EuGeany: Swapping support for Euphoria/Lua

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

I have posted my latest version of Geany support files and utility programs on the RDS User contribution page: http://www.rapideuphoria.com/eugeany.tar.gz . The Context Sensitive Help Program EuHelp is included with the support files, together with a utility program called "gny.ex", which is used to backup the original lua support files and restore them, if desired. A "euphoria enabled" snippets file is also included.

All the support files and utility programs are contained in the directory "EuGeany". Once you decompress the EuGeany folder, all you have to do is run the program gny.ex to install and set the system up so you can swap lua/euphoria support whenever you wish.

IMPORTANT: you will need to edit the constants which reference FILEDEF_DIR, FILETYPE_EXT_DIR, and SNIPPETS_DIR before running gny.ex! The latest version of gny.ex is included below, but everything you need is contained in the EuGeany download files.

Gny.ex is set up to translate/compile EuHelp.ex and gny.ex and then copy those programs to EUDIR/bin/ by default, but you can install those programs manually by setting the value of the constant COMPILE_INSTALL_EUHELP_GNY to FALSE. The path to EUDIR is set without using an environment variable

Comments, suggestions for improvements, etc. will be appreciated.

-- 
-- gny.ex 
-- A program to automate Geany editor support for euphoria. 
-- Configuration files for the programming language lua are used to support euphoria. 
-- Lua or Euphoria file support can be swapped at will by executing this program 
-- from Geany's Terminal interface, as described below. 
-- 
-- IMPORTANT: before running this program, you must edit the three constants: 
-- to reference the respective directories as illustrated below: 
-- FILEDEF_DIR 
-- FILETYPE_EXT_DIR 
-- SNIPPETS_DIR 
 
--  
-- usage:-- FILEDEF_DIR 
-- FILETYPE_EXT_DIR 
-- SNIPPETS_DIR 
-- eui gny.ex i to initialize & backup origninal files 
-- eui gny.ex l to enable support for lua 
-- eui gny.ex e to enable support for euphoria 
 
-- This program (gny.ex) will automatically compile and install itself EUDIR/bin/, 
-- if the COMPILE_INSTALL_EUHELP_GNY constant is set to TRUE.  
 
 
include std/filesys.e 
include std/console.e 
include std/io.e 
include std/text.e 
include EuDir.e  -- provides the path to the directory "euphoria" assigned to the    
-- public constant, EUDIR, without using an environment variable, as suggested by 
-- SDPRINGLE  
 
integer TRUE = 1, FALSE = 0 
 
constant BACKUP_INSTALL =  TRUE -- <<<------  change to FALSE after initial install/backup 
	 -- the backup_install routine should only be executed once! 
 
 
constant COMPILE_INSTALL_EUHELP_GNY = TRUE -- EuHelp.ex & gny.ex will be translated to C-code 
-- compiled and the EuHelp and gny binaries will be copied to EUDIR/bin or EUDIR\bin. 
-- Insert [EuHelp.ex %s] Geany's Preferences/Tools/Commands/Context action box and 
-- assign a key and you will have context sensitive help available for std library functions 
-- at the press of a key. From Geany's Terminal, execute  gny with the commandline option i 
-- to install the original lua files or install euphoria support files. 
-- 
-- The original lua support files will remain in effect until you  execute "gny e" which will select your 
-- euphoria support enabled files in the place of the original files which support the lua language. 
-- File support for euphoria will remain in effect until you restore support for lua 
-- by executing "gny l" from Geany's Terminal window. 
 
 
-- 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 
 
 
constant EUBIN = EUDIR & "bin" & SLASH 
 
procedure gny(object cl) 
 
    -- lua 
    if equal(cl, "l") then 
	-- restore 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\tfiletypes.lua now supports the lua programming language!\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 by overwriting the current files wich support 
	-- the lua programming language with the files edited to support the euphoria programming language: 
 
	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 
	--   backup original lua files and install euphoria support files 
	--   copy filetypes.lua to filetypes.lua~ 
	--   copy filetype_extensions.lua to filetype_extensions.lua~ 
	--   copy snippets.conf to snippets.lua~ 
 
	if BACKUP_INSTALL then 
	    -- backup the original files which support the lua programming language: 
	    -- backup/copy original filetypes.lua file to filetypes.lua~ 
	    if copy_file( FILEDEF_DIR & "filetypes.lua",  FILEDEF_DIR & "~", 1) 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/copy original filetype_extensions.conf to filetype_extensions.lua~ 
	    if copy_file( FILETYPE_EXT_DIR & "filetype_extensions.conf", 
			    FILETYPE_EXT_DIR & "filetype_extensions.lua~", 1) 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/copy original "snippets.conf" to "snippets.lua~" 
	    if copy_file( SNIPPETS_DIR & "snippets.conf",  SNIPPETS_DIR & "snippets.lua~", 1) then 
		puts(SCREEN, "\n\n\tsnippets.conf backed up as snippets.lua.~\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 to filetypes.euphoria~ 
	    if copy_file( "filetypes.euphoria",  FILEDEF_DIR & "filetypes.euphoria~", 1) then 
		puts(SCREEN, "\n\tfiletypes.euphoria installed to:") 
		puts(SCREEN, "\n\t" & FILEDEF_DIR & "filetypes.euphoria~\n\t") 
	    else 
		puts(SCREEN, "\n\tFAILED to install filetypes.euphoria~ to:") 
		puts(SCREEN, "\n\t" & FILEDEF_DIR & "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~", 1) then 
		puts(SCREEN, "\n\n\tfiletype_extensions.euphoria installed to:") 
		puts(SCREEN, "\n\t" & FILETYPE_EXT_DIR & "filetype_extensions.euphoria~\n\t") 
	    else 
		puts(SCREEN, "\n\tFAILED to install filetype_extensions.euphoria~ to:") 
		puts(SCREEN, "\n\t" & FILETYPE_EXT_DIR & "filetype_extensions.euphoria~\n\t") 
	    end if 
	    any_key() 
 
	    -- copy "snippets.euphoria" to "snippets.euphoria~" 
	    if copy_file( "snippets.euphoria",  SNIPPETS_DIR & "snippets.euphoria~", 1) then 
		puts(SCREEN, "\n\n\tsnippets.euphoria installed to:") 
		puts(SCREEN, "\n\t" & SNIPPETS_DIR & "snippets.euphoria~\n\t") 
	    else 
		puts(SCREEN, "\n\tFAILED to install snippets.euphoria~  FAILED\n\t") 
	    end if 
	    any_key() 
     
	    -- compile EuHelp.ex and gny.ex and copy to EUDIR/bin/ 
	    if COMPILE_INSTALL_EUHELP_GNY then 
	     
		system("euc gny.ex", 1) 
		if copy_file("gny", EUBIN & "gny",1) then 
		    puts(SCREEN, "\n\tgny.ex copied to " & EUBIN &  "gny\n") 
		else 
		    puts(SCREEN, "Failed to copy gny to " & EUBIN) 
		end if 
     
		system("euc EuHelp.ex", 1) 
		if copy_file("EuHelp", EUBIN & "EuHelp\n",1) then 
		    puts(SCREEN, "\n\tEuHelp copied to " & EUBIN &  "EuHelp") 
		else 
		    puts(SCREEN, "Failed to copy EuHelp to " & EUBIN) 
		end if 
     
	    end if 
     
	end if 
 
    end if 
end procedure 
 
 
integer MENU = TRUE 
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 
	cl = prompt_string("\n\t") 
	cl = lower(cl) 
	if find(cl, options) then 
	    MENU = FALSE 
	    if equal(cl,"q") then 
		abort(1) 
	    end if 
	end if 
    end while 
else 
    cl=cl[3] 
    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