aboutsummaryrefslogtreecommitdiffhomepage
path: root/init.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-07-13 14:30:36 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-07-13 14:30:36 -0400
commit1e278dce5dab93b73a3699aa2cc54fa6db11f34f (patch)
treec3b58e90f15b2443e74d1cceb0749a94bb7a5d3c /init.lua
parentde57ae800e07e36e21741ff8983f64ed24ff16f9 (diff)
Auto-highlight all occurrences of selected words and find results.
This supercedes `textadept.editing.highlight_word()`, which has been removed. Changed the color of word highlights in themes.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua11
1 files changed, 5 insertions, 6 deletions
diff --git a/init.lua b/init.lua
index 6653261c..63b022f9 100644
--- a/init.lua
+++ b/init.lua
@@ -67,12 +67,12 @@ view.set_theme = set_theme -- needed for the first view
if not arg then view:goto_buffer(buffer) end
-- Temporary compatibility.
-function lfs.dir_foreach(dir, f, filter, n, include_dirs) ui.dialogs.msgbox{text='Compatibility issue',text='Please change your use of "lfs.dir_foreach()" to "for filename in lfs.walk()"'}; for filename in lfs.walk(dir, filter, n, include_dirs) do if f(filename) == false then return end end end
+function lfs.dir_foreach(dir, f, filter, n, include_dirs) ui.dialogs.msgbox{title='Compatibility issue',text='Please change your use of "lfs.dir_foreach()" to "for filename in lfs.walk()"'}; for filename in lfs.walk(dir, filter, n, include_dirs) do if f(filename) == false then return end end end
setmetatable(_L, {__index = function(t, k) return rawget(t, k:gsub('_', '')) or 'No Localization:'..k end})
setmetatable(textadept.snippets, {__index = function(t, k) return rawget(t, k:gsub('^_', '')) end})
buffer.set_theme = function(...) view:set_theme(select(2, ...)); events.connect(events.INITIALIZED, function() ui.dialogs.msgbox{title='Compatibility issue',text='Please change your use of "buffer:set_theme()" to "view:set_theme()"'} end) end
-local function en_au_to_us() for au,us in pairs{CASEINSENSITIVEBEHAVIOUR_IGNORECASE=buffer.CASEINSENSITIVEBEHAVIOR_IGNORECASE,CASEINSENSITIVEBEHAVIOUR_RESPECTCASE=buffer.CASEINSENSITIVEBEHAVIOR_RESPECTCASE,INDIC_GRADIENTCENTRE=buffer.INDIC_GRADIENTCENTER,MARGIN_COLOUR=buffer.MARGIN_COLOR,auto_c_case_insensitive_behaviour=buffer.auto_c_case_insensitive_behavior,colourise=buffer.colorize,edge_colour=buffer.edge_color,set_fold_margin_colour=function()ui.dialogs.msgbox{text='Compatibility issue',text="Please update your theme's use of renamed buffer/view fields"}; return buffer.set_fold_margin_color end,set_fold_margin_hi_colour=buffer.set_fold_margin_hi_color,vertical_centre_caret=buffer.vertical_center_caret} do buffer[au]=us;view[au]=us end end; events.connect(events.BUFFER_NEW, en_au_to_us); en_au_to_us()
-events.connect(events.INITIALIZED, function() local update_keys={}; local function translate_keys(keys,new_keys) for k,v in pairs(keys) do if type(k)=='string' and k:find('^[cmas]+.$') and not k:find('ctrl') and not k:find('cmd') and not k:find('alt') and not k:find('meta') and not k:find('shift') then update_keys[#update_keys+1]=k; k=k:gsub('^(c?m?a?)s(.)','%1shift+%2'):gsub('^(c?m?)a(.)','%1alt+%2'):gsub('^(c?)m(.)',string.format('%%1%s%%2',OSX and 'cmd+' or 'meta+')):gsub('^c(.)','ctrl+%1') end new_keys[k]=type(v)=='table' and translate_keys(v,{}) or v end return new_keys end; for k,v in pairs(translate_keys(keys,{})) do keys[k]=v end; if #update_keys>0 then ui.dialogs.msgbox{text='Compatibility issue',text='Please update your keys to use the new modifiers:\n'..table.concat(update_keys,'\n')} end end)
+local function en_au_to_us() for au,us in pairs{CASEINSENSITIVEBEHAVIOUR_IGNORECASE=buffer.CASEINSENSITIVEBEHAVIOR_IGNORECASE,CASEINSENSITIVEBEHAVIOUR_RESPECTCASE=buffer.CASEINSENSITIVEBEHAVIOR_RESPECTCASE,INDIC_GRADIENTCENTRE=buffer.INDIC_GRADIENTCENTER,MARGIN_COLOUR=buffer.MARGIN_COLOR,auto_c_case_insensitive_behaviour=buffer.auto_c_case_insensitive_behavior,colourise=buffer.colorize,edge_colour=buffer.edge_color,set_fold_margin_colour=function()ui.dialogs.msgbox{title='Compatibility issue',text="Please update your theme's use of renamed buffer/view fields"}; return buffer.set_fold_margin_color end,set_fold_margin_hi_colour=buffer.set_fold_margin_hi_color,vertical_centre_caret=buffer.vertical_center_caret} do buffer[au]=us;view[au]=us end end; events.connect(events.BUFFER_NEW, en_au_to_us); en_au_to_us()
+events.connect(events.INITIALIZED, function() local update_keys={}; local function translate_keys(keys,new_keys) for k,v in pairs(keys) do if type(k)=='string' and k:find('^[cmas]+.$') and not k:find('ctrl') and not k:find('cmd') and not k:find('alt') and not k:find('meta') and not k:find('shift') then update_keys[#update_keys+1]=k; k=k:gsub('^(c?m?a?)s(.)','%1shift+%2'):gsub('^(c?m?)a(.)','%1alt+%2'):gsub('^(c?)m(.)',string.format('%%1%s%%2',OSX and 'cmd+' or 'meta+')):gsub('^c(.)','ctrl+%1') end new_keys[k]=type(v)=='table' and translate_keys(v,{}) or v end return new_keys end; for k,v in pairs(translate_keys(keys,{})) do keys[k]=v end; if #update_keys>0 then ui.dialogs.msgbox{title='Compatibility issue',text='Please update your keys to use the new modifiers:\n'..table.concat(update_keys,'\n')} end end)
-- The remainder of this file defines default buffer properties and applies them
-- to subsequent buffers. Normally, a setting like `buffer.use_tabs = false`
@@ -260,9 +260,8 @@ if not CURSES then view.indic_under[ui.find.INDIC_FIND] = true end
local INDIC_BRACEMATCH = textadept.editing.INDIC_BRACEMATCH
view.indic_style[INDIC_BRACEMATCH] = view.INDIC_BOX
view:brace_highlight_indicator(not CURSES, INDIC_BRACEMATCH)
-local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT
-view.indic_style[INDIC_HIGHLIGHT] = view.INDIC_ROUNDBOX
-if not CURSES then view.indic_under[INDIC_HIGHLIGHT] = true end
+view.indic_style[ui.INDIC_HIGHLIGHT] = view.INDIC_ROUNDBOX
+if not CURSES then view.indic_under[ui.INDIC_HIGHLIGHT] = true end
local INDIC_PLACEHOLDER = textadept.snippets.INDIC_PLACEHOLDER
view.indic_style[INDIC_PLACEHOLDER] = not CURSES and view.INDIC_DOTBOX or
view.INDIC_STRAIGHTBOX