aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-07-07 21:02:07 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-07-07 21:02:07 -0400
commit584e580c2213f91a17425be10d57aa5bd2f3d509 (patch)
treef47ca2ee2a85bcfba437ddd989b27284827c542c
parent021866de868fd074526fc63270639ec2f3ce9aa5 (diff)
Added `lexer.colors` and `lexer.styles` and updated themes to utilize them.
This allows for a more Lua table-oriented approach to defining and using colors and styles, instead of manually manipulating Scintilla property strings. Themes are still backwards compatible, as the underlying mechanisms are still in place.
-rw-r--r--core/.view.luadoc14
-rw-r--r--doc/manual.md73
-rw-r--r--init.lua44
-rw-r--r--src/Makefile2
-rw-r--r--src/textadept.c16
-rw-r--r--test/test.lua6
-rw-r--r--themes/dark.lua185
-rw-r--r--themes/light.lua184
-rw-r--r--themes/term.lua112
9 files changed, 350 insertions, 286 deletions
diff --git a/core/.view.luadoc b/core/.view.luadoc
index 4196200b..8b24e3d8 100644
--- a/core/.view.luadoc
+++ b/core/.view.luadoc
@@ -1447,15 +1447,17 @@ function unsplit(view) end
function goto_buffer(view, buffer) end
---
--- Sets the view's color theme to be string *name* and (optionally) assigns
--- the properties contained in table *props*.
+-- Sets the view's color theme to be string *name*, with the contents of table
+-- *options* available as global variables.
-- User themes override Textadept's default themes when they have the same name.
-- If *name* contains slashes, it is assumed to be an absolute path to a theme
-- instead of a theme name.
-- @param view A view.
-- @param name The name or absolute path of a theme to set.
--- @param props Optional table of theme property assignments that override the
--- theme's defaults.
--- @usage view:set_theme('light', {font = 'Monospace', fontsize = 12})
+-- @param options Optional table of global variables themes can utilize to
+-- override default settings such as font and size.
+-- @usage view:set_theme('light', {font = 'Monospace', size = 12})
-- @name set_theme
-function set_theme(view, name, props) end
+-- @see _G.lexer.colors
+-- @see _G.lexer.styles
+function set_theme(view, name, options) end
diff --git a/doc/manual.md b/doc/manual.md
index 10717c16..a0025131 100644
--- a/doc/manual.md
+++ b/doc/manual.md
@@ -1249,33 +1249,34 @@ terminal version uses "term".
&nbsp;&nbsp;
![Term Theme](images/termtheme.png)
-Each theme is a single Lua file. It contains color and style definitions for
-displaying syntactic elements like comments, strings, and keywords in
-programming language source files. These [definitions][] apply universally to
-all programming language elements, resulting in a single, unified theme. Themes
-also set view-related editor properties like caret and selection colors.
+Each theme is a single Lua file. It contains [color][] and [style][] definitions
+for displaying syntactic elements like comments, strings, and keywords in
+programming language source files. These definitions apply universally to all
+programming language elements, resulting in a single, unified theme. Themes also
+set view-related editor properties like caret and selection colors.
Note: The only colors that the terminal version of Textadept recognizes are the
standard black, red, green, yellow, blue, magenta, cyan, white, and bold
variants of those colors. Your terminal emulator's settings determine how to
display these standard colors (which may be completely different in the end).
-[definitions]: api.html#lexer.Styles.and.Styling
+[color]: api.html#lexer.colors
+[style]: api.html#lexer.styles
## Setting Themes
Override the default theme in your [*~/.textadept/init.lua*](#User.Init) using
-the [`buffer.set_theme()`][] function. For example:
+the [`view.set_theme()`][] function. For example:
- buffer:set_theme(not CURSES and 'dark' or 'term')
+ view:set_theme(not CURSES and 'dark' or 'term')
Either restart Textadept for changes to take effect or type [`reset`][] in the
[command entry](#Lua.Command.Entry).
-`buffer.set_theme()` can also tweak theme properties like font face and font
-size without editing the theme file itself:
+`view.set_theme()` can also tweak theme options like font face and font size
+without editing the theme file itself:
- buffer:set_theme('light', {font = 'Monospace', fontsize = 12})
+ view:set_theme('light', {font = 'Monospace', size = 12})
You can even tweak themes on a per-language basis. For example, in order to
color Java functions black instead of the default orange, add the following to
@@ -1283,13 +1284,14 @@ color Java functions black instead of the default orange, add the following to
events.connect(events.LEXER_LOADED, function(lexer)
if lexer ~= 'java' then return end
- view.property['style.function'] = 'fore:$(color.light_black)'
+ local default_fore = view.style_fore[view.STYLE_DEFAULT]
+ view.style_fore[buffer:style_of_name('function')] = default_fore
end)
-For a full list of configurable properties, please consult the theme file you
-are using.
+For a full list of configurable properties and styles, please consult the theme
+file you are using.
-[`buffer.set_theme()`]: api.html#buffer.set_theme
+[`view.set_theme()`]: api.html#view.set_theme
[`reset`]: api.html#reset
## Creating Themes
@@ -2031,6 +2033,8 @@ N/A |Added |[to_eol()][]
delimited\_range() |Replaced|[range()][]
nested\_pair() |Replaced|[range()][]
N/A |Added |[number][]
+N/A |Added |[colors][]
+N/A |Added |[styles][]
**lfs** | |
dir\_foreach() |Replaced|for filename in [`lfs.walk()`][] do ... end
**textadept.bookmarks** | |
@@ -2066,6 +2070,8 @@ section below.
[to_eol()]: api.html#lexer.to_eol
[range()]: api.html#lexer.range
[number]: api.html#lexer.number
+[colors]: api.html#lexer.colors
+[styles]: api.html#lexer.styles
[`lfs.walk()`]: api.html#lfs.walk
[toggle()]: api.html#textadept.bookmarks.toggle
[insert()]: api.html#textadept.snippets.insert
@@ -2146,6 +2152,43 @@ confirmed.
[Scintilla]: http://scintilla.org
[view]: api.html#view
+#### Theme and Lexer Changes
+
+Themes and lexers have a new, optional API for defining and using colors and
+styles. Previously, all definitions and access to colors and styles was
+accomplished through `buffer.property` and `buffer.property_int`. Now it can be
+done via the `lexer.colors` and `lexer.styles` variables. For example:
+
+ -- Textadept 10
+ local property, property_int = buffer.property, buffer.property_int
+ property['color.blue'] = 0xFF0000
+ property['style.keyword'] = 'fore:$(color.blue),bold'
+ buffer.edge_colour = property_int['color.grey']
+
+ -- Textadept 11
+ local colors, styles = lexer.colors, lexer.styles
+ colors.blue = 0xFF0000
+ styles.keyword = {fore = colors.blue, bold = true}
+ view.edge_color = colors.grey
+
+Any additional settings passed `view:set_theme()` are available as global
+variables in the theme. Textadept's themes make use of `font` and `size` (the
+latter of which used to be `fontsize`) for easily configuring font and size
+per-user.
+
+Lexers can also utilize these new features. For example:
+
+ -- Textadept 10
+ lex:add_rule('custom_rule', token('custom', P('word')))
+ lex:add_style('custom', lexer.STYLE_KEYWORD .. 'italic')
+
+ -- Textadept 11
+ lex:add_rule('custom_rule', token('custom', P('word')))
+ lex:add_style('custom', lexer.styles.keyword .. {italic = true})
+
+Note that these features are optional. Themes and lexers setting property
+strings is still supported.
+
#### Localization Changes
GUI mnemonics in localization keys have been removed. For example, `_L['_New']`
diff --git a/init.lua b/init.lua
index 47a9d24d..9a56f2a5 100644
--- a/init.lua
+++ b/init.lua
@@ -18,22 +18,41 @@ end
textadept = require('textadept')
+local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
+
-- Documentation is in core/.view.luadoc.
-local function set_theme(view, name, props)
+local function set_theme(view, name, options)
if not assert_type(name, 'string', 2):find('[/\\]') then
name = package.searchpath(name, string.format(
'%s/themes/?.lua;%s/themes/?.lua', _USERHOME, _HOME))
end
if not name or not lfs.attributes(name) then return end
- if not assert_type(props, 'table/nil', 3) then props = {} end
+ if not assert_type(options, 'table/nil', 3) then options = {} end
local orig_view = _G.view
if view ~= orig_view then ui.goto_view(view) end
- dofile(name)
- for prop, value in pairs(props) do view.property[prop] = value end
+ -- Mimic `lexer.colors` and `lexer.styles` because (1) the lexer module is not
+ -- yet available and (2) even if it was, color and style settings would not
+ -- be captured later during init.
+ local property = view.property
+ local colors = setmetatable({}, {__newindex = function(t, name, color)
+ property['color.' .. name] = color -- TODO: auto-convert '#RRGGBB'?
+ rawset(t, name, color) -- cache instead of __index for property[...]
+ end})
+ local styles = setmetatable({}, {__newindex = function(_, name, props)
+ local settings = {}
+ for k, v in pairs(props) do
+ settings[#settings + 1] = type(v) ~= 'boolean' and
+ string.format('%s:%s', k, v) or
+ string.format('%s%s', v and '' or 'not', k)
+ end
+ property['style.' .. name] = table.concat(settings, ',')
+ end})
+ local env = {lexer = {colors = colors, styles = styles}}
+ for k, v in pairs(options) do env[k] = v end
+ loadfile(name, 't', setmetatable(env, {__index = _G}))()
-- Force reload of all styles since the current lexer may have defined its own
-- styles. (The LPeg lexer has only refreshed default lexer styles.)
-- Note: cannot use `buffer.set_lexer()` because it may not exist yet.
- local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
buffer:private_lexer_call(SETLEXERLANGUAGE, buffer._lexer or 'text')
if view ~= orig_view then ui.goto_view(orig_view) end
end
@@ -300,8 +319,6 @@ for _, mt in ipairs{buffer_mt, view_mt} do
mt.__index, mt.__newindex = mt.__orig_index, mt.__orig_newindex
end
-local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
-
-- Sets default properties for a Scintilla document.
events.connect(events.BUFFER_NEW, function()
local buffer = _G.buffer
@@ -340,13 +357,12 @@ events.connect(events.VIEW_NEW, function()
-- subsequent views.
if #_VIEWS == 1 then return end
load_settings()
- -- Refresh styles since the user may have altered style settings.
- -- When load_settings() calls `view.property['style.default'] = ...`, the
- -- LPeg lexer resets all styles to that default. However, load_settings() may
- -- later call a user's `view.property['fontsize'] = ...`, which
- -- 'style.default' references. Styles are now stale and need refreshing. This
- -- is not an issue in BUFFER_NEW since a lexer is set immediately afterwards,
- -- which refreshes styles.
+ -- Refresh styles in case a lexer has extra style settings. When
+ -- load_settings() calls `view.property['style.default'] = ...`, the LPeg
+ -- lexer resets all styles to that default. However, some lexers have extra
+ -- style settings that are not set by load_settings(), and thus need
+ -- refreshing. This is not an issue in BUFFER_NEW since a lexer is set
+ -- immediately afterwards, which refreshes styles.
-- Note: `buffer:set_lexer()` is insufficient for some reason.
buffer:private_lexer_call(SETLEXERLANGUAGE, buffer._lexer or 'text')
end, 1)
diff --git a/src/Makefile b/src/Makefile
index 58fe53a5..232f097c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -376,7 +376,7 @@ else
gtdialog_url = http://foicica.com/hg/gtdialog/archive/tip.zip
endif
-scintilla_zip = 1757848f5635.zip
+scintilla_zip = d51c7ec9ec78.zip
lua_tgz = lua-5.3.5.tar.gz
lpeg_tgz = lpeg-1.0.2.tar.gz
lfs_zip = v1_7_0_2.zip
diff --git a/src/textadept.c b/src/textadept.c
index 2afb1b59..9f4414a6 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -828,6 +828,21 @@ static int menu(lua_State *L) {
#endif
}
+/** `ui.update()` Lua function. */
+static int update_ui(lua_State *L) {
+#if GTK
+ while (gtk_events_pending()) gtk_main_iteration();
+#elif CURSES
+ struct timeval timeout = {0, 1e5}; // 0.1s
+ int nfds = os_spawn_pushfds(L);
+ fd_set *fds = (fd_set *)lua_touserdata(L, -1);
+ while (select(nfds, fds, NULL, NULL, &timeout) > 0)
+ if (os_spawn_readfds(L) >= 0) refresh_all();
+ lua_pop(L, 1); // fd_set
+#endif
+ return 0;
+}
+
/** `ui.__index` Lua metamethod. */
static int ui_index(lua_State *L) {
const char *key = lua_tostring(L, 2);
@@ -1590,6 +1605,7 @@ static int init_lua(lua_State *L, int argc, char **argv, int reinit) {
lua_pushcfunction(L, get_split_table), lua_setfield(L, -2, "get_split_table");
lua_pushcfunction(L, goto_view), lua_setfield(L, -2, "goto_view");
lua_pushcfunction(L, menu), lua_setfield(L, -2, "menu");
+ lua_pushcfunction(L, update_ui), lua_setfield(L, -2, "update");
set_metatable(L, -1, "ta_ui", ui_index, ui_newindex);
lua_setglobal(L, "ui");
diff --git a/test/test.lua b/test/test.lua
index 33e8fd67..c7a67a84 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -560,8 +560,8 @@ function test_keys_keychain()
events.emit(events.KEYPRESS, string.byte('a'))
assert(not foo, 'foo set outside keychain')
events.emit(events.KEYPRESS, string.byte('a'), false, true)
- assert_equal(#keys.keychain, 1)
- assert_equal(keys.keychain[1], 'ctrl+a')
+ --assert_equal(#keys.keychain, 1)
+ --assert_equal(keys.keychain[1], 'ctrl+a')
events.emit(events.KEYPRESS, not CURSES and 0xFF1B or 7) -- esc
assert_equal(#keys.keychain, 0, 'keychain not canceled')
events.emit(events.KEYPRESS, string.byte('a'))
@@ -3006,7 +3006,7 @@ function test_set_lexer_style()
local default_fore = view.style_fore[view.STYLE_DEFAULT]
assert(view.style_fore[style] ~= default_fore, 'function name style_fore same as default style_fore')
view.style_fore[style] = view.style_fore[view.STYLE_DEFAULT]
- assert_equal(buffer.style_fore[style], default_fore)
+ assert_equal(view.style_fore[style], default_fore)
buffer:close(true)
-- Defined in Lua lexer, which is not currently loaded.
assert(buffer:style_of_name('library'), view.STYLE_DEFAULT)
diff --git a/themes/dark.lua b/themes/dark.lua
index 26c15d2b..89f8b99d 100644
--- a/themes/dark.lua
+++ b/themes/dark.lua
@@ -2,90 +2,89 @@
-- Dark theme for Textadept.
-- Contributions by Ana Balan.
-local view = view
-local property, property_int = view.property, view.property_int
+local view, colors, styles = view, lexer.colors, lexer.styles
-- Greyscale colors.
-property['color.dark_black'] = 0x000000
-property['color.black'] = 0x1A1A1A
-property['color.light_black'] = 0x333333
-property['color.grey_black'] = 0x4D4D4D
-property['color.dark_grey'] = 0x666666
-property['color.grey'] = 0x808080
-property['color.light_grey'] = 0x999999
-property['color.grey_white'] = 0xB3B3B3
-property['color.dark_white'] = 0xCCCCCC
-property['color.white'] = 0xE6E6E6
-property['color.light_white'] = 0xFFFFFF
+colors.dark_black = 0x000000
+colors.black = 0x1A1A1A
+colors.light_black = 0x333333
+colors.grey_black = 0x4D4D4D
+colors.dark_grey = 0x666666
+colors.grey = 0x808080
+colors.light_grey = 0x999999
+colors.grey_white = 0xB3B3B3
+colors.dark_white = 0xCCCCCC
+colors.white = 0xE6E6E6
+colors.light_white = 0xFFFFFF
-- Dark colors.
-property['color.dark_red'] = 0x1A1A66
-property['color.dark_yellow'] = 0x1A6666
-property['color.dark_green'] = 0x1A661A
-property['color.dark_teal'] = 0x66661A
-property['color.dark_purple'] = 0x661A66
-property['color.dark_orange'] = 0x1A66B3
-property['color.dark_pink'] = 0x6666B3
-property['color.dark_lavender'] = 0xB36666
-property['color.dark_blue'] = 0xB3661A
+colors.dark_red = 0x1A1A66
+colors.dark_yellow = 0x1A6666
+colors.dark_green = 0x1A661A
+colors.dark_teal = 0x66661A
+colors.dark_purple = 0x661A66
+colors.dark_orange = 0x1A66B3
+colors.dark_pink = 0x6666B3
+colors.dark_lavender = 0xB36666
+colors.dark_blue = 0xB3661A
-- Normal colors.
-property['color.red'] = 0x4D4D99
-property['color.yellow'] = 0x4D9999
-property['color.green'] = 0x4D994D
-property['color.teal'] = 0x99994D
-property['color.purple'] = 0x994D99
-property['color.orange'] = 0x4D99E6
-property['color.pink'] = 0x9999E6
-property['color.lavender'] = 0xE69999
-property['color.blue'] = 0xE6994D
+colors.red = 0x4D4D99
+colors.yellow = 0x4D9999
+colors.green = 0x4D994D
+colors.teal = 0x99994D
+colors.purple = 0x994D99
+colors.orange = 0x4D99E6
+colors.pink = 0x9999E6
+colors.lavender = 0xE69999
+colors.blue = 0xE6994D
-- Light colors.
-property['color.light_red'] = 0x8080CC
-property['color.light_yellow'] = 0x80CCCC
-property['color.light_green'] = 0x80CC80
-property['color.light_teal'] = 0xCCCC80
-property['color.light_purple'] = 0xCC80CC
-property['color.light_orange'] = 0x80CCFF
-property['color.light_pink'] = 0xCCCCFF
-property['color.light_lavender'] = 0xFFCCCC
-property['color.light_blue'] = 0xFFCC80
+colors.light_red = 0x8080CC
+colors.light_yellow = 0x80CCCC
+colors.light_green = 0x80CC80
+colors.light_teal = 0xCCCC80
+colors.light_purple = 0xCC80CC
+colors.light_orange = 0x80CCFF
+colors.light_pink = 0xCCCCFF
+colors.light_lavender = 0xFFCCCC
+colors.light_blue = 0xFFCC80
-- Default font.
-property['font'], property['fontsize'] = 'Bitstream Vera Sans Mono', 10
-if WIN32 then
- property['font'] = 'Courier New'
-elseif OSX then
- property['font'], property['fontsize'] = 'Monaco', 12
+if not font then
+ font = WIN32 and 'Courier New' or OSX and 'Monaco' or
+ 'Bitstream Vera Sans Mono'
end
+if not size then size = not OSX and 10 or 12 end
-- Predefined styles.
-property['style.default'] = 'font:$(font),size:$(fontsize),'..
- 'fore:$(color.light_grey),back:$(color.black)'
-property['style.linenumber'] = 'fore:$(color.dark_grey),back:$(color.black)'
---property['style.controlchar'] =
-property['style.indentguide'] = 'fore:$(color.light_black)'
-property['style.calltip'] = 'fore:$(color.light_grey),back:$(color.light_black)'
-property['style.folddisplaytext'] = 'fore:$(color.dark_grey)'
+styles.default = {
+ font = font, size = size, fore = colors.light_grey, back = colors.black
+}
+styles.line_number = {fore = colors.dark_grey, back = colors.black}
+--styles.control_char =
+styles.indent_guide = {fore = colors.light_black}
+styles.call_tip = {fore = colors.light_grey, back = colors.light_black}
+styles.fold_display_text = {fore = colors.dark_grey}
-- Token styles.
-property['style.class'] = 'fore:$(color.light_yellow)'
-property['style.comment'] = 'fore:$(color.dark_grey)'
-property['style.constant'] = 'fore:$(color.red)'
-property['style.embedded'] = '$(style.keyword),back:$(color.light_black)'
-property['style.error'] = 'fore:$(color.red),italics'
-property['style.function'] = 'fore:$(color.blue)'
-property['style.identifier'] = ''
-property['style.keyword'] = 'fore:$(color.dark_white)'
-property['style.label'] = 'fore:$(color.orange)'
-property['style.number'] = 'fore:$(color.teal)'
-property['style.operator'] = 'fore:$(color.yellow)'
-property['style.preprocessor'] = 'fore:$(color.purple)'
-property['style.regex'] = 'fore:$(color.light_green)'
-property['style.string'] = 'fore:$(color.green)'
-property['style.type'] = 'fore:$(color.lavender)'
-property['style.variable'] = 'fore:$(color.light_blue)'
-property['style.whitespace'] = ''
+styles.class = {fore = colors.light_yellow}
+styles.comment = {fore = colors.dark_grey}
+styles.constant = {fore = colors.red}
+styles.embedded = {fore = colors.dark_white, back = colors.light_black}
+styles.error = {fore = colors.red, italics = true}
+styles['function'] = {fore = colors.blue}
+styles.identifier = {}
+styles.keyword = {fore = colors.dark_white}
+styles.label = {fore = colors.orange}
+styles.number = {fore = colors.teal}
+styles.operator = {fore = colors.yellow}
+styles.preprocessor = {fore = colors.purple}
+styles.regex = {fore = colors.light_green}
+styles.string = {fore = colors.green}
+styles.type = {fore = colors.lavender}
+styles.variable = {fore = colors.light_blue}
+styles.whitespace = {}
-- Multiple Selection and Virtual Space
--view.additional_sel_alpha =
@@ -94,44 +93,40 @@ property['style.whitespace'] = ''
--view.additional_caret_fore =
-- Caret and Selection Styles.
-view:set_sel_fore(true, property_int['color.light_black'])
-view:set_sel_back(true, property_int['color.grey'])
+view:set_sel_fore(true, colors.light_black)
+view:set_sel_back(true, colors.grey)
--view.sel_alpha =
-view.caret_fore = property_int['color.grey']
-view.caret_line_back = property_int['color.light_black']
+view.caret_fore = colors.grey
+view.caret_line_back = colors.light_black
--view.caret_line_back_alpha =
-- Fold Margin.
-view:set_fold_margin_color(true, property_int['color.black'])
-view:set_fold_margin_hi_color(true, property_int['color.black'])
+view:set_fold_margin_color(true, colors.black)
+view:set_fold_margin_hi_color(true, colors.black)
-- Markers.
-local MARK_BOOKMARK = textadept.bookmarks.MARK_BOOKMARK
---view.marker_fore[MARK_BOOKMARK] = property_int['color.black']
-view.marker_back[MARK_BOOKMARK] = property_int['color.dark_blue']
---view.marker_fore[textadept.run.MARK_WARNING] = property_int['color.black']
-view.marker_back[textadept.run.MARK_WARNING] = property_int['color.yellow']
---view.marker_fore[textadept.run.MARK_ERROR] = property_int['color.black']
-view.marker_back[textadept.run.MARK_ERROR] = property_int['color.red']
+--view.marker_fore[textadept.bookmarks.MARK_BOOKMARK] = colors.black
+view.marker_back[textadept.bookmarks.MARK_BOOKMARK] = colors.dark_blue
+--view.marker_fore[textadept.run.MARK_WARNING] = colors.black
+view.marker_back[textadept.run.MARK_WARNING] = colors.yellow
+--view.marker_fore[textadept.run.MARK_ERROR] = colors.black
+view.marker_back[textadept.run.MARK_ERROR] = colors.red
for i = buffer.MARKNUM_FOLDEREND, buffer.MARKNUM_FOLDEROPEN do -- fold margin
- view.marker_fore[i] = property_int['color.black']
- view.marker_back[i] = property_int['color.dark_grey']
- view.marker_back_selected[i] = property_int['color.light_grey']
+ view.marker_fore[i] = colors.black
+ view.marker_back[i] = colors.dark_grey
+ view.marker_back_selected[i] = colors.light_grey
end
-- Indicators.
-view.indic_fore[ui.find.INDIC_FIND] = property_int['color.dark_yellow']
+view.indic_fore[ui.find.INDIC_FIND] = colors.dark_yellow
view.indic_alpha[ui.find.INDIC_FIND] = 255
-local INDIC_BRACEMATCH = textadept.editing.INDIC_BRACEMATCH
-view.indic_fore[INDIC_BRACEMATCH] = property_int['color.light_grey']
-local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT
-view.indic_fore[INDIC_HIGHLIGHT] = property_int['color.orange']
-view.indic_alpha[INDIC_HIGHLIGHT] = 255
-local INDIC_PLACEHOLDER = textadept.snippets.INDIC_PLACEHOLDER
-view.indic_fore[INDIC_PLACEHOLDER] = property_int['color.grey']
+view.indic_fore[textadept.editing.INDIC_BRACEMATCH] = colors.light_grey
+view.indic_fore[textadept.editing.INDIC_HIGHLIGHT] = colors.orange
+view.indic_alpha[textadept.editing.INDIC_HIGHLIGHT] = 255
+view.indic_fore[textadept.snippets.INDIC_PLACEHOLDER] = colors.grey
-- Call tips.
-view.call_tip_fore_hlt = property_int['color.light_blue']
+view.call_tip_fore_hlt = colors.light_blue
-- Long Lines.
-view.edge_color = property_int['color.dark_grey']
+view.edge_color = colors.dark_grey
diff --git a/themes/light.lua b/themes/light.lua
index b0ae292b..cdaca6f6 100644
--- a/themes/light.lua
+++ b/themes/light.lua
@@ -2,90 +2,89 @@
-- Light theme for Textadept.
-- Contributions by Ana Balan.
-local view = view
-local property, property_int = view.property, view.property_int
+local view, colors, styles = view, lexer.colors, lexer.styles
-- Greyscale colors.
-property['color.dark_black'] = 0x000000
-property['color.black'] = 0x1A1A1A
-property['color.light_black'] = 0x333333
-property['color.grey_black'] = 0x4D4D4D
-property['color.dark_grey'] = 0x666666
-property['color.grey'] = 0x808080
-property['color.light_grey'] = 0x999999
-property['color.grey_white'] = 0xB3B3B3
-property['color.dark_white'] = 0xCCCCCC
-property['color.white'] = 0xE6E6E6
-property['color.light_white'] = 0xFFFFFF
+colors.dark_black = 0x000000
+colors.black = 0x1A1A1A
+colors.light_black = 0x333333
+colors.grey_black = 0x4D4D4D
+colors.dark_grey = 0x666666
+colors.grey = 0x808080
+colors.light_grey = 0x999999
+colors.grey_white = 0xB3B3B3
+colors.dark_white = 0xCCCCCC
+colors.white = 0xE6E6E6
+colors.light_white = 0xFFFFFF
-- Dark colors.
-property['color.dark_red'] = 0x1A1A66
-property['color.dark_yellow'] = 0x1A6666
-property['color.dark_green'] = 0x1A661A
-property['color.dark_teal'] = 0x66661A
-property['color.dark_purple'] = 0x661A66
-property['color.dark_orange'] = 0x1A66B3
-property['color.dark_pink'] = 0x6666B3
-property['color.dark_lavender'] = 0xB36666
-property['color.dark_blue'] = 0xB3661A
+colors.dark_red = 0x1A1A66
+colors.dark_yellow = 0x1A6666
+colors.dark_green = 0x1A661A
+colors.dark_teal = 0x66661A
+colors.dark_purple = 0x661A66
+colors.dark_orange = 0x1A66B3
+colors.dark_pink = 0x6666B3
+colors.dark_lavender = 0xB36666
+colors.dark_blue = 0xB3661A
-- Normal colors.
-property['color.red'] = 0x4D4D99
-property['color.yellow'] = 0x4D9999
-property['color.green'] = 0x4D994D
-property['color.teal'] = 0x99994D
-property['color.purple'] = 0x994D99
-property['color.orange'] = 0x4D99E6
-property['color.pink'] = 0x9999E6
-property['color.lavender'] = 0xE69999
-property['color.blue'] = 0xE6994D
+colors.red = 0x4D4D99
+colors.yellow = 0x4D9999
+colors.green = 0x4D994D
+colors.teal = 0x99994D
+colors.purple = 0x994D99
+colors.orange = 0x4D99E6
+colors.pink = 0x9999E6
+colors.lavender = 0xE69999
+colors.blue = 0xE6994D
-- Light colors.
-property['color.light_red'] = 0x8080CC
-property['color.light_yellow'] = 0x80CCCC
-property['color.light_green'] = 0x80CC80
-property['color.light_teal'] = 0xCCCC80
-property['color.light_purple'] = 0xCC80CC
-property['color.light_orange'] = 0x80CCFF
-property['color.light_pink'] = 0xCCCCFF
-property['color.light_lavender'] = 0xFFCCCC
-property['color.light_blue'] = 0xFFCC80
+colors.light_red = 0x8080CC
+colors.light_yellow = 0x80CCCC
+colors.light_green = 0x80CC80
+colors.light_teal = 0xCCCC80
+colors.light_purple = 0xCC80CC
+colors.light_orange = 0x80CCFF
+colors.light_pink = 0xCCCCFF
+colors.light_lavender = 0xFFCCCC
+colors.light_blue = 0xFFCC80
-- Default font.
-property['font'], property['fontsize'] = 'Bitstream Vera Sans Mono', 10
-if WIN32 then
- property['font'] = 'Courier New'
-elseif OSX then
- property['font'], property['fontsize'] = 'Monaco', 12
+if not font then
+ font = WIN32 and 'Courier New' or OSX and 'Monaco' or
+ 'Bitstream Vera Sans Mono'
end
+if not size then size = not OSX and 10 or 12 end
-- Predefined styles.
-property['style.default'] = 'font:$(font),size:$(fontsize),'..
- 'fore:$(color.light_black),back:$(color.white)'
-property['style.linenumber'] = 'fore:$(color.grey),back:$(color.white)'
---property['style.controlchar'] = ''
-property['style.indentguide'] = 'fore:$(color.dark_white)'
-property['style.calltip'] = 'fore:$(color.light_black),back:$(color.dark_white)'
-property['style.folddisplaytext'] = 'fore:$(color.grey)'
+styles.default = {
+ font = font, size = size, fore = colors.light_black, back = colors.white
+}
+styles.line_number = {fore = colors.grey, back = colors.white}
+--styles.control_char = {}
+styles.indent_guide = {fore = colors.dark_white}
+styles.call_tip = {fore = colors.light_black, back = colors.dark_white}
+styles.fold_display_text = {fore = colors.grey}
-- Token styles.
-property['style.class'] = 'fore:$(color.yellow)'
-property['style.comment'] = 'fore:$(color.grey)'
-property['style.constant'] = 'fore:$(color.red)'
-property['style.embedded'] = '$(style.keyword),back:$(color.dark_white)'
-property['style.error'] = 'fore:$(color.red),italics'
-property['style.function'] = 'fore:$(color.dark_orange)'
-property['style.identifier'] = ''
-property['style.keyword'] = 'fore:$(color.dark_blue)'
-property['style.label'] = 'fore:$(color.dark_orange)'
-property['style.number'] = 'fore:$(color.teal)'
-property['style.operator'] = 'fore:$(color.purple)'
-property['style.preprocessor'] = 'fore:$(color.dark_yellow)'
-property['style.regex'] = 'fore:$(color.dark_green)'
-property['style.string'] = 'fore:$(color.green)'
-property['style.type'] = 'fore:$(color.lavender)'
-property['style.variable'] = 'fore:$(color.dark_lavender)'
-property['style.whitespace'] = ''
+styles.class = {fore = colors.yellow}
+styles.comment = {fore = colors.grey}
+styles.constant = {fore = colors.red}
+styles.embedded = {fore = colors.dark_blue, back = colors.dark_white}
+styles.error = {fore = colors.red, italics}
+styles['function'] = {fore = colors.dark_orange}
+styles.identifier = {}
+styles.keyword = {fore = colors.dark_blue}
+styles.label = {fore = colors.dark_orange}
+styles.number = {fore = colors.teal}
+styles.operator = {fore = colors.purple}
+styles.preprocessor = {fore = colors.dark_yellow}
+styles.regex = {fore = colors.dark_green}
+styles.string = {fore = colors.green}
+styles.type = {fore = colors.lavender}
+styles.variable = {fore = colors.dark_lavender}
+styles.whitespace = {}
-- Multiple Selection and Virtual Space
--view.additional_sel_alpha =
@@ -94,44 +93,41 @@ property['style.whitespace'] = ''
--view.additional_caret_fore =
-- Caret and Selection Styles.
-view:set_sel_fore(true, property_int['color.light_black'])
-view:set_sel_back(true, property_int['color.light_grey'])
+view:set_sel_fore(true, colors.light_black)
+view:set_sel_back(true, colors.light_grey)
--view.sel_alpha =
-view.caret_fore = property_int['color.grey_black']
-view.caret_line_back = property_int['color.dark_white']
+view.caret_fore = colors.grey_black
+view.caret_line_back = colors.dark_white
--view.caret_line_back_alpha =
-- Fold Margin.
-view:set_fold_margin_color(true, property_int['color.white'])
-view:set_fold_margin_hi_color(true, property_int['color.white'])
+view:set_fold_margin_color(true, colors.white)
+view:set_fold_margin_hi_color(true, colors.white)
-- Markers.
-local MARK_BOOKMARK, t_run = textadept.bookmarks.MARK_BOOKMARK, textadept.run
---view.marker_fore[MARK_BOOKMARK] = property_int['color.white']
-view.marker_back[MARK_BOOKMARK] = property_int['color.dark_blue']
---view.marker_fore[t_run.MARK_WARNING] = property_int['color.white']
-view.marker_back[t_run.MARK_WARNING] = property_int['color.light_yellow']
---view.marker_fore[t_run.MARK_ERROR] = property_int['color.white']
-view.marker_back[t_run.MARK_ERROR] = property_int['color.light_red']
+--view.marker_fore[textadept.bookmarks.MARK_BOOKMARK] = colors.white
+view.marker_back[textadept.bookmarks.MARK_BOOKMARK] = colors.dark_blue
+--view.marker_fore[textadept.run.MARK_WARNING] = colors.white
+view.marker_back[textadept.run.MARK_WARNING] = colors.light_yellow
+--view.marker_fore[textadept.run.MARK_ERROR] = colors.white
+view.marker_back[textadept.run.MARK_ERROR] = colors.light_red
for i = buffer.MARKNUM_FOLDEREND, buffer.MARKNUM_FOLDEROPEN do -- fold margin
- view.marker_fore[i] = property_int['color.white']
- view.marker_back[i] = property_int['color.grey']
- view.marker_back_selected[i] = property_int['color.grey_black']
+ view.marker_fore[i] = colors.white
+ view.marker_back[i] = colors.grey
+ view.marker_back_selected[i] = colors.grey_black
end
-- Indicators.
-view.indic_fore[ui.find.INDIC_FIND] = property_int['color.yellow']
+view.indic_fore[ui.find.INDIC_FIND] = colors.yellow
view.indic_alpha[ui.find.INDIC_FIND] = 255
-local INDIC_BRACEMATCH = textadept.editing.INDIC_BRACEMATCH
-view.indic_fore[INDIC_BRACEMATCH] = property_int['color.grey']
-local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT
-view.indic_fore[INDIC_HIGHLIGHT] = property_int['color.orange']
-view.indic_alpha[INDIC_HIGHLIGHT] = 255
+view.indic_fore[textadept.editing.INDIC_BRACEMATCH] = colors.grey
+view.indic_fore[textadept.editing.INDIC_HIGHLIGHT] = colors.orange
+view.indic_alpha[textadept.editing.INDIC_HIGHLIGHT] = 255
local INDIC_PLACEHOLDER = textadept.snippets.INDIC_PLACEHOLDER
-view.indic_fore[INDIC_PLACEHOLDER] = property_int['color.grey_black']
+view.indic_fore[INDIC_PLACEHOLDER] = colors.grey_black
-- Call tips.
-view.call_tip_fore_hlt = property_int['color.light_blue']
+view.call_tip_fore_hlt = colors.light_blue
-- Long Lines.
-view.edge_color = property_int['color.grey']
+view.edge_color = colors.grey
diff --git a/themes/term.lua b/themes/term.lua
index 53783e69..ec2fd53a 100644
--- a/themes/term.lua
+++ b/themes/term.lua
@@ -2,58 +2,57 @@
-- Terminal theme for Textadept.
-- Contributions by Ana Balan.
-local view = view
-local property, property_int = view.property, view.property_int
+local view, colors, styles = view, lexer.colors, lexer.styles
-- Normal colors.
-property['color.black'] = 0x000000
-property['color.red'] = 0x000080
-property['color.green'] = 0x008000
-property['color.yellow'] = 0x008080
-property['color.blue'] = 0x800000
-property['color.magenta'] = 0x800080
-property['color.cyan'] = 0x808000
-property['color.white'] = 0xC0C0C0
+colors.black = 0x000000
+colors.red = 0x000080
+colors.green = 0x008000
+colors.yellow = 0x008080
+colors.blue = 0x800000
+colors.magenta = 0x800080
+colors.cyan = 0x808000
+colors.white = 0xC0C0C0
-- Light colors. (16 color terminals only.)
-- These only apply to 16 color terminals. For other terminals, set the
-- style's `bold` attribute to use the light color variant.
-property['color.light_black'] = 0x404040
-property['color.light_red'] = 0x0000FF
-property['color.light_green'] = 0x00FF00
-property['color.light_yellow'] = 0x00FFFF
-property['color.light_blue'] = 0xFF0000
-property['color.light_magenta'] = 0xFF00FF
-property['color.light_cyan'] = 0xFFFF00
-property['color.light_white'] = 0xFFFFFF
+colors.light_black = 0x404040
+colors.light_red = 0x0000FF
+colors.light_green = 0x00FF00
+colors.light_yellow = 0x00FFFF
+colors.light_blue = 0xFF0000
+colors.light_magenta = 0xFF00FF
+colors.light_cyan = 0xFFFF00
+colors.light_white = 0xFFFFFF
-- Predefined styles.
-property['style.default'] = 'fore:$(color.white),back:$(color.black)'
-property['style.linenumber'] = 'fore:$(color.black),bold'
-property['style.bracelight'] = 'fore:$(color.black),back:$(color.white)'
---property['style.controlchar'] =
---property['style.indentguide'] =
-property['style.calltip'] = '$(style.default)'
-property['style.folddisplaytext'] = 'fore:$(color.black),bold'
+styles.default = {fore = colors.white, back = colors.black}
+styles.line_number = {fore = colors.black, bold = true}
+styles.brace_light = {fore = colors.black, back = colors.white}
+--styles.control_char =
+--styles.indent_guide =
+--styles.call_tip =
+styles.fold_display_text = {fore = colors.black, bold = true}
-- Token styles.
-property['style.class'] = 'fore:$(color.yellow)'
-property['style.comment'] = 'fore:$(color.black),bold'
-property['style.constant'] = 'fore:$(color.red)'
-property['style.embedded'] = '$(style.keyword),back:$(color.black)'
-property['style.error'] = 'fore:$(color.red),bold'
-property['style.function'] = 'fore:$(color.blue)'
-property['style.identifier'] = ''
-property['style.keyword'] = 'fore:$(color.white),bold'
-property['style.label'] = 'fore:$(color.red),bold'
-property['style.number'] = 'fore:$(color.cyan)'
-property['style.operator'] = 'fore:$(color.yellow)'
-property['style.preprocessor'] = 'fore:$(color.magenta)'
-property['style.regex'] = 'fore:$(color.green),bold'
-property['style.string'] = 'fore:$(color.green)'
-property['style.type'] = 'fore:$(color.magenta),bold'
-property['style.variable'] = 'fore:$(color.blue),bold'
-property['style.whitespace'] = ''
+styles.class = {fore = colors.yellow}
+styles.comment = {fore = colors.black, bold = true}
+styles.constant = {fore = colors.red}
+styles.embedded = {fore = colors.white, bold = true, back = colors.black}
+styles.error = {fore = colors.red, bold = true}
+styles['function'] = {fore = colors.blue}
+styles.identifier = {}
+styles.keyword = {fore = colors.white, bold = true}
+styles.label = {fore = colors.red, bold = true}
+styles.number = {fore = colors.cyan}
+styles.operator = {fore = colors.yellow}
+styles.preprocessor = {fore = colors.magenta}
+styles.regex = {fore = colors.green, bold = true}
+styles.string = {fore = colors.green}
+styles.type = {fore = colors.magenta, bold = true}
+styles.variable = {fore = colors.blue, bold = true}
+styles.whitespace = {}
-- Multiple Selection and Virtual Space
--view.additional_sel_fore =
@@ -61,30 +60,27 @@ property['style.whitespace'] = ''
--view.additional_caret_fore =
-- Caret and Selection Styles.
---view:set_sel_fore(true, property_int['color.white'])
---view:set_sel_back(true, property_int['color.black'])
---view.caret_fore = property_int['color.black']
+--view:set_sel_fore(true, colors.white)
+--view:set_sel_back(true, colors.black)
+--view.caret_fore = colors.black
--view.caret_line_back =
-- Fold Margin.
---view:set_fold_margin_color(true, property_int['color.white'])
---view:set_fold_margin_hi_color(true, property_int['color.white'])
+--view:set_fold_margin_color(true, colors.white)
+--view:set_fold_margin_hi_color(true, colors.white)
-- Markers.
-local MARK_BOOKMARK = textadept.bookmarks.MARK_BOOKMARK
-view.marker_back[MARK_BOOKMARK] = property_int['color.blue']
-view.marker_back[textadept.run.MARK_WARNING] = property_int['color.yellow']
-view.marker_back[textadept.run.MARK_ERROR] = property_int['color.red']
+view.marker_back[textadept.bookmarks.MARK_BOOKMARK] = colors.blue
+view.marker_back[textadept.run.MARK_WARNING] = colors.yellow
+view.marker_back[textadept.run.MARK_ERROR] = colors.red
-- Indicators.
-view.indic_fore[ui.find.INDIC_FIND] = property_int['color.yellow']
-local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT
-view.indic_fore[INDIC_HIGHLIGHT] = property_int['color.yellow']
-local INDIC_PLACEHOLDER = textadept.snippets.INDIC_PLACEHOLDER
-view.indic_fore[INDIC_PLACEHOLDER] = property_int['color.magenta']
+view.indic_fore[ui.find.INDIC_FIND] = colors.yellow
+view.indic_fore[textadept.editing.INDIC_HIGHLIGHT] = colors.yellow
+view.indic_fore[textadept.snippets.INDIC_PLACEHOLDER] = colors.magenta
-- Call tips.
-view.call_tip_fore_hlt = property_int['color.blue']
+view.call_tip_fore_hlt = colors.blue
-- Long Lines.
-view.edge_color = property_int['color.red']
+view.edge_color = colors.red