From dbef5c3fa8ca9f842f75a6db1f0aa0fb029a4be6 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Mon, 16 Sep 2013 20:49:23 -0400 Subject: Moved custom markers and indicators into themes and added more properties. --- modules/textadept/bookmarks.lua | 7 --- modules/textadept/editing.lua | 16 ++----- modules/textadept/run.lua | 7 --- properties.lua | 94 ++++++++++++++++++++++++++++++++--------- themes/dark.lua | 25 +++++++---- themes/light.lua | 21 ++++++--- themes/term.lua | 9 ++++ 7 files changed, 119 insertions(+), 60 deletions(-) diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua index b6fc39d5..c70983a1 100644 --- a/modules/textadept/bookmarks.lua +++ b/modules/textadept/bookmarks.lua @@ -66,11 +66,4 @@ function M.goto_mark(next) end end -local CURSES_MARK = buffer.SC_MARK_CHARACTER + string.byte(' ') --- Sets view properties for bookmark markers. -events.connect(events.VIEW_NEW, function() - if CURSES then buffer:marker_define(M.MARK_BOOKMARK, CURSES_MARK) end - buffer.marker_back[M.MARK_BOOKMARK] = not CURSES and 0xB3661A or 0x800000 -end) - return M diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 143d07f5..8f6d93a2 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -167,10 +167,7 @@ events.connect(events.FILE_BEFORE_SAVE, function() local s, e = buffer:position_from_line(line), line_end_position[line] local i, c = e - 1, char_at[e - 1] while i >= s and c == 9 or c == 32 do i, c = i - 1, char_at[i - 1] end - if i < e - 1 then - buffer.target_start, buffer.target_end = i + 1, e - buffer:replace_target('') - end + if i < e - 1 then buffer:delete_range(i + 1, e - i - 1) end end -- Ensure ending newline. local e = buffer:position_from_line(lines) @@ -309,7 +306,8 @@ function M.block_comment(comment) end --- --- Goes to line number *line* or the user-specified line in the buffer. +-- Moves the caret to the beginning of line number *line* or the user-specified +-- line, ensuring the line is visible. -- @param line Optional line number to go to. If `nil`, the user is prompted for -- one. -- @name goto_line @@ -501,14 +499,6 @@ function M.highlight_word() buffer:set_sel(s, e) end --- Sets view properties for highlighted word indicators and markers. -events.connect(events.VIEW_NEW, function() - buffer.indic_fore[M.INDIC_HIGHLIGHT] = not CURSES and 0x4D99E6 or 0x008080 - buffer.indic_style[M.INDIC_HIGHLIGHT] = buffer.INDIC_ROUNDBOX - buffer.indic_alpha[M.INDIC_HIGHLIGHT] = 255 - if not CURSES then buffer.indic_under[M.INDIC_HIGHLIGHT] = true end -end) - --- -- Passes selected or all buffer text to string shell command *command* as -- standard input (stdin) and replaces the input text with the command's diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index 87e292c4..fd3be697 100644 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -241,11 +241,4 @@ events.connect(events.DOUBLE_CLICK, function(pos, line) if is_msg_buf(buffer) then M.goto_error(line) end end) -local CURSES_MARK = buffer.SC_MARK_CHARACTER + string.byte(' ') --- Sets view properties for error markers. -events.connect(events.VIEW_NEW, function() - if CURSES then buffer:marker_define(M.MARK_ERROR, CURSES_MARK) end - buffer.marker_back[M.MARK_ERROR] = not CURSES and 0x8080CC or 0x000080 -end) - return M diff --git a/properties.lua b/properties.lua index 88fef5ca..9d47ff0d 100644 --- a/properties.lua +++ b/properties.lua @@ -14,12 +14,12 @@ buffer.rectangular_selection_modifier = (WIN32 or OSX) and buffer.SCMOD_ALT or --buffer.additional_carets_visible = false -- Scrolling. -buffer:set_x_caret_policy(1, 20) -- CARET_SLOP -buffer:set_y_caret_policy(13, 1) -- CARET_SLOP | CARET_STRICT | CARET_EVEN +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.h_scroll_bar = false --buffer.v_scroll_bar = false ---buffer.x_offset = --buffer.scroll_width = --buffer.scroll_width_tracking = true --buffer.end_at_last_line = false @@ -36,25 +36,27 @@ buffer:set_y_caret_policy(13, 1) -- CARET_SLOP | CARET_STRICT | CARET_EVEN -- Caret and Selection Styles. --buffer.sel_eol_filled = true buffer.caret_line_visible = not CURSES ---buffer.caret_line_visible_always = true +buffer.caret_line_visible_always = true --buffer.caret_period = 0 --buffer.caret_style = buffer.CARETSTYLE_BLOCK --buffer.caret_width = --buffer.caret_sticky = buffer.SC_CARETSTICKY_ON +-- Margins. +--buffer.margin_left = +--buffer.margin_right = -- Line Number Margin. 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 0 or 1 - +buffer.margin_width_n[1] = not CURSES and 12 or 1 +buffer.margin_sensitive_n[1] = true +buffer.margin_cursor_n[1] = buffer.SC_CURSORARROW -- Fold Margin. -buffer.margin_width_n[2] = not CURSES and 10 or 1 +buffer.margin_width_n[2] = not CURSES and 12 or 1 buffer.margin_mask_n[2] = buffer.SC_MASK_FOLDERS buffer.margin_sensitive_n[2] = true ---buffer.margin_left = ---buffer.margin_right = +buffer.margin_cursor_n[2] = buffer.SC_CURSORARROW -- Annotations. buffer.annotation_visible = buffer.ANNOTATION_BOXED @@ -62,6 +64,9 @@ buffer.annotation_visible = buffer.ANNOTATION_BOXED -- Other. buffer.buffered_draw = not CURSES and not OSX -- Quartz buffers drawing on OSX --buffer.two_phase_draw = false +--buffer.word_chars = +--buffer.whitespace_chars = +--buffer.punctuation_chars = -- Tabs and Indentation Guides. -- Note: tab and indentation settings apply to individual buffers. @@ -72,36 +77,85 @@ buffer.tab_indents = true buffer.back_space_un_indents = true buffer.indentation_guides = buffer.SC_IV_LOOKBOTH --- Fold Margin Markers. +-- Margin Markers. +local symbol = not CURSES and buffer.SC_MARK_SMALLRECT or + buffer.SC_MARK_CHARACTER + string.byte(' ') +buffer:marker_define(textadept.bookmarks.MARK_BOOKMARK, symbol) +buffer:marker_define(textadept.run.MARK_ERROR, symbol) if not CURSES then - buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPEN, buffer.SC_MARK_ARROWDOWN) - buffer:marker_define(buffer.SC_MARKNUM_FOLDER, buffer.SC_MARK_ARROW) - buffer:marker_define(buffer.SC_MARKNUM_FOLDERSUB, buffer.SC_MARK_EMPTY) - buffer:marker_define(buffer.SC_MARKNUM_FOLDERTAIL, buffer.SC_MARK_EMPTY) - buffer:marker_define(buffer.SC_MARKNUM_FOLDEREND, buffer.SC_MARK_EMPTY) - buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPENMID, buffer.SC_MARK_EMPTY) - buffer:marker_define(buffer.SC_MARKNUM_FOLDERMIDTAIL, buffer.SC_MARK_EMPTY) + -- Arrow Folding Symbols. +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPEN, buffer.SC_MARK_ARROWDOWN) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDER, buffer.SC_MARK_ARROW) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERSUB, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERTAIL, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEREND, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPENMID, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERMIDTAIL, buffer.SC_MARK_EMPTY) + -- Plus/Minus Folding Symbols. +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPEN, buffer.SC_MARK_MINUS) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDER, buffer.SC_MARK_PLUS) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERSUB, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERTAIL, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEREND, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPENMID, buffer.SC_MARK_EMPTY) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERMIDTAIL, buffer.SC_MARK_EMPTY) + -- Circle Tree Folding Symbols. +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPEN, +-- buffer.SC_MARK_CIRCLEMINUS) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDER, buffer.SC_MARK_CIRCLEPLUS) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERSUB, buffer.SC_MARK_VLINE) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERTAIL, +-- buffer.SC_MARK_LCORNERCURVE) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEREND, +-- buffer.SC_MARK_CIRCLEPLUSCONNECTED) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPENMID, +-- buffer.SC_MARK_CIRCLEMINUSCONNECTED) +-- buffer:marker_define(buffer.SC_MARKNUM_FOLDERMIDTAIL, +-- buffer.SC_MARK_TCORNERCURVE) + -- Box Tree Folding Symbols. + buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPEN, buffer.SC_MARK_BOXMINUS) + buffer:marker_define(buffer.SC_MARKNUM_FOLDER, buffer.SC_MARK_BOXPLUS) + buffer:marker_define(buffer.SC_MARKNUM_FOLDERSUB, buffer.SC_MARK_VLINE) + buffer:marker_define(buffer.SC_MARKNUM_FOLDERTAIL, buffer.SC_MARK_LCORNER) + buffer:marker_define(buffer.SC_MARKNUM_FOLDEREND, + buffer.SC_MARK_BOXPLUSCONNECTED) + buffer:marker_define(buffer.SC_MARKNUM_FOLDEROPENMID, + buffer.SC_MARK_BOXMINUSCONNECTED) + buffer:marker_define(buffer.SC_MARKNUM_FOLDERMIDTAIL, buffer.SC_MARK_TCORNER) +end +--buffer:marker_enable_highlight(true) + +-- Indicators. +buffer.indic_style[textadept.editing.INDIC_HIGHLIGHT] = buffer.INDIC_ROUNDBOX +if not CURSES then + buffer.indic_under[textadept.editing.INDIC_HIGHLIGHT] = true end -- Autocompletion. --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.SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE --buffer.auto_c_auto_hide = false +--buffer.auto_c_drop_rest_of_word = true --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.by.indentation'] = '0' buffer.property['fold.line.comments'] = '0' -buffer.fold_flags = not CURSES and buffer.SC_FOLDFLAG_LINEAFTER_CONTRACTED or 0 buffer.automatic_fold = buffer.SC_AUTOMATICFOLD_SHOW + buffer.SC_AUTOMATICFOLD_CLICK + buffer.SC_AUTOMATICFOLD_CHANGE +buffer.fold_flags = not CURSES and buffer.SC_FOLDFLAG_LINEAFTER_CONTRACTED or 0 -- Line Wrapping. --buffer.wrap_mode = buffer.SC_WRAP_WORD diff --git a/themes/dark.lua b/themes/dark.lua index a446e9b6..6db08dfc 100644 --- a/themes/dark.lua +++ b/themes/dark.lua @@ -27,7 +27,7 @@ property['color.dark_white'] = 0xCCCCCC --property['color.dark_orange'] = 0x1A66B3 --property['color.dark_pink'] = 0x6666B3 --property['color.dark_lavender'] = 0xB36666 ---property['color.dark_blue'] = 0xB3661A +property['color.dark_blue'] = 0xB3661A -- Normal colors. property['color.red'] = 0x4D4D99 @@ -106,13 +106,22 @@ buffer.caret_line_back = property_int['color.light_black'] buffer:set_fold_margin_colour(true, property_int['color.black']) buffer:set_fold_margin_hi_colour(true, property_int['color.black']) --- Fold Margin Markers. -buffer.marker_fore[buffer.SC_MARKNUM_FOLDEROPEN] = - property_int['color.dark_grey'] -buffer.marker_back[buffer.SC_MARKNUM_FOLDEROPEN] = - property_int['color.dark_grey'] -buffer.marker_fore[buffer.SC_MARKNUM_FOLDER] = property_int['color.dark_grey'] -buffer.marker_back[buffer.SC_MARKNUM_FOLDER] = property_int['color.dark_grey'] +-- Markers. +local MARK_BOOKMARK = textadept.bookmarks.MARK_BOOKMARK +buffer.marker_fore[MARK_BOOKMARK] = property_int['color.black'] +buffer.marker_back[MARK_BOOKMARK] = property_int['color.dark_blue'] +buffer.marker_fore[textadept.run.MARK_ERROR] = property_int['color.black'] +buffer.marker_back[textadept.run.MARK_ERROR] = property_int['color.red'] +for i = 25, 31 do -- fold margin markers + buffer.marker_fore[i] = property_int['color.black'] + buffer.marker_back[i] = property_int['color.dark_grey'] + buffer.marker_back_selected[i] = property_int['color.light_grey'] +end + +-- Indicators. +local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT +buffer.indic_fore[INDIC_HIGHLIGHT] = property_int['color.orange'] +buffer.indic_alpha[INDIC_HIGHLIGHT] = 255 -- Long Lines. buffer.edge_colour = property_int['color.dark_grey'] diff --git a/themes/light.lua b/themes/light.lua index dc6daf1c..5b7baca0 100644 --- a/themes/light.lua +++ b/themes/light.lua @@ -106,11 +106,22 @@ buffer.caret_line_back = property_int['color.dark_white'] buffer:set_fold_margin_colour(true, property_int['color.white']) buffer:set_fold_margin_hi_colour(true, property_int['color.white']) --- Fold Margin Markers. -buffer.marker_fore[buffer.SC_MARKNUM_FOLDEROPEN] = property_int['color.grey'] -buffer.marker_back[buffer.SC_MARKNUM_FOLDEROPEN] = property_int['color.grey'] -buffer.marker_fore[buffer.SC_MARKNUM_FOLDER] = property_int['color.grey'] -buffer.marker_back[buffer.SC_MARKNUM_FOLDER] = property_int['color.grey'] +-- Markers. +local MARK_BOOKMARK = textadept.bookmarks.MARK_BOOKMARK +buffer.marker_fore[MARK_BOOKMARK] = property_int['color.white'] +buffer.marker_back[MARK_BOOKMARK] = property_int['color.dark_blue'] +buffer.marker_fore[textadept.run.MARK_ERROR] = property_int['color.white'] +buffer.marker_back[textadept.run.MARK_ERROR] = property_int['color.light_red'] +for i = 25, 31 do -- fold margin markers + buffer.marker_fore[i] = property_int['color.white'] + buffer.marker_back[i] = property_int['color.grey'] + buffer.marker_back_selected[i] = property_int['color.grey_black'] +end + +-- Indicators. +local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT +buffer.indic_fore[INDIC_HIGHLIGHT] = property_int['color.orange'] +buffer.indic_alpha[INDIC_HIGHLIGHT] = 255 -- Long Lines. buffer.edge_colour = property_int['color.grey'] diff --git a/themes/term.lua b/themes/term.lua index 9f530723..bccd2686 100644 --- a/themes/term.lua +++ b/themes/term.lua @@ -73,5 +73,14 @@ property['style.whitespace'] = '' --buffer:set_fold_margin_colour(true, property_int['color.white']) --buffer:set_fold_margin_hi_colour(true, property_int['color.white']) +-- Markers. +local MARK_BOOKMARK = textadept.bookmarks.MARK_BOOKMARK +buffer.marker_back[MARK_BOOKMARK] = property_int['color.blue'] +buffer.marker_back[textadept.run.MARK_ERROR] = property_int['color.red'] + +-- Indicators. +local INDIC_HIGHLIGHT = textadept.editing.INDIC_HIGHLIGHT +buffer.indic_fore[INDIC_HIGHLIGHT] = property_int['color.yellow'] + -- Long Lines. buffer.edge_colour = property_int['color.white'] -- cgit v1.2.3