Geany: Swapping support for Euphoria/Lua

new topic     » goto parent     » topic index » view thread      » older message » newer message

This little utility program allows switching back and forth between the original files which support lua and the lua files which have been edited to support euphoria.

The euphoria support files will be snippets.euphoria, filetypes.euphoria, and filetype_extensions.euphoria. A program called gny.ex can easily be executed from Geany's Terminal Window "Pane". The program accepts three command line switches - "i", "l", or "e": "i" will backup the original lua enabled files and install the new euphoria enabled files. The backup-installation option should be executed only once. Subsequently, the user may select euphoria support by executing "eui gny.ex e" or "eui gny.ex l" to select the original lua enabled support files. After switching filetype support the user should select "Reload Configuration" from the Tools menu.

Any suggestions for improvement will be greatly appreciated.

-- 
-- 
-- Gny.ex, a program to automate Geany editor support for euphoria 
-- by swapping Lua/Euphoria filetypes at will 
-- 
-- 
 
include std/filesys.e 
include std/console.e 
include std/io.e 
include std/text.e 
 
constant BACKUP_INSTALL =  1 -- <<<------  change to 0 after initial install/backup 
                 -- the backup_install routine should only be executed once! 
 
-- edit paths to your directories containing: 
constant FILEDEF_DIR =     "/home/ken/.config/geany/filedefs/"  -- filetypes.lua 
constant FILETYPE_EXT_DIR = "/home/ken/.config/geany/"       -- filetype_extensions.conf" 
constant SNIPPETS_DIR =     "/home/ken/.config/geany/"    -- snippets.conf 
 
 
-- backup original lua files and install euphoria support files 
-- copy filetypes.lua to filetypes.lua~ 
-- copy filetype_extensions.lua to filetype_extensions.conf~ 
-- copy snippets.conf to snippets.conf~ 
 
-- "l" for lua support 
-- "e" for euphoria support 
-- "i" to initialize backup origninal files 
procedure gny(sequence cl) 
 
    -- lua 
    if equal(cl, "l") then 
    -- restore/install original files with support for the lua programing language. 
    -- the current files will be overwritten: 
 
    if copy_file( FILEDEF_DIR & "filetypes.lua~", FILEDEF_DIR & "filetypes.lua", 1) then 
        puts(SCREEN, "\n\tfiletype support for the language lua restored!\n\t") 
    else 
        puts(SCREEN, "\n\t Failed to restore the original filetypes.lua file!\n\t") 
    end if 
    any_key() 
 
    if copy_file( FILETYPE_EXT_DIR & "filetype_extensions.lua~", 
                FILETYPE_EXT_DIR & "filetype_extensions.conf", 1) then 
        puts(SCREEN, "\n\tfiletype_extensions.conf now supports the lua programming language!\n\t") 
    else 
        puts(SCREEN, "\n\t Failed to restore filetype_extensions.conf file!\n\t") 
    end if 
    any_key() 
 
    if copy_file( SNIPPETS_DIR & "snippets.lua~", 
                SNIPPETS_DIR & "snippets.conf", 1) then 
        puts(SCREEN, "\n\tsnippets.conf now supports the lua programming language!\n\t") 
    else 
        puts(SCREEN, "\n\t Failed to restore the original snippets.conf file with lua support!\n\t") 
    end if 
    any_key() 
 
 
    -- euphoria 
    elsif equal(cl,"e") then 
    -- restore/install euphoria support files: overwrite the current files: 
 
    if copy_file( FILEDEF_DIR & "filetypes.euphoria~", FILEDEF_DIR & "filetypes.lua", 1) then 
        puts(SCREEN, "\n\tfiletypes.lua now supports the Euphoria Programming Language!\n\t") 
    else 
        puts(SCREEN, "\n\tFAILED to install filetypes.lua, " 
               & "\n\t with support for the Euphoria Programming Language\n\t") 
    end if 
    any_key() 
 
    if copy_file( FILETYPE_EXT_DIR & "filetype_extensions.euphoria~", 
                FILETYPE_EXT_DIR & "filetype_extensions.conf", 1) then 
        puts(SCREEN, "\n\tfiletype_extensions.conf now supports the Euphoria Programming Language!\n\t") 
    else 
        puts(SCREEN, "\n\tFAILED to install filetypes.lua, " 
               & "\n\t with support for the Euphoria Programming Language\n\t") 
    end if 
    any_key() 
 
    if copy_file(SNIPPETS_DIR & "snippets.euphoria~", SNIPPETS_DIR & "snippets.conf", 1) then 
        puts(SCREEN, "\n\tsnippets.conf now supports the Euphoria Programming Language!\n\t") 
    else 
        puts(SCREEN, "\n\tFAILED to install snippets.conf, " 
               & "\n\t with support for the Euphoria Programming Language\n\t") 
    end if 
    any_key() 
 
 
    elsif equal(cl,"i") then 
 
    if BACKUP_INSTALL then 
    -- backup the original files which support the lua programming language: 
    -- backup original filetypes.lua file to filetypes.lua~ 
        if copy_file( FILEDEF_DIR & "filetypes.lua",  FILEDEF_DIR & "~", 0) then 
        puts(SCREEN, "\n\tfiletypes.lua backed up as filetypes.lua~\n\t") 
        else 
        puts(SCREEN, "\n\tfiletypes.lua back up as filetypes.lua~ FAILED!\n\t") 
        end if 
        any_key() 
 
        -- backup original filetype_extensions.conf to filetype_extensions.conf~ 
        if copy_file( FILETYPE_EXT_DIR & "filetype_extensions.conf", 
                  FILETYPE_EXT_DIR & "filetype_extensions.lua~", 0) then 
        puts(SCREEN, "\n\n\tfiletype_extensions.conf backed up as filetype_extensions.lua~\n\t") 
        else 
        puts(SCREEN, "\n\tfiletype_extensions.conf back up as filetype_extensions.lua~  FAILED\n\t") 
        end if 
        any_key() 
 
        -- backup original "snippets.conf" to "snippets.conf~" 
        if copy_file( SNIPPETS_DIR & "snippets.conf",  SNIPPETS_DIR & "snippets.lua~", 0) then 
        puts(SCREEN, "\n\n\tsnippets.conf backed up as snippets.conf.~\n\t") 
        else 
        puts(SCREEN, "\n\tFAILED to back up file snippets.conf as snippets.lua~  FAILED\n\t") 
        end if 
        any_key() 
 
 
        -- now, install euphoria support files: 
 
        -- copy filetypes.euphoria as filetypes.euphoria~ 
        if copy_file( "filetypes.euphoria",  FILEDEF_DIR & "filetypes.euphoria~", 0) then 
        puts(SCREEN, "\n\tfiletypes.euphoria installed as filetypes.euphoria~\n\t") 
        else 
        puts(SCREEN, "\n\tFAILED to install filetypes.euphoria~!\n\t") 
        end if 
        any_key() 
 
        -- copy "filetype_extensions.euphoria" to "filetype_extensions.euphoria~" 
        if copy_file( "filetype_extensions.euphoria", 
                   FILETYPE_EXT_DIR & "filetype_extensions.euphoria~", 0) then 
        puts(SCREEN, "\n\n\tfiletype_extensions.euphoria installed as filetype_extensions.euphoria~\n\t") 
        else 
        puts(SCREEN, "\n\tFAILED to install back filetype_extensions.euphoria~  FAILED\n\t") 
        end if 
        any_key() 
 
        -- copy "snippets.euphoria" to "snippets.euphoria~" 
        if copy_file( "snippets.euphoria",  SNIPPETS_DIR & "snippets.euphoria~", 0) then 
        puts(SCREEN, "\n\n\tsnippets.euphoria installed as snippets.euphoria~") 
        else 
        puts(SCREEN, "\n\tFAILED to install snippets.euphoria~  FAILED\n\t") 
        end if 
        any_key() 
    end if 
 
    end if 
 
end procedure 
 
 
integer MENU = 1 
integer n 
sequence options = { "i", "e", "l", "q" } 
object cl = command_line() 
if length(cl)<3 then 
    puts(1,"\n\tEnter \"i\" - initial backup/install.  ONLY EXECUTE ONCE!") 
    puts(1,"\n\tEnter \"e\" - install euphoria support ( as lua )") 
    puts(1,"\n\tEnter \"l\" - install/restore original lua support files") 
    puts(1,"\n\tEnter \"q\" - exit\n\t") 
    while MENU do 
        n = get_key() 
        if find(n, { 113, 108, 105, 101 }) then 
        MENU = 0 
        end if 
    end while 
    if n = 113 then 
        abort(1) 
    elsif n = 108 then 
        cl = "l" 
    elsif n = 101 then 
        cl = "e" 
    elsif n = 105 then 
        cl = "i" 
    end if 
else 
    cl=cl[3] 
    for i = 1 to length(options) do 
    if find(options[i], cl) then 
        gny(options[i]) 
    end if 
    end for 
cl = lower(cl) 
end if 
 
gny(cl) 
 
 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu