aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md21
-rw-r--r--core/.buffer.luadoc16
-rw-r--r--core/.view.luadoc16
-rw-r--r--doc/manual.md12
-rw-r--r--init.lua31
-rw-r--r--modules/lua/ta_api4
-rw-r--r--modules/lua/ta_tags4
-rw-r--r--test/test.lua33
8 files changed, 84 insertions, 53 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c9b29d7..d334783f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -582,7 +582,7 @@ Bugfixes:
* Fixed markdown lexer lists and C# lexer keywords.
* Fixed child lexers that embed themselves into parents and fixed proxy lexers.
* Fixed handling of custom fold functions in legacy lexers.
-* Fixed [`buffer:set_theme()`][] for lexers that have their own styles.
+* Fixed `buffer:set_theme()` for lexers that have their own styles.
* Scintilla: Fixed potential crash with newer versions of ncurses.
* Scintilla: Fixed some regex searching corner-cases.
@@ -606,7 +606,6 @@ Changes:
[PGP -- 10.0 Linux]: download/textadept_10.0.i386.tgz.asc
[PGP -- 10.0 Linux x86_64]: download/textadept_10.0.x86_64.tgz.asc
[PGP -- 10.0 Modules]: download/textadept_10.0.modules.zip.asc
-[`buffer:set_theme()`]: api.html#buffer.set_theme
[Scintilla]: http://scintilla.org
[Lua]: http://lua.org
@@ -704,7 +703,7 @@ Changes:
dependencies.
* Emacs-style `^K` for OSX and the terminal version joins lines at EOL.
* Pasted text reindents an extra level after a fold header.
-* [`buffer.set_theme()`][] now takes an initial buffer argument like all other
+* `buffer.set_theme()` now takes an initial buffer argument like all other
buffer functions and does not have any call restrictions.
* Scintilla: Added [`events.AUTO_C_SELECTION_CHANGE`][] event.
* Updated to [Scintilla][] 3.8.0.
@@ -719,7 +718,6 @@ Changes:
[PGP -- 10.0 alpha 3 Linux]: download/textadept_10.0_alpha_3.i386.tgz.asc
[PGP -- 10.0 alpha 3 Linux x86_64]: download/textadept_10.0_alpha_3.x86_64.tgz.asc
[PGP -- 10.0 alpha 3 Modules]: download/textadept_10.0_alpha_3.modules.zip.asc
-[`buffer.set_theme()`]: api.html#buffer.set_theme
[`events.AUTO_C_SELECTION_CHANGE`]: api.html#events.AUTO_C_SELECTION_CHANGE
[Scintilla]: http://scintilla.org
@@ -800,7 +798,7 @@ Changes:
"Select in ..." menu items.
* Removed the need for *~/.textadept/properties.lua*. All `buffer` settings set
in *~/.textadept/init.lua* will apply to the first and subsequent buffers.
-* Renamed `ui.set_theme()` to [`buffer.set_theme()`][].
+* Renamed `ui.set_theme()` to `buffer.set_theme()`.
* Enforce extra argument to [`buffer.brace_match()`][] added back in Scintilla
3.7.0.
* Added [`events.ZOOM`][].
@@ -817,7 +815,6 @@ Changes:
[PGP -- 10.0 alpha Linux x86_64]: download/textadept_10.0_alpha.x86_64.tgz.asc
[PGP -- 10.0 alpha Modules]: download/textadept_10.0_alpha.modules.zip.asc
[`textadept.editing.select_enclosed()`]: api.html#textadept.editing.select_enclosed
-[`buffer.set_theme()`]: api.html#buffer.set_theme
[`buffer.brace_match()`]: api.html#buffer.brace_match
[`events.ZOOM`]: api.html#events.ZOOM
[create lexers]: api.html#lexer
@@ -2637,7 +2634,7 @@ Bugfixes:
Changes:
-* Changed [`ui.set_theme()`][] API to accept a table of property assignments.
+* Changed `ui.set_theme()` API to accept a table of property assignments.
* Added Nimrod lexer and compile and run commands.
* Use [`textadept.editing.INDIC_BRACEMATCH`][] indicator for brace highlighting
instead of styles.
@@ -2660,7 +2657,6 @@ Changes:
[PGP -- 7.0 beta 5 Linux]: download/textadept_7.0_beta_5.i386.tgz.asc
[PGP -- 7.0 beta 5 Linux x86_64]: download/textadept_7.0_beta_5.x86_64.tgz.asc
[PGP -- 7.0 beta 5 Modules]: download/textadept_7.0_beta_5.modules.zip.asc
-[`ui.set_theme()`]: api.html#ui.set_theme
[`textadept.editing.INDIC_BRACEMATCH`]: api.html#textadept.editing.INDIC_BRACEMATCH
[`buffer`]: api.html#buffer
[`lexer.load()`]: api.html#lexer.load
@@ -2808,7 +2804,7 @@ Download:
Bugfixes:
* Fixed bug with theme loading when resetting.
-* Fixed bug with property settings in [`gui.set_theme()`][] not persisting.
+* Fixed bug with property settings in `gui.set_theme()` not persisting.
* Scintilla: fixed some instances of case conversions.
* Scintilla: fixed some instances of word wrapping and improved performance.
* Scintilla: fixed minor memory leak.
@@ -2830,7 +2826,6 @@ Changes:
[PGP -- 7.0 beta 2 Linux]: download/textadept_7.0_beta_2.i386.tgz.asc
[PGP -- 7.0 beta 2 Linux x86_64]: download/textadept_7.0_beta_2.x86_64.tgz.asc
[PGP -- 7.0 beta 2 Modules]: download/textadept_7.0_beta_2.modules.zip.asc
-[`gui.set_theme()`]: api.html#ui.set_theme
[`gui.maximized`]: api.html#ui.maximized
[`lexer._tokenstyles`]: api.html#lexer.Token.Styles
[Scintilla]: http://scintilla.org
@@ -2899,7 +2894,7 @@ Changes:
* [`_M.textadept.editing.block_comment()`][] supports block comment delimiters.
* Block comments for languages is now built-in. The supplemental ones on the
wiki are no longer needed.
-* [`gui.set_theme()`][] accepts key-value argument pairs for overriding theme
+* `gui.set_theme()` accepts key-value argument pairs for overriding theme
properties.
* Removed `gui.select_theme()` since selected themes do not persist.
* Removed `_G.RESETTING` flag.
@@ -2920,7 +2915,6 @@ Changes:
[PGP -- 7.0 alpha 2 Modules]: download/textadept_7.0_alpha_2.modules.zip.asc
[compiling]: manual.html#Compiling
[`_M.textadept.editing.block_comment()`]: api.html#textadept.editing.block_comment
-[`gui.set_theme()`]: api.html#ui.set_theme
[`_M.textadept.bookmarks.goto_mark()`]: api.html#textadept.bookmarks.goto_mark
[LuaJIT]: http://luajit.org
[nightly builds]: README.html#Download
@@ -3943,7 +3937,7 @@ Bugfixes:
Changes:
-* Added on-the-fly [theme switching][].
+* Added on-the-fly theme switching.
* All new `light` and `dark` themes.
* Removed `_m.textadept.editing.select_style()`.
* Simplify theming via [gtkrc][] by naming `GtkWindow` only.
@@ -3962,7 +3956,6 @@ Changes:
[PGP -- 4.3 Linux x86_64]: download/textadept_4.3.x86_64.tgz.asc
[PGP -- 4.3 Source]: download/textadept_4.3.src.zip.asc
[PGP -- 4.3 Modules]: download/textadept_4.3.modules.zip.asc
-[theme switching]: api.html#ui.set_theme
[gtkrc]: manual.html#GUI.Theme
[`lexer.REGEX`]: api.html#lexer.REGEX
[`lexer.LABEL`]: api.html#lexer.LABEL
diff --git a/core/.buffer.luadoc b/core/.buffer.luadoc
index b0618699..0f6040b2 100644
--- a/core/.buffer.luadoc
+++ b/core/.buffer.luadoc
@@ -440,8 +440,6 @@
--
-- @field SEL_THIN (number, Read-only)
--
--- @field STYLE_MAX (number, Read-only)
---
-- @field UPDATE_CONTENT (number, Read-only)
--
-- @field UPDATE_SELECTION (number, Read-only)
@@ -1882,20 +1880,6 @@ function get_lexer(buffer, current) end
-- @usage buffer:set_lexer('lexer_name')
function set_lexer(buffer, lexer) end
----
--- Sets the buffer's color theme to be string *name* and (optionally) assigns
--- the properties contained in table *props*.
--- 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 buffer A buffer.
--- @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 buffer:set_theme('light', {font = 'Monospace', fontsize = 12})
--- @name set_theme
-function set_theme(buffer, name, props) end
-
-- Unused Fields.
-- * accessibility
-- * annotation_style_offset
diff --git a/core/.view.luadoc b/core/.view.luadoc
index 7f1477af..40acda08 100644
--- a/core/.view.luadoc
+++ b/core/.view.luadoc
@@ -903,6 +903,8 @@
--
-- @field STYLE_LINENUMBER (number, Read-only)
--
+-- @field STYLE_MAX (number, Read-only)
+--
-- @field UPDATE_H_SCROLL (number, Read-only)
--
-- @field UPDATE_V_SCROLL (number, Read-only)
@@ -1405,3 +1407,17 @@ function unsplit(view) end
-- @see events.BUFFER_BEFORE_SWITCH
-- @see events.BUFFER_AFTER_SWITCH
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*.
+-- 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})
+-- @name set_theme
+function set_theme(view, name, props) end
diff --git a/doc/manual.md b/doc/manual.md
index 3649b410..7507ec37 100644
--- a/doc/manual.md
+++ b/doc/manual.md
@@ -2006,15 +2006,16 @@ terminal's constraints:
Old API |Change |New API
------------------------|:------:|-------
**buffer** | |
+set_theme() |Renamed |[view:set_theme()][]
style_name[n] |Replaced|[buffer:name_of_style][](n)
**events** | |
N/A |Added |[events.SESSION_SAVE][]
N/A |Added |[events.SESSION_LOAD][]
**io** | |
-reload_file |Renamed |[buffer:reload()][]
-save_file |Renamed |[buffer:save()][]
-save_file_as |Renamed |[buffer:save_as()][]
-close_buffer |Renamed |[buffer:close()][]
+reload_file() |Renamed |[buffer:reload()][]
+save_file() |Renamed |[buffer:save()][]
+save_file_as() |Renamed |[buffer:save_as()][]
+close_buffer() |Renamed |[buffer:close()][]
**keys** | |
MODE |Renamed |[mode][]
**lexer** | |
@@ -2041,6 +2042,7 @@ N/A |Added |_buffer functions and fields_<sup>b</sup>
<sup>b</sup>Most buffer functions and fields are available in views now. See
section below.
+[view:set_theme()]: api.html#view.set_theme
[buffer:name_of_style]: api.html#buffer.name_of_style
[events.SESSION_SAVE]: api.html#events.SESSION_SAVE
[events.SESSION_LOAD]: api.html#events.SESSION_LOAD
@@ -2115,7 +2117,7 @@ need to be updated and will continue to function normally_. The following "Find"
regex can be used to help convert `buffer.*` functionality to `view.*`:
<pre style="word-wrap: break-word;">
-<code>(\w+)([.:])\b(additional_caret_fore|additional_carets_blink|additional_carets_visible|additional_sel_alpha|additional_sel_back|additional_sel_fore|all_lines_visible|annotation_visible|auto_c_max_height|auto_c_max_width|call_tip_fore_hlt|call_tip_position|call_tip_use_style|caret_fore|caret_line_back|caret_line_back_alpha|caret_line_frame|caret_line_visible|caret_line_visible_always|caret_period|caret_style|caret_width|cursor|edge_colour|edge_column|edge_mode|end_at_last_line|extra_ascent|extra_descent|first_visible_line|fold_display_text_style|fold_expanded|fold_flags|h_scroll_bar|highlight_guide|idle_styling|indentation_guides|indic_alpha|indic_fore|indic_hover_fore|indic_hover_style|indic_outline_alpha|indic_style|indic_under|line_visible|lines_on_screen|margins|margin_back_n|margin_cursor_n|margin_left|margin_mask_n|margin_options|margin_right|margin_sensitive_n|margin_type_n|margin_width_n|marker_alpha|marker_back|marker_back_selected|marker_fore|mouse_dwell_time|mouse_selection_rectangular_switch|rectangular_selection_modifier|representation|rgba_image_height|rgba_image_scale|rgba_image_width|scroll_width|scroll_width_tracking|sel_alpha|sel_eol_filled|size|style_back|style_bold|style_case|style_changeable|style_eol_filled|style_font|style_fore|style_italic|style_size|style_underline|style_visible|tab_draw_mode|v_scroll_bar|view_eol|view_ws|whitespace_size|wrap_indent_mode|wrap_mode|wrap_start_indent|wrap_visual_flags|wrap_visual_flags_location|x_offset|zoom|ANNOTATION_BOXED|ANNOTATION_HIDDEN|ANNOTATION_STANDARD|ANNOTATION_INDENTED|CARETSTYLE_BLOCK|CARETSTYLE_INVISIBLE|CARETSTYLE_LINE|CARET_EVEN|CARET_JUMPS|CARET_SLOP|CARET_STRICT|EDGE_BACKGROUND|EDGE_LINE|EDGE_MULTILINE|EDGE_NONE|FOLDACTION_CONTRACT|FOLDACTION_EXPAND|FOLDACTION_TOGGLE|FOLDDISPLAYTEXT_HIDDEN|FOLDDISPLAYTEXT_STANDARD|FOLDDISPLAYTEXT_BOXED|INDIC_BOX|INDIC_COMPOSITIONTHICK|INDIC_COMPOSITIONTHIN|INDIC_DASH|INDIC_DIAGONAL|INDIC_DOTBOX|INDIC_DOTS|INDIC_FULLBOX|INDIC_GRADIENT|INDIC_GRADIENTCENTRE|INDIC_HIDDEN|INDIC_PLAIN|INDIC_POINT|INDIC_POINTCHARACTER|INDIC_ROUNDBOX|INDIC_SQUIGGLE|INDIC_SQUIGGLELOW|INDIC_SQUIGGLEPIXMAP|INDIC_STRAIGHTBOX|INDIC_STRIKE|INDIC_TEXTFORE|INDIC_TT|MOD_ALT|MOD_CTRL|MOD_META|MOD_SHIFT|MOD_SUPER|MOUSE_DRAG|MOUSE_PRESS|MOUSE_RELEASE|WS_INVISIBLE|WS_VISIBLEAFTERINDENT|WS_VISIBLEALWAYS|WS_VISIBLEONLYININDENT|ALPHA_NOALPHA|ALPHA_OPAQUE|ALPHA_TRANSPARENT|CASE_CAMEL|CASE_LOWER|CASE_MIXED|CASE_UPPER|CURSORARROW|CURSORNORMAL|CURSORREVERSEARROW|CURSORWAIT|FOLDFLAG_LEVELNUMBERS|FOLDFLAG_LINEAFTER_CONTRACTED|FOLDFLAG_LINEAFTER_EXPANDED|FOLDFLAG_LINEBEFORE_CONTRACTED|FOLDFLAG_LINEBEFORE_EXPANDED|FOLDFLAG_LINESTATE|IV_LOOKBOTH|IV_LOOKFORWARD|IV_NONE|IV_REAL|MARGINOPTION_NONE|MARGINOPTION_SUBLINESELECT|MARGIN_BACK|MARGIN_COLOUR|MARGIN_FORE|MARGIN_NUMBER|MARGIN_RTEXT|MARGIN_SYMBOL|MARGIN_TEXT|MARK_ARROW|MARK_ARROWDOWN|MARK_ARROWS|MARK_BACKGROUND|MARK_BOOKMARK|MARK_BOXMINUS|MARK_BOXMINUSCONNECTED|MARK_BOXPLUS|MARK_BOXPLUSCONNECTED|MARK_CHARACTER|MARK_CIRCLE|MARK_CIRCLEMINUS|MARK_CIRCLEMINUSCONNECTED|MARK_CIRCLEPLUS|MARK_CIRCLEPLUSCONNECTED|MARK_DOTDOTDOT|MARK_EMPTY|MARK_FULLRECT|MARK_LCORNER|MARK_LCORNERCURVE|MARK_LEFTRECT|MARK_MINUS|MARK_PIXMAP|MARK_PLUS|MARK_RGBAIMAGE|MARK_ROUNDRECT|MARK_SHORTARROW|MARK_SMALLRECT|MARK_TCORNER|MARK_TCORNERCURVE|MARK_UNDERLINE|MARK_VERTICALBOOKMARK|MARK_VLINE|MASK_FOLDERS|TD_LONGARROW|TD_STRIKEOUT|TIME_FOREVER|WRAPINDENT_DEEPINDENT|WRAPINDENT_FIXED|WRAPINDENT_INDENT|WRAPINDENT_SAME|WRAPVISUALFLAGLOC_DEFAULT|WRAPVISUALFLAGLOC_END_BY_TEXT|WRAPVISUALFLAGLOC_START_BY_TEXT|WRAPVISUALFLAG_END|WRAPVISUALFLAG_MARGIN|WRAPVISUALFLAG_NONE|WRAPVISUALFLAG_START|WRAP_CHAR|WRAP_NONE|WRAP_WHITESPACE|WRAP_WORD|STYLE_BRACEBAD|STYLE_BRACELIGHT|STYLE_CALLTIP|STYLE_CONTROLCHAR|STYLE_DEFAULT|STYLE_FOLDDISPLAYTEXT|STYLE_INDENTGUIDE|STYLE_LINENUMBER|UPDATE_H_SCROLL|UPDATE_V_SCROLL|VISIBLE_SLOP|VISIBLE_STRICT|brace_bad_light|brace_bad_light_indicator|brace_highlight|brace_highlight_indicator|call_tip_set_hlt|clear_registered_images|clear_representation|contracted_fold_next|doc_line_from_visible|ensure_visible|ensure_visible_enforce_policy|fold_all|fold_children|fold_line|get_default_fold_display_text|hide_lines|line_scroll|line_scroll_down|line_scroll_up|marker_define|marker_define_pixmap|marker_define_rgba_image|marker_enable_highlight|marker_symbol_defined|multi_edge_add_line|multi_edge_clear_all|register_image|register_rgba_image|scroll_caret|scroll_to_end|scroll_to_start|scroll_range|set_default_fold_display_text|set_fold_margin_colour|set_fold_margin_hi_colour|set_sel_back|set_sel_fore|set_visible_policy|set_whitespace_back|set_whitespace_fore|set_x_caret_policy|set_y_caret_policy|show_lines|style_clear_all|style_reset_default|text_height|text_width|toggle_fold|toggle_fold_show_text|vertical_centre_caret|visible_from_doc_line|wrap_count|zoom_in|zoom_out|split|unsplit|goto_buffer)\b</code>
+<code>(\w+)([.:])\b(additional_caret_fore|additional_carets_blink|additional_carets_visible|additional_sel_alpha|additional_sel_back|additional_sel_fore|all_lines_visible|annotation_visible|auto_c_max_height|auto_c_max_width|call_tip_fore_hlt|call_tip_position|call_tip_use_style|caret_fore|caret_line_back|caret_line_back_alpha|caret_line_frame|caret_line_visible|caret_line_visible_always|caret_period|caret_style|caret_width|cursor|edge_colour|edge_column|edge_mode|end_at_last_line|extra_ascent|extra_descent|first_visible_line|fold_display_text_style|fold_expanded|fold_flags|h_scroll_bar|highlight_guide|idle_styling|indentation_guides|indic_alpha|indic_fore|indic_hover_fore|indic_hover_style|indic_outline_alpha|indic_style|indic_under|line_visible|lines_on_screen|margins|margin_back_n|margin_cursor_n|margin_left|margin_mask_n|margin_options|margin_right|margin_sensitive_n|margin_type_n|margin_width_n|marker_alpha|marker_back|marker_back_selected|marker_fore|mouse_dwell_time|mouse_selection_rectangular_switch|rectangular_selection_modifier|representation|rgba_image_height|rgba_image_scale|rgba_image_width|scroll_width|scroll_width_tracking|sel_alpha|sel_eol_filled|size|style_back|style_bold|style_case|style_changeable|style_eol_filled|style_font|style_fore|style_italic|style_size|style_underline|style_visible|tab_draw_mode|v_scroll_bar|view_eol|view_ws|whitespace_size|wrap_indent_mode|wrap_mode|wrap_start_indent|wrap_visual_flags|wrap_visual_flags_location|x_offset|zoom|ANNOTATION_BOXED|ANNOTATION_HIDDEN|ANNOTATION_STANDARD|ANNOTATION_INDENTED|CARETSTYLE_BLOCK|CARETSTYLE_INVISIBLE|CARETSTYLE_LINE|CARET_EVEN|CARET_JUMPS|CARET_SLOP|CARET_STRICT|EDGE_BACKGROUND|EDGE_LINE|EDGE_MULTILINE|EDGE_NONE|FOLDACTION_CONTRACT|FOLDACTION_EXPAND|FOLDACTION_TOGGLE|FOLDDISPLAYTEXT_HIDDEN|FOLDDISPLAYTEXT_STANDARD|FOLDDISPLAYTEXT_BOXED|INDIC_BOX|INDIC_COMPOSITIONTHICK|INDIC_COMPOSITIONTHIN|INDIC_DASH|INDIC_DIAGONAL|INDIC_DOTBOX|INDIC_DOTS|INDIC_FULLBOX|INDIC_GRADIENT|INDIC_GRADIENTCENTRE|INDIC_HIDDEN|INDIC_PLAIN|INDIC_POINT|INDIC_POINTCHARACTER|INDIC_ROUNDBOX|INDIC_SQUIGGLE|INDIC_SQUIGGLELOW|INDIC_SQUIGGLEPIXMAP|INDIC_STRAIGHTBOX|INDIC_STRIKE|INDIC_TEXTFORE|INDIC_TT|MOD_ALT|MOD_CTRL|MOD_META|MOD_SHIFT|MOD_SUPER|MOUSE_DRAG|MOUSE_PRESS|MOUSE_RELEASE|WS_INVISIBLE|WS_VISIBLEAFTERINDENT|WS_VISIBLEALWAYS|WS_VISIBLEONLYININDENT|ALPHA_NOALPHA|ALPHA_OPAQUE|ALPHA_TRANSPARENT|CASE_CAMEL|CASE_LOWER|CASE_MIXED|CASE_UPPER|CURSORARROW|CURSORNORMAL|CURSORREVERSEARROW|CURSORWAIT|FOLDFLAG_LEVELNUMBERS|FOLDFLAG_LINEAFTER_CONTRACTED|FOLDFLAG_LINEAFTER_EXPANDED|FOLDFLAG_LINEBEFORE_CONTRACTED|FOLDFLAG_LINEBEFORE_EXPANDED|FOLDFLAG_LINESTATE|IV_LOOKBOTH|IV_LOOKFORWARD|IV_NONE|IV_REAL|MARGINOPTION_NONE|MARGINOPTION_SUBLINESELECT|MARGIN_BACK|MARGIN_COLOUR|MARGIN_FORE|MARGIN_NUMBER|MARGIN_RTEXT|MARGIN_SYMBOL|MARGIN_TEXT|MARK_ARROW|MARK_ARROWDOWN|MARK_ARROWS|MARK_BACKGROUND|MARK_BOOKMARK|MARK_BOXMINUS|MARK_BOXMINUSCONNECTED|MARK_BOXPLUS|MARK_BOXPLUSCONNECTED|MARK_CHARACTER|MARK_CIRCLE|MARK_CIRCLEMINUS|MARK_CIRCLEMINUSCONNECTED|MARK_CIRCLEPLUS|MARK_CIRCLEPLUSCONNECTED|MARK_DOTDOTDOT|MARK_EMPTY|MARK_FULLRECT|MARK_LCORNER|MARK_LCORNERCURVE|MARK_LEFTRECT|MARK_MINUS|MARK_PIXMAP|MARK_PLUS|MARK_RGBAIMAGE|MARK_ROUNDRECT|MARK_SHORTARROW|MARK_SMALLRECT|MARK_TCORNER|MARK_TCORNERCURVE|MARK_UNDERLINE|MARK_VERTICALBOOKMARK|MARK_VLINE|MASK_FOLDERS|TD_LONGARROW|TD_STRIKEOUT|TIME_FOREVER|WRAPINDENT_DEEPINDENT|WRAPINDENT_FIXED|WRAPINDENT_INDENT|WRAPINDENT_SAME|WRAPVISUALFLAGLOC_DEFAULT|WRAPVISUALFLAGLOC_END_BY_TEXT|WRAPVISUALFLAGLOC_START_BY_TEXT|WRAPVISUALFLAG_END|WRAPVISUALFLAG_MARGIN|WRAPVISUALFLAG_NONE|WRAPVISUALFLAG_START|WRAP_CHAR|WRAP_NONE|WRAP_WHITESPACE|WRAP_WORD|STYLE_BRACEBAD|STYLE_BRACELIGHT|STYLE_CALLTIP|STYLE_CONTROLCHAR|STYLE_DEFAULT|STYLE_FOLDDISPLAYTEXT|STYLE_INDENTGUIDE|STYLE_LINENUMBER|STYLE_MAX|UPDATE_H_SCROLL|UPDATE_V_SCROLL|VISIBLE_SLOP|VISIBLE_STRICT|brace_bad_light|brace_bad_light_indicator|brace_highlight|brace_highlight_indicator|call_tip_set_hlt|clear_registered_images|clear_representation|contracted_fold_next|doc_line_from_visible|ensure_visible|ensure_visible_enforce_policy|fold_all|fold_children|fold_line|get_default_fold_display_text|hide_lines|line_scroll|line_scroll_down|line_scroll_up|marker_define|marker_define_pixmap|marker_define_rgba_image|marker_enable_highlight|marker_symbol_defined|multi_edge_add_line|multi_edge_clear_all|register_image|register_rgba_image|scroll_caret|scroll_to_end|scroll_to_start|scroll_range|set_default_fold_display_text|set_fold_margin_colour|set_fold_margin_hi_colour|set_sel_back|set_sel_fore|set_visible_policy|set_whitespace_back|set_whitespace_fore|set_x_caret_policy|set_y_caret_policy|show_lines|style_clear_all|style_reset_default|text_height|text_width|toggle_fold|toggle_fold_show_text|vertical_centre_caret|visible_from_doc_line|wrap_count|zoom_in|zoom_out|split|unsplit|goto_buffer)\b</code>
</pre>
"Replace" with
diff --git a/init.lua b/init.lua
index d7c9f271..a3d5bf29 100644
--- a/init.lua
+++ b/init.lua
@@ -18,35 +18,36 @@ end
textadept = require('textadept')
--- Temporary compatibility.
-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})
-
--- Documentation is in core/.buffer.luadoc.
-local function set_theme(buffer, name, props)
+-- Documentation is in core/.view.luadoc.
+local function set_theme(view, name, props)
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
- local orig_buffer = _G.buffer -- may not be equivalent to buffer argument
- _G.buffer = buffer
+ local orig_view = _G.view
+ if view ~= orig_view then ui.goto_view(view) end
dofile(name)
- _G.buffer = orig_buffer
for prop, value in pairs(props) do buffer.property[prop] = value end
-- 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
-events.connect(events.BUFFER_NEW, function() buffer.set_theme = set_theme end)
-buffer.set_theme = set_theme -- needed for the first buffer
+events.connect(events.VIEW_NEW, function() view.set_theme = set_theme end)
+view.set_theme = set_theme -- needed for the first view
-- On reset, _LOADED['lexer'] is removed. Force a reload in order for set_theme
-- to work properly.
if not arg then view:goto_buffer(buffer) end
+-- Temporary compatibility.
+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
+
-- The remainder of this file defines default buffer properties and applies them
-- to subsequent buffers. Normally, a setting like `buffer.use_tabs = false`
-- only applies to the current (initial) buffer. However, temporarily tap into
@@ -94,7 +95,7 @@ end
-- Default buffer and view settings.
local buffer, view = buffer, view
-buffer:set_theme(not CURSES and 'light' or 'term')
+view:set_theme(not CURSES and 'light' or 'term')
-- Multiple Selection and Virtual Space
buffer.multiple_selection = true
@@ -296,6 +297,8 @@ 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
@@ -303,7 +306,6 @@ events.connect(events.BUFFER_NEW, function()
local SETDIRECTPOINTER = _SCINTILLA.properties.doc_pointer[2]
local SETLUASTATE = _SCINTILLA.functions.change_lexer_state[1]
local LOADLEXERLIBRARY = _SCINTILLA.functions.load_lexer_library[1]
- local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
buffer.lexer_language = 'lpeg'
buffer:private_lexer_call(SETDIRECTFUNCTION, buffer.direct_function)
buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer)
@@ -342,5 +344,6 @@ events.connect(events.VIEW_NEW, function()
-- '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.
- buffer:set_lexer(buffer._lexer or 'text')
+ -- Note: `buffer:set_lexer()` is insufficient for some reason.
+ buffer:private_lexer_call(SETLEXERLANGUAGE, buffer._lexer or 'text')
end, 1)
diff --git a/modules/lua/ta_api b/modules/lua/ta_api
index 03fe8200..7dbfbf45 100644
--- a/modules/lua/ta_api
+++ b/modules/lua/ta_api
@@ -287,7 +287,7 @@ STYLE_KEYWORD lexer.STYLE_KEYWORD (string)\nThe style typically used for languag
STYLE_LABEL lexer.STYLE_LABEL (string)\nThe style typically used for labels.
STYLE_LINENUMBER lexer.STYLE_LINENUMBER (string)\nThe style used for all margins except fold margins.
STYLE_LINENUMBER view.STYLE_LINENUMBER (number, Read-only)\n
-STYLE_MAX buffer.STYLE_MAX (number, Read-only)\n
+STYLE_MAX view.STYLE_MAX (number, Read-only)\n
STYLE_NUMBER lexer.STYLE_NUMBER (string)\nThe style typically used for numbers.
STYLE_OPERATOR lexer.STYLE_OPERATOR (string)\nThe style typically used for operators.
STYLE_PREPROCESSOR lexer.STYLE_PREPROCESSOR (string)\nThe style typically used for preprocessor statements.
@@ -994,7 +994,7 @@ set_selection buffer.set_selection(buffer, end_pos, start_pos)\nSelects the rang
set_styling buffer.set_styling(buffer, length, style)\nAssigns style number *style*, in the range from `1` to `256`, to the next\n*length* characters, starting from the current styling position, and\nincrements the styling position by *length*.\n`buffer:start_styling` should be called before `buffer:set_styling()`.\n@param buffer A buffer.\n@param length The number of characters to style.\n@param style The style number to set.
set_target_range buffer.set_target_range(buffer, start_pos, end_pos)\nDefines the target range's beginning and end positions as *start_pos* and\n*end_pos*, respectively.\n@param buffer A buffer.\n@param start_pos The position of the beginning of the target range.\n@param end_pos The position of the end of the target range.
set_text buffer.set_text(buffer, text)\nReplaces the buffer's text with string *text*.\n@param buffer A buffer.\n@param text The text to set.
-set_theme buffer.set_theme(buffer, name, props)\nSets the buffer's color theme to be string *name* and (optionally) assigns\nthe properties contained in table *props*.\nUser themes override Textadept's default themes when they have the same name.\nIf *name* contains slashes, it is assumed to be an absolute path to a theme\ninstead of a theme name.\n@param buffer A buffer.\n@param name The name or absolute path of a theme to set.\n@param props Optional table of theme property assignments that override the\n theme's defaults.\n@usage buffer:set_theme('light', {font = 'Monospace', fontsize = 12})
+set_theme view.set_theme(view, name, props)\nSets the view's color theme to be string *name* and (optionally) assigns\nthe properties contained in table *props*.\nUser themes override Textadept's default themes when they have the same name.\nIf *name* contains slashes, it is assumed to be an absolute path to a theme\ninstead of a theme name.\n@param view A view.\n@param name The name or absolute path of a theme to set.\n@param props Optional table of theme property assignments that override the\n theme's defaults.\n@usage view:set_theme('light', {font = 'Monospace', fontsize = 12})
set_visible_policy view.set_visible_policy(view, policy, y)\nDefines scrolling policy bit-mask *policy* as the policy for keeping the\ncaret *y* number of lines away from the vertical margins as\n`view.ensure_visible_enforce_policy()` redisplays hidden or folded lines.\nIt is similar in operation to `view.set_y_caret_policy()`.\n@param view A view.\n@param policy The combination of `view.VISIBLE_SLOP` and\n `view.VISIBLE_STRICT` policy flags to set.\n@param y The number of lines from the vertical margins to keep the caret.
set_watch debugger.set_watch(expr)\nWatches string expression *expr* for changes and breaks on each change.\nEmits a `DEBUGGER_WATCH_ADDED` event if the debugger is running, or queues up\nthe event to run in `debugger.start()`.\nIf the debugger is executing (e.g. not at a breakpoint), assumes a watch\ncannot be set and shows an error message.\n@param expr String expression to watch.
set_whitespace_back view.set_whitespace_back(view, use_setting, color)\nOverrides the background color of whitespace with color *color*, in\n"0xBBGGRR" format, if *use_setting* is `true`.\n@param view A view.\n@param use_setting Whether or not to use *color*.\n@param color The color in "0xBBGGRR" format.
diff --git a/modules/lua/ta_tags b/modules/lua/ta_tags
index ecfc9b48..f3d45f84 100644
--- a/modules/lua/ta_tags
+++ b/modules/lua/ta_tags
@@ -287,7 +287,7 @@ STYLE_KEYWORD _HOME/lexers/lexer.lua /^module('lexer')]=]$/;" F class:lexer
STYLE_LABEL _HOME/lexers/lexer.lua /^module('lexer')]=]$/;" F class:lexer
STYLE_LINENUMBER _HOME/core/.view.luadoc /^module('view')$/;" F class:view
STYLE_LINENUMBER _HOME/lexers/lexer.lua /^module('lexer')]=]$/;" F class:lexer
-STYLE_MAX _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
+STYLE_MAX _HOME/core/.view.luadoc /^module('view')$/;" F class:view
STYLE_NUMBER _HOME/lexers/lexer.lua /^module('lexer')]=]$/;" F class:lexer
STYLE_OPERATOR _HOME/lexers/lexer.lua /^module('lexer')]=]$/;" F class:lexer
STYLE_PREPROCESSOR _HOME/lexers/lexer.lua /^module('lexer')]=]$/;" F class:lexer
@@ -1004,7 +1004,7 @@ set_selection _HOME/core/.buffer.luadoc /^function set_selection(buffer, end_pos
set_styling _HOME/core/.buffer.luadoc /^function set_styling(buffer, length, style) end$/;" f class:buffer
set_target_range _HOME/core/.buffer.luadoc /^function set_target_range(buffer, start_pos, end_pos) end$/;" f class:buffer
set_text _HOME/core/.buffer.luadoc /^function set_text(buffer, text) end$/;" f class:buffer
-set_theme _HOME/core/.buffer.luadoc /^function set_theme(buffer, name, props) end$/;" f class:buffer
+set_theme _HOME/core/.view.luadoc /^function set_theme(view, name, props) end$/;" f class:view
set_visible_policy _HOME/core/.view.luadoc /^function set_visible_policy(view, policy, y) end$/;" f class:view
set_watch _HOME/modules/debugger/init.lua /^function M.set_watch(expr)$/;" f class:debugger
set_whitespace_back _HOME/core/.view.luadoc /^function set_whitespace_back(view, use_setting, color) end$/;" f class:view
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.