editors

view Euphoria.tmbundle/Commands/Camel To Underscore.tmCommand @ 57:149815b0874c

* added installer for jEdit mode
author Shawn David Pringle B.Sc. <shawn.pringle@gmail.com>
date Fri Sep 25 00:03:32 2015 -0300 (2015-09-25)
parents
children
line source
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0">
4 <dict>
5 <key>name</key>
6 <string>Camel To Underscore</string>
7 <key>uuid</key>
8 <string>3C18F822-49F4-4BE2-B54C-69F61C133273</string>
9 <key>input</key>
10 <string>selection</string>
11 <key>output</key>
12 <string>replaceSelectedText</string>
13 <key>command</key>
14 <string>#!/usr/bin/env eui
16 include std/types.e
17 include std/text.e
18 include std/search.e
20 sequence funcName = getenv("TM_SELECTED_TEXT")
21 sequence newFuncName = ""
23 integer start = 1
24 if begins("cd", funcName) then
25 start = 3
26 end if
28 for i = start to length(funcName) do
29 if t_upper(funcName[i]) then
30 if i &gt; start then
31 newFuncName = append(newFuncName, '_')
32 end if
34 newFuncName = append(newFuncName, lower(funcName[i]))
35 else
36 newFuncName = append(newFuncName, funcName[i])
37 end if
38 end for
40 puts(1, newFuncName)
41 </string>
42 <key>scope</key>
43 <string></string>
44 <key>runEnvironment</key>
45 <string>windows</string>
46 <key>winCommand</key>
47 <string>#!/usr/bin/env eui
49 function is_upper(integer c)
50 return ((c &gt;= 65) and (c &lt;= 90))
51 end function
53 function to_lower(integer c)
54 return c + 32
55 end function
57 constant funcName = getenv("TM_SELECTED_TEXT")
58 if atom(funcName) then
59 abort(0)
60 end if
62 for i = 1 to length(funcName) do
63 if is_upper(funcName[i]) then
64 if i &gt; 1 then
65 puts(1, '_')
66 end if
68 puts(1, to_lower(funcName[i]))
69 else
70 puts(1, funcName[i])
71 end if
72 end for
73 </string>
74 <key>keyEquivalent</key>
75 <string>@_</string>
76 </dict>
77 </plist>

SCM Home | OpenEuphoria.org Home