aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/menu.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-05-25 21:16:01 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-05-25 21:16:01 -0400
commitf2374c4aba53fa462dc88d4104e10d8cb97e61ba (patch)
tree5e5a9d26a5ad8915c0e12187dd059b1109fcf22d /modules/textadept/menu.lua
parenteffc636745e8d9c680c3acf42e8e25eed10cd903 (diff)
downloadtextadept-f2374c4aba53fa462dc88d4104e10d8cb97e61ba.tar.gz
textadept-f2374c4aba53fa462dc88d4104e10d8cb97e61ba.zip
Allow views to be used as buffers and update API.
This allows for a superficial separation of buffer- and view-specific Scintilla functionality. buffers and views can now be used interchangeably for the most part, and the APIs are guidance, not hard requirements. User scripts do not require any modification and will continue to function normally.
Diffstat (limited to 'modules/textadept/menu.lua')
-rw-r--r--modules/textadept/menu.lua30
1 files changed, 14 insertions, 16 deletions
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index a92c2498..c998ade6 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -292,17 +292,15 @@ local default_menubar = {
{_L['UTF-16 Encoding'], function() set_encoding('UTF-16LE') end}
},
SEPARATOR,
- {_L['Toggle View EOL'], function()
- buffer.view_eol = not buffer.view_eol
- end},
+ {_L['Toggle View EOL'], function() view.view_eol = not view.view_eol end},
{_L['Toggle Wrap Mode'], function()
- local first_visible_line = buffer.first_visible_line
- local display_line = buffer:visible_from_doc_line(first_visible_line)
- buffer.wrap_mode = buffer.wrap_mode == 0 and buffer.WRAP_WHITESPACE or 0
- buffer:line_scroll(0, first_visible_line - display_line)
+ local first_visible_line = view.first_visible_line
+ local display_line = view:visible_from_doc_line(first_visible_line)
+ view.wrap_mode = view.wrap_mode == 0 and view.WRAP_WHITESPACE or 0
+ view:line_scroll(0, first_visible_line - display_line)
end},
{_L['Toggle View Whitespace'], function()
- buffer.view_ws = buffer.view_ws == 0 and buffer.WS_VISIBLEALWAYS or 0
+ view.view_ws = view.view_ws == 0 and view.WS_VISIBLEALWAYS or 0
end},
SEPARATOR,
{_L['Select Lexer...'], textadept.file_types.select_lexer},
@@ -318,28 +316,28 @@ local default_menubar = {
{_L['Unsplit View'], function() view:unsplit() end},
{_L['Unsplit All Views'], function() while view:unsplit() do end end},
{_L['Grow View'], function()
- if view.size then view.size = view.size + buffer:text_height(1) end
+ if view.size then view.size = view.size + view:text_height(1) end
end},
{_L['Shrink View'], function()
- if view.size then view.size = view.size - buffer:text_height(1) end
+ if view.size then view.size = view.size - view:text_height(1) end
end},
SEPARATOR,
{_L['Toggle Current Fold'], function()
- buffer:toggle_fold(buffer:line_from_position(buffer.current_pos))
+ view:toggle_fold(buffer:line_from_position(buffer.current_pos))
end},
SEPARATOR,
{_L['Toggle Show Indent Guides'], function()
- local off = buffer.indentation_guides == 0
- buffer.indentation_guides = off and buffer.IV_LOOKBOTH or 0
+ local off = view.indentation_guides == 0
+ view.indentation_guides = off and view.IV_LOOKBOTH or 0
end},
{_L['Toggle Virtual Space'], function()
local off = buffer.virtual_space_options == 0
buffer.virtual_space_options = off and buffer.VS_USERACCESSIBLE or 0
end},
SEPARATOR,
- {_L['Zoom In'], buffer.zoom_in},
- {_L['Zoom Out'], buffer.zoom_out},
- {_L['Reset Zoom'], function() buffer.zoom = 0 end}
+ {_L['Zoom In'], view.zoom_in},
+ {_L['Zoom Out'], view.zoom_out},
+ {_L['Reset Zoom'], function() view.zoom = 0 end}
},
{
title = _L['Help'],