Scite Make Monospace |
|
MakeMonospace right after initializing a
monospace-mandatory script, the user no longer has to hit Ctrl+F11.
With a bit more code, it should be possible to automatically make certain file types open in monospace. This would allow for a mixed monospace-proportional font environment without the hassle of hitting Ctrl+F11 all the time.
The script forces a buffer into monospace mode by overriding the usual
style properties. It uses extman to hook to OnSwitchFile.
----------------------------------------------------------------------- -- makes a buffer monospace <khman@users.sf.net> public domain 20060906 ----------------------------------------------------------------------- -- [[ scite_Command('Make Monospace|MakeMonospace|Ctrl+8') function MakeMonospace() local MonoFont, MonoSize = "Courier New", 9 local SIG = "MakeMonospace" local function AllMono() for i = 0, 127 do editor.StyleFont[i] = MonoFont editor.StyleSize[i] = MonoSize end editor:Colourise(0, -1) end scite_OnSwitchFile(function() if buffer[SIG] then AllMono() return true end end) buffer[SIG] = true AllMono() end --]]
-- retrieve monospace font information local StyleMono = {} local monoprop = props["font.monospace"] for style, value in string.gfind(monoprop, "([^,:]+):([^,]+)") do StyleMono[style] = value end -- grab styles, assuming they are defined MonoFont = StyleMono.font MonoSize = tonumber(StyleMono.size)