[Ipe-discuss] Setting default style sheets

Norbert Zeh nzeh at cs.dal.ca
Fri Jan 8 07:19:40 CET 2010


Thanks so much, Otfried.  Your responsiveness is impressive!

Cheers,
Norbert
Otfried Cheong [2010.01.08 1031 +0900]:
> Norbert Zeh wrote:
>> I'm trying to replace the "basic" stylesheet with one of my own by
>> default for all my documents.  Since it's the default, I don't want to
>> have to do this manually for every document.  What I did is create my
>> own prefs.lua in my personal ipelets directory.  Currently it looks very
>> simple:
>>
>> prefs.max_zoom = 10
>> prefs.styles = { "nzeh_monochrome" }
>>
>> A file called nzeh_monochrome.isy is present in ipe's styles directory,
>> and when I select Help->Show configuration, I see that nzeh_monochrome
>> is listed as the style for new documents.  
>
> And indeed you are doing everything right.  There is a bug in  
> "main.lua", in that ipelets are loaded after the configuration has been  
> analyzed.
>
> I'm attaching a patch, to be applied in the "lua" directory.
>
> Otfried
>

> Index: main.lua
> ===================================================================
> --- main.lua	(revision 405)
> +++ main.lua	(working copy)
> @@ -144,6 +144,41 @@
>    table.insert(config.ipeletDirs, 1, config.home .. "/.ipe/ipelets")
>  end
>  
> +-- look for ipelets
> +ipelets = {}
> +for _,w in ipairs(config.ipeletDirs) do
> +  if ipe.fileExists(w) then 
> +    for f in lfs.dir(w) do
> +      if f:sub(-4) == ".lua" then
> +	ff = assert(loadfile(w .. "/" .. f))
> +	ft = {}
> +	ft._G = _G
> +	ft.ipe = ipe
> +	ft.ipeui = ipeui
> +	ft.math = math
> +	ft.string = string
> +	ft.table = table
> +	ft.assert = assert
> +	ft.shortcuts = shortcuts
> +	ft.prefs = prefs
> +	ft.ipairs = ipairs
> +	ft.pairs = pairs
> +	ft.print = print
> +	ft.tonumber = tonumber
> +	ft.tostring = tostring
> +	ft.name = f:sub(1,-5)
> +	ft.dllname = w .. "/" .. ft.name
> +	setfenv(ff, ft)
> +	ff()
> +	-- if it has no label, then running it once was all
> +	if ft.label then
> +	  ipelets[#ipelets + 1] = ft
> +	end
> +      end
> +    end
> +  end
> +end
> +
>  if #argv == 1 and argv[1] == "-show-configuration" then
>    show_configuration()
>    return
> @@ -179,41 +214,6 @@
>    config.styleList[#config.styleList + 1] = w
>  end
>  
> --- look for ipelets
> -ipelets = {}
> -for _,w in ipairs(config.ipeletDirs) do
> -  if ipe.fileExists(w) then 
> -    for f in lfs.dir(w) do
> -      if f:sub(-4) == ".lua" then
> -	ff = assert(loadfile(w .. "/" .. f))
> -	ft = {}
> -	ft._G = _G
> -	ft.ipe = ipe
> -	ft.ipeui = ipeui
> -	ft.math = math
> -	ft.string = string
> -	ft.table = table
> -	ft.assert = assert
> -	ft.shortcuts = shortcuts
> -	ft.prefs = prefs
> -	ft.ipairs = ipairs
> -	ft.pairs = pairs
> -	ft.print = print
> -	ft.tonumber = tonumber
> -	ft.tostring = tostring
> -	ft.name = f:sub(1,-5)
> -	ft.dllname = w .. "/" .. ft.name
> -	setfenv(ff, ft)
> -	ff()
> -	-- if it has no label, then running it once was all
> -	if ft.label then
> -	  ipelets[#ipelets + 1] = ft
> -	end
> -      end
> -    end
> -  end
> -end
> -
>  MODEL:new(first_file)
>  
>  ipeui.mainLoop()

> _______________________________________________
> Ipe-discuss mailing list
> Ipe-discuss at cs.uu.nl
> https://mail.cs.uu.nl/mailman/listinfo/ipe-discuss


-- 
"And it happened all the time that the compromise between two perfectly
rational alternatives was something that made no sense at all."
  -- Neal Stephenson, Anathem



More information about the Ipe-discuss mailing list