aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/.buffer.luadoc14
-rw-r--r--core/ui.lua86
-rw-r--r--doc/manual.md92
-rw-r--r--init.lua285
-rw-r--r--properties.lua184
-rw-r--r--src/Makefile8
-rw-r--r--src/textadept.c6
7 files changed, 352 insertions, 323 deletions
diff --git a/core/.buffer.luadoc b/core/.buffer.luadoc
index 79d0bb62..49e4309b 100644
--- a/core/.buffer.luadoc
+++ b/core/.buffer.luadoc
@@ -3112,6 +3112,20 @@ function get_lexer(buffer, current) end
-- @usage buffer:set_lexer('lexer_name')
function set_lexer(buffer, lexer) end
+---
+-- Declares the editor 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.
+-- Note: this function must be called on startup in order to be effective.
+-- @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(name, props) end
+
-- Unused Fields.
-- * annotation_style_offset
-- * annotation_styles
diff --git a/core/ui.lua b/core/ui.lua
index fa45eac9..0060231c 100644
--- a/core/ui.lua
+++ b/core/ui.lua
@@ -37,11 +37,6 @@ module('ui')]]
ui.silent_print = false
-local theme = package.searchpath(not CURSES and 'light' or 'term',
- _USERHOME..'/themes/?.lua;'..
- _HOME..'/themes/?.lua')
-local theme_props = {}
-
-- Helper function for printing messages to buffers.
-- @see ui._print
local function _print(buffer_type, ...)
@@ -265,89 +260,11 @@ function ui.goto_file(filename, split, preferred_view, sloppy)
io.open_file(filename)
end
----
--- Switches the editor theme to 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 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 ui.set_theme('light', {font = 'Monospace', fontsize = 12})
--- @name set_theme
-function ui.set_theme(name, props)
- name = name:find('[/\\]') and name or
- package.searchpath(name, _USERHOME..'/themes/?.lua;'..
- _HOME..'/themes/?.lua')
- if not name or not lfs.attributes(name) then return end
- props = props or {}
- local current_buffer, current_view = buffer, view
- for i = 1, #_BUFFERS do
- view:goto_buffer(_BUFFERS[i])
- dofile(name)
- for prop, value in pairs(props) do buffer.property[prop] = value end
- end
- view:goto_buffer(current_buffer)
- for i = 1, #_VIEWS do
- ui.goto_view(_VIEWS[i])
- dofile(name)
- for prop, value in pairs(props) do buffer.property[prop] = value end
- end
- ui.goto_view(current_view)
- theme, theme_props = name, props
-end
-
local events, events_connect = events, events.connect
--- Loads the theme and properties files.
-local function load_theme_and_settings()
- dofile(theme)
- for prop, value in pairs(theme_props) do buffer.property[prop] = value end
- dofile(_HOME..'/properties.lua')
- if lfs.attributes(_USERHOME..'/properties.lua') then
- dofile(_USERHOME..'/properties.lua')
- end
-end
-
--- Sets default properties for a Scintilla window.
-events_connect(events.VIEW_NEW, function()
- local buffer = buffer
- -- Allow redefinitions of these Scintilla key commands.
- local ctrl_keys = {
- '[', ']', '/', '\\', 'Z', 'Y', 'X', 'C', 'V', 'A', 'L', 'T', 'D', 'U'
- }
- local ctrl_shift_keys = {'L', 'T', 'U', 'Z'}
- for i = 1, #ctrl_keys do
- buffer:clear_cmd_key(string.byte(ctrl_keys[i]) +
- bit32.lshift(buffer.MOD_CTRL, 16))
- end
- for i = 1, #ctrl_shift_keys do
- buffer:clear_cmd_key(string.byte(ctrl_shift_keys[i]) +
- bit32.lshift(buffer.MOD_CTRL + buffer.MOD_SHIFT, 16))
- end
- -- Since BUFFER_NEW loads themes and settings on startup, only load them for
- -- subsequent views.
- if #_VIEWS > 1 then load_theme_and_settings() end
-end)
+-- Ensure title, statusbar, etc. are updated for new views.
events_connect(events.VIEW_NEW, function() events.emit(events.UPDATE_UI) end)
-local SETDIRECTFUNCTION = _SCINTILLA.properties.direct_function[1]
-local SETDIRECTPOINTER = _SCINTILLA.properties.doc_pointer[2]
-local SETLUASTATE = _SCINTILLA.functions.change_lexer_state[1]
-local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
--- Sets default properties for a Scintilla document.
-events_connect(events.BUFFER_NEW, function()
- buffer.lexer_language = 'lpeg'
- buffer:private_lexer_call(SETDIRECTFUNCTION, buffer.direct_function)
- buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer)
- buffer:private_lexer_call(SETLUASTATE, _LUA)
- buffer.property['lexer.lpeg.home'] = _USERHOME..'/lexers/?.lua;'..
- _HOME..'/lexers'
- load_theme_and_settings()
- buffer:private_lexer_call(SETLEXERLANGUAGE, 'text')
-end)
-
-- Switches between buffers when a tab is clicked.
events_connect(events.TAB_CLICKED,
function(index) view:goto_buffer(_BUFFERS[index]) end)
@@ -434,6 +351,7 @@ end)
-- Updates titlebar and statusbar.
local function update_bars()
set_title()
+ local SETDIRECTPOINTER = _SCINTILLA.properties.doc_pointer[2]
buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer)
events.emit(events.UPDATE_UI)
end
diff --git a/doc/manual.md b/doc/manual.md
index 15f928ee..721f1678 100644
--- a/doc/manual.md
+++ b/doc/manual.md
@@ -989,11 +989,37 @@ order to configure Textadept.
Textadept executes a *~/.textadept/init.lua*, your user-init file, on startup.
If this file does not exist, Textadept creates it for you. This file allows you
to write arbitrary Lua code that instructs Textadept what to do when the
-application starts. This includes (but is not limited to) changing the
-settings of existing modules, loading new modules, modifying key bindings,
-adding snippets, editing file associations, adding menu items, and changing the
-theme. This manual discusses these specific customizations, minus theming, in
-the sections below. Theming is covered in a later section.
+application starts. This includes (but is not limited to) changing editor
+preferences, changing the settings of existing modules, loading new modules,
+modifying key bindings, adding snippets, editing file associations, adding menu
+items, and changing the theme. This manual discusses these specific
+customizations, minus theming, in the sections below. Theming is covered in a
+later section.
+
+### Editor Preferences
+
+Editor preferences are stored in a [`buffer`][] object. Normally, each buffer
+can have its own individual preferences, but on startup, any preferences set
+apply to all subsequent buffers. For example, in order to override a setting
+like Textadept's default indentation setting of 2 spaces per indent, add the
+following to your *~/.textadept/init.lua*:
+
+ buffer.use_tabs = true
+ buffer.tab_width = 4
+
+(If you want to define per-language editor preferences, use the technique shown
+in the [Language Preferences](#Language.Preferences) section below.)
+
+Textadept's own *init.lua* contains the application's default editor settings
+(like 2 space indentation). This file is a good "quick reference" for
+configurable editor settings. It also has many commented out settings that
+you can copy to your *~/.textadept/init.lua* and uncomment in order to turn on
+(or change the value of before turning on). You can view a settings's
+documentation by pressing `Ctrl+H` (`^H` on Mac OSX | `M-H` or `M-S-H` in
+curses) or by reading the [buffer API documentation][].
+
+[`buffer`]: api.html#buffer
+[buffer API documentation]: api.html#buffer
### Module Preferences
@@ -1208,37 +1234,6 @@ Learn more about menus and how to customize them in the [menu documentation][].
[menu documentation]: api.html#textadept.menu
-## Buffer Settings
-
-While your *~/.textadept/init.lua* is useful for configuring Textadept's general
-preferences, it is not adequate for configuring editor preferences (e.g. buffer
-indentation settings, scrolling and autocompletion behavior, etc.). Attempting
-to define such settings from *~/.textadept/init.lua* would only apply to the
-first buffer and view -- subsequent buffers and split views would not inherit
-those settings.
-
-For editor preferences, Textadept executes a *~/.textadept/properties.lua* each
-time Textadept loads a file for editing (either in the current view or in a new,
-split view). Therefore, in order to override a setting like Textadept's default
-indentation setting of 2 spaces per indent, add the following to your
-*~/.textadept/properties.lua*:
-
- buffer.use_tabs = true
- buffer.tab_width = 4
-
-(If you want to define per-language editor preferences, use the technique shown
-in the [Language Preferences](#Language.Preferences) section above.)
-
-Textadept's own *properties.lua* contains the application's default editor
-settings (like 2 space indentation). This file is a good "quick reference" for
-configurable editor properties. It also has many commented out properties that
-you can copy to your *~/.textadept/properties.lua* and uncomment in order to
-turn on (or change the value of before turning on). You can view a property's
-documentation by pressing `Ctrl+H` (`^H` on Mac OSX | `M-H` or `M-S-H` in
-curses) or by reading the [buffer API documentation][].
-
-[buffer API documentation]: api.html#buffer
-
## Locale Preference
Textadept attempts to auto-detect your locale settings using the "$LANG"
@@ -1285,17 +1280,17 @@ display these standard colors (which may be completely different in the end).
## Setting Themes
Override the default theme in your [*~/.textadept/init.lua*](#User.Init) using
-the [`ui.set_theme()`][] function. For example:
+the [`buffer.set_theme()`][] function. For example:
- ui.set_theme(not CURSES and 'dark' or 'term')
+ buffer.set_theme(not CURSES and 'dark' or 'term')
-Either restart Textadept for changes to take effect or type [`reset()`][] in the
+Either restart Textadept for changes to take effect or type [`reset`][] in the
[command entry](#Lua.Command.Entry).
-`ui.set_theme()` can also tweak theme properties like font face and font size
-without editing the theme file itself:
+`buffer.set_theme()` can also tweak theme properties like font face and font
+size without editing the theme file itself:
- ui.set_theme('light', {font = 'Monospace', fontsize = 12})
+ buffer.set_theme('light', {font = 'Monospace', fontsize = 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
@@ -1310,8 +1305,8 @@ color Java functions black instead of the default orange, add the following to
For a full list of configurable properties, please consult the theme file you
are using.
-[`ui.set_theme()`]: api.html#ui.set_theme
-[`reset()`]: api.html#reset
+[`buffer.set_theme()`]: api.html#buffer.set_theme
+[`reset`]: api.html#reset
## Creating Themes
@@ -2564,7 +2559,7 @@ find.goto\_file\_in\_list() |Renamed |find.[goto\_file\_found()][]
select\_theme |Removed |N/A
N/A |New |[dialogs][]
filteredlist |Removed |N/A
-set\_theme(name, ...) |Changed |[set\_theme][](name, table)
+set\_theme(name, ...) |Changed |set\_theme(name, table)
**io** | |
try\_encodings |Renamed |[encodings][]
open\_file(string) |Changed |[open\_file][](string or table)
@@ -2613,7 +2608,6 @@ close\_all() |Renamed |[close\_all\_buffers()][]
[maximized]: api.html#ui.maximized
[goto\_file\_found()]: api.html#ui.find.goto_file_found
[dialogs]: api.html#ui.dialogs
-[set\_theme]: api.html#ui.set_theme
[encodings]: api.html#io.encodings
[open\_file]: api.html#io.open_file
[snapopen]: api.html#io.snapopen
@@ -2714,9 +2708,9 @@ Notes:
5. Set view properties related to colors directly in *theme.lua* now instead of
a separate *view.lua*. You may use color properties defined earlier. Try to
refrain from setting properties like `buffer.sel_eol_filled` which belong in
- a [*properties.lua*](#Buffer.Settings) file.
-6. The separate *buffer.lua* is gone. Use [*properties.lua*](#Buffer.Settings)
- or a [language module](#Language-Specific.Buffer.Settings).
+ a *properties.lua* file.
+6. The separate *buffer.lua* is gone. Use *properties.lua* or a
+ [language module](#Language-Specific.Buffer.Settings).
##### Theme Preference
diff --git a/init.lua b/init.lua
index ce40d869..c3b483fb 100644
--- a/init.lua
+++ b/init.lua
@@ -12,5 +12,290 @@ package.cpath = table.concat({
}, ';')
textadept = require('textadept')
+
+-- Documentation is in core/.buffer.luadoc.
+function buffer.set_theme(name, props)
+ name = name:find('[/\\]') and name or
+ package.searchpath(name, _USERHOME..'/themes/?.lua;'..
+ _HOME..'/themes/?.lua')
+ if not name or not lfs.attributes(name) then return end
+ dofile(name)
+ for prop, value in pairs(props or {}) do buffer.property[prop] = value end
+end
+-- 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
+
+-- 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
+-- buffer's metatable in order to capture these initial buffer settings (both
+-- from Textadept's init.lua and from the user's init.lua).
+
+local settings = {}
+
+local buffer_mt = getmetatable(buffer)
+local orig__index, orig__newindex = buffer_mt.__index, buffer_mt.__newindex
+local function repr(v)
+ return type(v) == 'string' and string.format("%q", v) or tostring(v)
+end
+buffer_mt.__index = function(buffer, k)
+ local v = orig__index(buffer, k)
+ if type(v) == 'function' then
+ return function(...)
+ local args = {...}
+ if type(args[1]) == 'table' then table.remove(args, 1) end -- ignore self
+ for i = 1, #args do args[i] = repr(args[i]) end
+ settings[#settings + 1] = string.format("buffer:%s(%s)", k,
+ table.concat(args, ','))
+ return v(...)
+ end
+ elseif type(v) == 'table' then
+ local property_mt = getmetatable(v)
+ setmetatable(v, {
+ __index = property_mt.__index,
+ __newindex = function(property, k2, v2)
+ settings[#settings + 1] = string.format("buffer.%s[%s]=%s", k, repr(k2),
+ repr(v2))
+ property_mt.__newindex(property, k2, v2)
+ end
+ })
+ end
+ return v
+end
+buffer_mt.__newindex = function(buffer, k, v)
+ settings[#settings + 1] = string.format("buffer[%s]=%s", repr(k), repr(v))
+ orig__newindex(buffer, k, v)
+end
+
+-- Default buffer settings.
+
+local buffer = buffer
+buffer.set_theme(not CURSES and 'light' or 'term')
+
+-- Multiple Selection and Virtual Space
+buffer.multiple_selection = true
+buffer.additional_selection_typing = true
+--buffer.multi_paste = buffer.MULTIPASTE_EACH
+--buffer.virtual_space_options = buffer.VS_RECTANGULARSELECTION +
+-- buffer.VS_USERACCESSIBLE
+buffer.rectangular_selection_modifier = buffer.MOD_ALT
+buffer.mouse_selection_rectangular_switch = true
+--buffer.additional_carets_blink = false
+--buffer.additional_carets_visible = false
+
+-- Scrolling.
+buffer:set_x_caret_policy(buffer.CARET_SLOP, 20)
+buffer:set_y_caret_policy(buffer.CARET_SLOP + buffer.CARET_STRICT +
+ buffer.CARET_EVEN, 1)
+buffer:set_visible_policy(buffer.VISIBLE_SLOP + buffer.VISIBLE_STRICT, 5)
+--buffer.h_scroll_bar = CURSES
+--buffer.v_scroll_bar = false
+if CURSES and not (WIN32 or LINUX or BSD) then buffer.v_scroll_bar = false end
+--buffer.scroll_width =
+--buffer.scroll_width_tracking = true
+--buffer.end_at_last_line = false
+
+-- Whitespace
+buffer.view_ws = buffer.WS_INVISIBLE
+--buffer.whitespace_size =
+--buffer.extra_ascent =
+--buffer.extra_descent =
+
+-- Line Endings
+buffer.view_eol = false
+
+-- Styling
+if not CURSES then buffer.idle_styling = buffer.IDLESTYLING_ALL end
+
+-- Caret and Selection Styles.
+--buffer.sel_eol_filled = true
+buffer.caret_line_visible = not CURSES
+--buffer.caret_line_visible_always = true
+--buffer.caret_period = 0
+--buffer.caret_style = buffer.CARETSTYLE_BLOCK
+--buffer.caret_width =
+--buffer.caret_sticky = buffer.CARETSTICKY_ON
+
+-- Margins.
+--buffer.margin_left =
+--buffer.margin_right =
+-- Line Number Margin.
+buffer.margin_type_n[0] = buffer.MARGIN_NUMBER
+local width = 4 * buffer:text_width(buffer.STYLE_LINENUMBER, '9')
+buffer.margin_width_n[0] = width + (not CURSES and 4 or 0)
+-- Marker Margin.
+buffer.margin_width_n[1] = not CURSES and 4 or 1
+-- Fold Margin.
+buffer.margin_width_n[2] = not CURSES and 12 or 1
+buffer.margin_mask_n[2] = buffer.MASK_FOLDERS
+-- Other Margins.
+for i = 1, buffer.margins - 1 do
+ buffer.margin_type_n[i] = buffer.MARGIN_SYMBOL
+ buffer.margin_sensitive_n[i] = true
+ buffer.margin_cursor_n[i] = buffer.CURSORARROW
+ if i > 2 then buffer.margin_width_n[i] = 0 end
+end
+
+-- Annotations.
+buffer.annotation_visible = buffer.ANNOTATION_BOXED
+
+-- Other.
+--buffer.word_chars =
+--buffer.whitespace_chars =
+--buffer.punctuation_chars =
+
+-- Tabs and Indentation Guides.
+-- Note: tab and indentation settings apply to individual buffers.
+buffer.tab_width = 2
+buffer.use_tabs = false
+--buffer.indent = 2
+buffer.tab_indents = true
+buffer.back_space_un_indents = true
+buffer.indentation_guides = not CURSES and buffer.IV_LOOKBOTH or buffer.IV_NONE
+
+-- Margin Markers.
+buffer:marker_define(textadept.bookmarks.MARK_BOOKMARK, buffer.MARK_FULLRECT)
+buffer:marker_define(textadept.run.MARK_WARNING, buffer.MARK_FULLRECT)
+buffer:marker_define(textadept.run.MARK_ERROR, buffer.MARK_FULLRECT)
+-- Arrow Folding Symbols.
+--buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_ARROWDOWN)
+--buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_ARROW)
+--buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDEREND, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_EMPTY)
+-- Plus/Minus Folding Symbols.
+--buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_MINUS)
+--buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_PLUS)
+--buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDEREND, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID, buffer.MARK_EMPTY)
+--buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_EMPTY)
+-- Circle Tree Folding Symbols.
+--buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_CIRCLEMINUS)
+--buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_CIRCLEPLUS)
+--buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_VLINE)
+--buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_LCORNERCURVE)
+--buffer:marker_define(buffer.MARKNUM_FOLDEREND,
+-- buffer.MARK_CIRCLEPLUSCONNECTED)
+--buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID,
+-- buffer.MARK_CIRCLEMINUSCONNECTED)
+--buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_TCORNERCURVE)
+-- Box Tree Folding Symbols.
+buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_BOXMINUS)
+buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_BOXPLUS)
+buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_VLINE)
+buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_LCORNER)
+buffer:marker_define(buffer.MARKNUM_FOLDEREND, buffer.MARK_BOXPLUSCONNECTED)
+buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID,
+ buffer.MARK_BOXMINUSCONNECTED)
+buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_TCORNER)
+--buffer:marker_enable_highlight(true)
+
+-- Indicators.
+buffer.indic_style[ui.find.INDIC_FIND] = buffer.INDIC_ROUNDBOX
+if not CURSES then buffer.indic_under[ui.find.INDIC_FIND] = true end
+local INDIC_BRACEMATCH = textadept.editing.INDIC_BRACEMATCH
+buffer.indic_style[INDIC_BRACEMATCH] = buffer.INDIC_BOX
+buffer:brace_highlight_indicator(not CURSES, INDIC_BRACEMATCH)
+local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT
+buffer.indic_style[INDIC_HIGHLIGHT] = buffer.INDIC_ROUNDBOX
+if not CURSES then buffer.indic_under[INDIC_HIGHLIGHT] = true end
+local INDIC_PLACEHOLDER = textadept.snippets.INDIC_PLACEHOLDER
+buffer.indic_style[INDIC_PLACEHOLDER] = not CURSES and buffer.INDIC_DOTBOX or
+ buffer.INDIC_STRAIGHTBOX
+
+-- Autocompletion.
+--buffer.auto_c_separator =
+--buffer.auto_c_cancel_at_start = false
+--buffer.auto_c_fill_ups = '('
+buffer.auto_c_choose_single = true
+--buffer.auto_c_ignore_case = true
+--buffer.auto_c_case_insensitive_behaviour =
+-- buffer.CASEINSENSITIVEBEHAVIOUR_IGNORECASE
+buffer.auto_c_multi = buffer.MULTIAUTOC_EACH
+--buffer.auto_c_auto_hide = false
+--buffer.auto_c_drop_rest_of_word = true
+--buffer.auto_c_type_separator =
+--buffer.auto_c_max_height =
+--buffer.auto_c_max_width =
+
+-- Call Tips.
+buffer.call_tip_use_style = buffer.tab_width *
+ buffer:text_width(buffer.STYLE_CALLTIP, ' ')
+--buffer.call_tip_position = true
+
+-- Folding.
+buffer.property['fold'] = '1'
+--buffer.property['fold.by.indentation'] = '1'
+--buffer.property['fold.line.comments'] = '1'
+--buffer.property['fold.on.zero.sum.lines'] = '1'
+buffer.automatic_fold = buffer.AUTOMATICFOLD_SHOW + buffer.AUTOMATICFOLD_CLICK +
+ buffer.AUTOMATICFOLD_CHANGE
+buffer.fold_flags = not CURSES and buffer.FOLDFLAG_LINEAFTER_CONTRACTED or 0
+buffer.fold_display_text_style = buffer.FOLDDISPLAYTEXT_BOXED
+
+-- Line Wrapping.
+buffer.wrap_mode = buffer.WRAP_NONE
+--buffer.wrap_visual_flags = buffer.WRAPVISUALFLAG_MARGIN
+--buffer.wrap_visual_flags_location = buffer.WRAPVISUALFLAGLOC_END_BY_TEXT
+--buffer.wrap_indent_mode = buffer.WRAPINDENT_SAME
+--buffer.wrap_start_indent =
+
+-- Long Lines.
+--buffer.edge_mode = not CURSES and buffer.EDGE_LINE or buffer.EDGE_BACKGROUND
+--buffer.edge_column = 80
+
+-- Accessibility.
+buffer.accessibility = buffer.ACCESSIBILITY_DISABLED
+
+-- Load user init file, which may also define default buffer settings.
local user_init = _USERHOME..'/init.lua'
if lfs.attributes(user_init) then dofile(user_init) end
+
+-- Generate default buffer settings for subsequent buffers and remove temporary
+-- buffer metatable listener.
+local load_settings = load(table.concat(settings, '\n'))
+buffer_mt.__index, buffer_mt.__newindex = orig__index, orig__newindex
+
+-- Sets default properties for a Scintilla document.
+events.connect(events.BUFFER_NEW, function()
+ local buffer = _G.buffer
+ local SETDIRECTFUNCTION = _SCINTILLA.properties.direct_function[1]
+ local SETDIRECTPOINTER = _SCINTILLA.properties.doc_pointer[2]
+ local SETLUASTATE = _SCINTILLA.functions.change_lexer_state[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)
+ buffer:private_lexer_call(SETLUASTATE, _LUA)
+ buffer.property['lexer.lpeg.home'] = _USERHOME..'/lexers/?.lua;'..
+ _HOME..'/lexers'
+ load_settings()
+ buffer:private_lexer_call(SETLEXERLANGUAGE, 'text')
+ if buffer == ui.command_entry then buffer.caret_line_visible = false end
+end, 1)
+
+-- Sets default properties for a Scintilla window.
+events.connect(events.VIEW_NEW, function()
+ local buffer = _G.buffer
+ -- Allow redefinitions of these Scintilla key commands.
+ local ctrl_keys = {
+ '[', ']', '/', '\\', 'Z', 'Y', 'X', 'C', 'V', 'A', 'L', 'T', 'D', 'U'
+ }
+ local ctrl_shift_keys = {'L', 'T', 'U', 'Z'}
+ for i = 1, #ctrl_keys do
+ buffer:clear_cmd_key(string.byte(ctrl_keys[i]) +
+ bit32.lshift(buffer.MOD_CTRL, 16))
+ end
+ for i = 1, #ctrl_shift_keys do
+ buffer:clear_cmd_key(string.byte(ctrl_shift_keys[i]) +
+ bit32.lshift(buffer.MOD_CTRL + buffer.MOD_SHIFT, 16))
+ end
+ -- Since BUFFER_NEW loads themes and settings on startup, only load them for
+ -- subsequent views.
+ if #_VIEWS > 1 then load_settings() end
+end, 1)
diff --git a/properties.lua b/properties.lua
deleted file mode 100644
index ad19ce8f..00000000
--- a/properties.lua
+++ /dev/null
@@ -1,184 +0,0 @@
--- Copyright 2007-2017 Mitchell mitchell.att.foicica.com. See LICENSE.
-
-local buffer = buffer
-
--- Multiple Selection and Virtual Space
-buffer.multiple_selection = true
-buffer.additional_selection_typing = true
---buffer.multi_paste = buffer.MULTIPASTE_EACH
---buffer.virtual_space_options = buffer.VS_RECTANGULARSELECTION +
--- buffer.VS_USERACCESSIBLE
-buffer.rectangular_selection_modifier = buffer.MOD_ALT
-buffer.mouse_selection_rectangular_switch = true
---buffer.additional_carets_blink = false
---buffer.additional_carets_visible = false
-
--- Scrolling.
-buffer:set_x_caret_policy(buffer.CARET_SLOP, 20)
-buffer:set_y_caret_policy(buffer.CARET_SLOP + buffer.CARET_STRICT +
- buffer.CARET_EVEN, 1)
-buffer:set_visible_policy(buffer.VISIBLE_SLOP + buffer.VISIBLE_STRICT, 5)
---buffer.h_scroll_bar = CURSES
---buffer.v_scroll_bar = false
-if CURSES and not (WIN32 or LINUX or BSD) then buffer.v_scroll_bar = false end
---buffer.scroll_width =
---buffer.scroll_width_tracking = true
---buffer.end_at_last_line = false
-
--- Whitespace
-buffer.view_ws = buffer.WS_INVISIBLE
---buffer.whitespace_size =
---buffer.extra_ascent =
---buffer.extra_descent =
-
--- Line Endings
-buffer.view_eol = false
-
--- Styling
-if not CURSES then buffer.idle_styling = buffer.IDLESTYLING_ALL end
-
--- Caret and Selection Styles.
---buffer.sel_eol_filled = true
-buffer.caret_line_visible = not CURSES and buffer ~= ui.command_entry
---buffer.caret_line_visible_always = true
---buffer.caret_period = 0
---buffer.caret_style = buffer.CARETSTYLE_BLOCK
---buffer.caret_width =
---buffer.caret_sticky = buffer.CARETSTICKY_ON
-
--- Margins.
---buffer.margin_left =
---buffer.margin_right =
--- Line Number Margin.
-buffer.margin_type_n[0] = buffer.MARGIN_NUMBER
-local width = 4 * buffer:text_width(buffer.STYLE_LINENUMBER, '9')
-buffer.margin_width_n[0] = width + (not CURSES and 4 or 0)
--- Marker Margin.
-buffer.margin_width_n[1] = not CURSES and 4 or 1
--- Fold Margin.
-buffer.margin_width_n[2] = not CURSES and 12 or 1
-buffer.margin_mask_n[2] = buffer.MASK_FOLDERS
--- Other Margins.
-for i = 1, buffer.margins - 1 do
- buffer.margin_type_n[i] = buffer.MARGIN_SYMBOL
- buffer.margin_sensitive_n[i] = true
- buffer.margin_cursor_n[i] = buffer.CURSORARROW
- if i > 2 then buffer.margin_width_n[i] = 0 end
-end
-
--- Annotations.
-buffer.annotation_visible = buffer.ANNOTATION_BOXED
-
--- Other.
---buffer.word_chars =
---buffer.whitespace_chars =
---buffer.punctuation_chars =
-
--- Tabs and Indentation Guides.
--- Note: tab and indentation settings apply to individual buffers.
-buffer.tab_width = 2
-buffer.use_tabs = false
---buffer.indent = 2
-buffer.tab_indents = true
-buffer.back_space_un_indents = true
-buffer.indentation_guides = not CURSES and buffer.IV_LOOKBOTH or buffer.IV_NONE
-
--- Margin Markers.
-buffer:marker_define(textadept.bookmarks.MARK_BOOKMARK, buffer.MARK_FULLRECT)
-buffer:marker_define(textadept.run.MARK_WARNING, buffer.MARK_FULLRECT)
-buffer:marker_define(textadept.run.MARK_ERROR, buffer.MARK_FULLRECT)
--- Arrow Folding Symbols.
---buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_ARROWDOWN)
---buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_ARROW)
---buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDEREND, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_EMPTY)
--- Plus/Minus Folding Symbols.
---buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_MINUS)
---buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_PLUS)
---buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDEREND, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID, buffer.MARK_EMPTY)
---buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_EMPTY)
--- Circle Tree Folding Symbols.
---buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_CIRCLEMINUS)
---buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_CIRCLEPLUS)
---buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_VLINE)
---buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_LCORNERCURVE)
---buffer:marker_define(buffer.MARKNUM_FOLDEREND,
--- buffer.MARK_CIRCLEPLUSCONNECTED)
---buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID,
--- buffer.MARK_CIRCLEMINUSCONNECTED)
---buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_TCORNERCURVE)
--- Box Tree Folding Symbols.
-buffer:marker_define(buffer.MARKNUM_FOLDEROPEN, buffer.MARK_BOXMINUS)
-buffer:marker_define(buffer.MARKNUM_FOLDER, buffer.MARK_BOXPLUS)
-buffer:marker_define(buffer.MARKNUM_FOLDERSUB, buffer.MARK_VLINE)
-buffer:marker_define(buffer.MARKNUM_FOLDERTAIL, buffer.MARK_LCORNER)
-buffer:marker_define(buffer.MARKNUM_FOLDEREND, buffer.MARK_BOXPLUSCONNECTED)
-buffer:marker_define(buffer.MARKNUM_FOLDEROPENMID,
- buffer.MARK_BOXMINUSCONNECTED)
-buffer:marker_define(buffer.MARKNUM_FOLDERMIDTAIL, buffer.MARK_TCORNER)
---buffer:marker_enable_highlight(true)
-
--- Indicators.
-buffer.indic_style[ui.find.INDIC_FIND] = buffer.INDIC_ROUNDBOX
-if not CURSES then buffer.indic_under[ui.find.INDIC_FIND] = true end
-local INDIC_BRACEMATCH = textadept.editing.INDIC_BRACEMATCH
-buffer.indic_style[INDIC_BRACEMATCH] = buffer.INDIC_BOX
-buffer:brace_highlight_indicator(not CURSES, INDIC_BRACEMATCH)
-local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT
-buffer.indic_style[INDIC_HIGHLIGHT] = buffer.INDIC_ROUNDBOX
-if not CURSES then buffer.indic_under[INDIC_HIGHLIGHT] = true end
-local INDIC_PLACEHOLDER = textadept.snippets.INDIC_PLACEHOLDER
-buffer.indic_style[INDIC_PLACEHOLDER] = not CURSES and buffer.INDIC_DOTBOX or
- buffer.INDIC_STRAIGHTBOX
-
--- Autocompletion.
---buffer.auto_c_separator =
---buffer.auto_c_cancel_at_start = false
---buffer.auto_c_fill_ups = '('
-buffer.auto_c_choose_single = true
---buffer.auto_c_ignore_case = true
---buffer.auto_c_case_insensitive_behaviour =
--- buffer.CASEINSENSITIVEBEHAVIOUR_IGNORECASE
-buffer.auto_c_multi = buffer.MULTIAUTOC_EACH
---buffer.auto_c_auto_hide = false
---buffer.auto_c_drop_rest_of_word = true
---buffer.auto_c_type_separator =
---buffer.auto_c_max_height =
---buffer.auto_c_max_width =
-
--- Call Tips.
-buffer.call_tip_use_style = buffer.tab_width *
- buffer:text_width(buffer.STYLE_CALLTIP, ' ')
---buffer.call_tip_position = true
-
--- Folding.
-buffer.property['fold'] = '1'
---buffer.property['fold.by.indentation'] = '1'
---buffer.property['fold.line.comments'] = '1'
---buffer.property['fold.on.zero.sum.lines'] = '1'
-buffer.automatic_fold = buffer.AUTOMATICFOLD_SHOW + buffer.AUTOMATICFOLD_CLICK +
- buffer.AUTOMATICFOLD_CHANGE
-buffer.fold_flags = not CURSES and buffer.FOLDFLAG_LINEAFTER_CONTRACTED or 0
-buffer.fold_display_text_style = buffer.FOLDDISPLAYTEXT_BOXED
-
--- Line Wrapping.
-buffer.wrap_mode = buffer.WRAP_NONE
---buffer.wrap_visual_flags = buffer.WRAPVISUALFLAG_MARGIN
---buffer.wrap_visual_flags_location = buffer.WRAPVISUALFLAGLOC_END_BY_TEXT
---buffer.wrap_indent_mode = buffer.WRAPINDENT_SAME
---buffer.wrap_start_indent =
-
--- Long Lines.
---if buffer ~= ui.command_entry then
--- buffer.edge_mode = not CURSES and buffer.EDGE_LINE or buffer.EDGE_BACKGROUND
--- buffer.edge_column = 80
---end
-
--- Accessibility.
-buffer.accessibility = buffer.ACCESSIBILITY_DISABLED
diff --git a/src/Makefile b/src/Makefile
index e28f375a..6b99bcb7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -69,6 +69,8 @@ else
LDFLAGS += -ldl
MAKE = make
else
+ CC=cc
+ CXX=c++
LDFLAGS += -liconv
MAKE = gmake
endif
@@ -270,14 +272,14 @@ textadeptjit-curses.exe: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \
# Install/uninstall.
install: $(install_targets) | ../core ../doc ../init.lua ../lexers ../LICENSE \
- ../modules ../properties.lua ../themes
+ ../modules ../themes
install -d $(DESTDIR)$(bin_dir) $(DESTDIR)$(data_dir)
install $^ $(DESTDIR)$(data_dir)
cp -r $| $(DESTDIR)$(data_dir)
ln -s $(subst .., $(data_dir), $^) $(DESTDIR)$(bin_dir)
if [ -d "$(XDG_DATA_DIR)" ]; then \
install -d $(DESTDIR)$(XDG_DATA_DIR); \
- install -t $(DESTDIR)$(XDG_DATA_DIR) $(desktop_files); \
+ install $(desktop_files) $(DESTDIR)$(XDG_DATA_DIR); \
fi
if [ -d "$(PIXMAPS_DIR)" ]; then \
install -d $(DESTDIR)$(PIXMAPS_DIR); \
@@ -534,7 +536,7 @@ clean-deps:
# Count lines of code and generate ctags.
sources = ../core ../modules/ansi_c ../modules/lua ../modules/textadept \
- ../themes textadept.c Makefile ../init.lua ../properties.lua
+ ../themes textadept.c Makefile ../init.lua
count: $(cloc) ; perl $< $(sources) --not-match-f=tadoc.lua
ctags:
ctags -R --langdef=luax --langmap=luax:.lua --exclude="*doc*" \
diff --git a/src/textadept.c b/src/textadept.c
index 73fd9591..9b16bf9d 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -1521,10 +1521,10 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
lua_setfield(L, LUA_REGISTRYINDEX, "ta_arg");
lua_newtable(L), lua_setfield(L, LUA_REGISTRYINDEX, "ta_buffers");
lua_newtable(L), lua_setfield(L, LUA_REGISTRYINDEX, "ta_views");
- } else { // clear package.loaded and _G
- lua_getglobal(L, "package"), lua_getfield(L, -1, "loaded");
+ } else { // clear _LOADED and _G
+ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
lL_cleartable(L, lua_gettop(L));
- lua_pop(L, 2); // package.loaded and package
+ lua_pop(L, 1); // _LOADED
#if LUA_VERSION_NUM >= 502
lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
lL_cleartable(L, lua_gettop(L));