aboutsummaryrefslogtreecommitdiff
path: root/test/test.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-06-05 22:00:31 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-06-05 22:00:31 -0400
commit20833c35fd6d580c934cb6c3f6e7b9a2c39ac99b (patch)
tree370beb025b4868a475efa682373968c5b7a76a95 /test/test.lua
parent0dc1a169161395987f28a11b9dc72ac7c04f605d (diff)
downloadtextadept-20833c35fd6d580c934cb6c3f6e7b9a2c39ac99b.tar.gz
textadept-20833c35fd6d580c934cb6c3f6e7b9a2c39ac99b.zip
Renamed `buffer:set_theme()` to `view:set_theme()` and fixed a bug with splits.
Also improved separate themes-per-view functionality.
Diffstat (limited to 'test/test.lua')
-rw-r--r--test/test.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index 6985bfc1..650b092b 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -2955,6 +2955,24 @@ function test_view_split_resize_unsplit()
assert_equal(#_VIEWS, 1)
end
+function test_view_split_refresh_styles()
+ io.open_file(_HOME .. '/init.lua')
+ local GETNAMEDSTYLE = _SCINTILLA.properties.named_styles[1]
+ local style = buffer:private_lexer_call(GETNAMEDSTYLE, 'library')
+ assert(style > 1, 'cannot retrieve number of library style')
+ local color = view.style_fore[style]
+ assert(color ~= view.style_fore[view.STYLE_DEFAULT], 'library style not set')
+ view:split()
+ for _, view in ipairs(_VIEWS) do
+ local view_style = buffer:private_lexer_call(GETNAMEDSTYLE, 'library')
+ assert_equal(view_style, style)
+ local view_color = view.style_fore[view_style]
+ assert_equal(view_color, color)
+ end
+ view:unsplit()
+ buffer:close(true)
+end
+
function test_buffer_read_write_only_properties()
assert_raises(function() view.all_lines_visible = false end, 'read-only property')
assert_raises(function() return buffer.auto_c_fill_ups end, 'write-only property')
@@ -2963,6 +2981,21 @@ function test_buffer_read_write_only_properties()
assert_raises(function() return view.marker_alpha[INDEX(1)] end, 'write-only property')
end
+function test_set_theme()
+ local current_theme = view.style_fore[view.STYLE_DEFAULT]
+ view:split()
+ io.open_file(_HOME .. '/init.lua')
+ view:split(true)
+ io.open_file(_HOME .. '/src/textadept.c')
+ _VIEWS[2]:set_theme('dark')
+ _VIEWS[3]:set_theme('light')
+ assert(_VIEWS[2].style_fore[view.STYLE_DEFAULT] ~= _VIEWS[3].style_fore[view.STYLE_DEFAULT], 'same default styles')
+ buffer:close(true)
+ buffer:close(true)
+ ui.goto_view(_VIEWS[1])
+ view:unsplit()
+end
+
-- TODO: test init.lua's buffer settings
-- Load buffer and view API from their respective LuaDoc files.