editors

changeset 36:5f1c1af05fe7

Added Camel to Underscore command for TextMate and e-TextEditor bundle
author Jeremy Cowgar <jeremy@cowgar.com>
date Mon Nov 29 22:13:39 2010 -0500 (2010-11-29)
parents d5b077700445
children 3f2d268670b9
files Euphoria.tmbundle/Commands/Camel To Underscore.tmCommand Euphoria.tmbundle/Commands/Test Current File.tmCommand Euphoria.tmbundle/info.plist
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Euphoria.tmbundle/Commands/Camel To Underscore.tmCommand	Mon Nov 29 22:13:39 2010 -0500
     1.3 @@ -0,0 +1,77 @@
     1.4 +<?xml version="1.0" encoding="UTF-8" ?>
     1.5 +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     1.6 +<plist version="1.0">
     1.7 +    <dict>
     1.8 +        <key>name</key>
     1.9 +        <string>Camel To Underscore</string>
    1.10 +        <key>uuid</key>
    1.11 +        <string>3C18F822-49F4-4BE2-B54C-69F61C133273</string>
    1.12 +        <key>input</key>
    1.13 +        <string>selection</string>
    1.14 +        <key>output</key>
    1.15 +        <string>replaceSelectedText</string>
    1.16 +        <key>command</key>
    1.17 +        <string>#!/usr/bin/env eui
    1.18 +
    1.19 +include std/types.e
    1.20 +include std/text.e
    1.21 +include std/search.e
    1.22 +
    1.23 +sequence funcName = getenv("TM_SELECTED_TEXT")
    1.24 +sequence newFuncName = ""
    1.25 +
    1.26 +integer start = 1
    1.27 +if begins("cd", funcName) then
    1.28 +	start = 3
    1.29 +end if
    1.30 +
    1.31 +for i = start to length(funcName) do
    1.32 +	if t_upper(funcName[i]) then
    1.33 +		if i &gt; start then
    1.34 +			newFuncName = append(newFuncName, '_')
    1.35 +		end if
    1.36 +		
    1.37 +		newFuncName = append(newFuncName, lower(funcName[i]))
    1.38 +	else
    1.39 +		newFuncName = append(newFuncName, funcName[i])
    1.40 +	end if
    1.41 +end for
    1.42 +
    1.43 +puts(1, newFuncName)
    1.44 +</string>
    1.45 +        <key>scope</key>
    1.46 +        <string></string>
    1.47 +        <key>runEnvironment</key>
    1.48 +        <string>windows</string>
    1.49 +        <key>winCommand</key>
    1.50 +        <string>#!/usr/bin/env eui
    1.51 +
    1.52 +function is_upper(integer c)
    1.53 +	return ((c &gt;= 65) and (c &lt;= 90))
    1.54 +end function
    1.55 +
    1.56 +function to_lower(integer c)
    1.57 +	return c + 32
    1.58 +end function
    1.59 +
    1.60 +constant funcName = getenv("TM_SELECTED_TEXT")
    1.61 +if atom(funcName) then
    1.62 +	abort(0)
    1.63 +end if
    1.64 +
    1.65 +for i = 1 to length(funcName) do
    1.66 +	if is_upper(funcName[i]) then
    1.67 +		if i &gt; 1 then
    1.68 +			puts(1, '_')
    1.69 +		end if
    1.70 +
    1.71 +		puts(1, to_lower(funcName[i]))
    1.72 +	else
    1.73 +		puts(1, funcName[i])
    1.74 +	end if
    1.75 +end for
    1.76 +</string>
    1.77 +        <key>keyEquivalent</key>
    1.78 +        <string>@_</string>
    1.79 +    </dict>
    1.80 +</plist>
     2.1 --- a/Euphoria.tmbundle/Commands/Test Current File.tmCommand	Sat Nov 27 15:28:36 2010 -0500
     2.2 +++ b/Euphoria.tmbundle/Commands/Test Current File.tmCommand	Mon Nov 29 22:13:39 2010 -0500
     2.3 @@ -27,11 +27,11 @@
     2.4  
     2.5  sequence FilePath = getenv("TM_FILEPATH")
     2.6  sequence FileDir  = getenv("TM_DIRECTORY")
     2.7 -
     2.8 +sequence FileName = filename(FilePath)
     2.9  filesys:chdir(FileDir)
    2.10  filesys:delete_file("ex.err")
    2.11  
    2.12 -sequence command = sprintf("eui -wf ex.warn -test -batch %s", { FilePath })
    2.13 +sequence command = sprintf("eui -wf ex.warn -test -batch %s", { FileName })
    2.14  if system_exec(command) = 0 then
    2.15  	puts(1, `&lt;font color="#448844"&gt;&lt;b&gt;Success&lt;/b&gt;&lt;/font&gt;`)
    2.16  else
    2.17 @@ -67,5 +67,7 @@
    2.18          <string>source.euphoria</string>
    2.19          <key>beforeRunningCommand</key>
    2.20          <string>saveActiveFile</string>
    2.21 +        <key>keyEquivalent</key>
    2.22 +        <string>@N</string>
    2.23      </dict>
    2.24  </plist>
     3.1 --- a/Euphoria.tmbundle/info.plist	Sat Nov 27 15:28:36 2010 -0500
     3.2 +++ b/Euphoria.tmbundle/info.plist	Mon Nov 29 22:13:39 2010 -0500
     3.3 @@ -16,6 +16,7 @@
     3.4          <dict>
     3.5              <key>items</key>
     3.6              <array>
     3.7 +                <string>3C18F822-49F4-4BE2-B54C-69F61C133273</string>
     3.8                  <string>DC2E2191-0318-4031-AC5C-7ED23D0F8732</string>
     3.9              </array>
    3.10          </dict>

SCM Home | OpenEuphoria.org Home