orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
636 stars 38 forks source link

V12 Beta - view.caret_line_layer = view.LAYER_UNDER_TEXT seems to overrides view.ELEMENT_SELECTION_BACK #420

Closed merlindiavova closed 1 year ago

merlindiavova commented 1 year ago

Hi,

When I set view.caret_line_layer = view.LAYER_UNDER_TEXT in my theme, it seems to override the view.ELEMENT_SELECTION_BACK with view.ELEMENT_CARET_LINE_BACK for the current line only.

I can highlight all other lines however the line that has the caret and a selection just shows the view.ELEMENT_CARET_LINE_BACK color not view.ELEMENT_SELECTION_BACK.

Any ideas?

Please see my theme below

local view, colors, styles = view, view.colors, view.styles

colors.bg_main          = 0xf0f7fb -- #fbf7f0
colors.bg_dim           = 0xdbe7ed -- #ede7db
colors.fg_main          = 0x000000
colors.bg_line          = 0xd0d5f1 -- #f1d5d0
colors.bg_selection     = 0xcfc1f0 -- #f0c1cf
colors.bg_selection_inactive = 0xcfd9df -- #dfd9cf
colors.border = colors.bg_dim

-- Common accent foregrounds

colors.white           = 0xFFFFFF
colors.red             = 0x0000a6 -- #a60000
colors.green           = 0x006800 -- #006800
colors.yellow          = 0x00556f -- #6f5500
colors.blue            = 0xa93000 -- #0031a9
colors.magenta         = 0x441072 -- #721045
colors.cyan            = 0x8b5f00 -- #005e8b

-- Default font.
if not font then font = WIN32 and 'Consolas' or OSX and 'Monaco' or 'Monospace' end
if not size then size = not OSX and 10 or 12 end

-- The default style all others are based on.
styles[view.STYLE_DEFAULT] = {
  font = font, size = size, fore = colors.fg_main, back = colors.bg_main
}

-- The line number margin style.
styles[view.STYLE_LINENUMBER] = { fore = colors.fg_main, back = colors.bg_dim }

-- The style of control character blocks.
-- styles[view.STYLE_CONTROLCHAR] = {}

-- This style sets the foreground and background colours used when drawing the indentation guides.
styles[view.STYLE_INDENTGUIDE] = { fore = colors.bg_dim }

-- The style of call tip text. Only the font, size, fore, and back style definition fields are supported.
styles[view.STYLE_CALLTIP] = { fore = colors.fg_main, back = colors.bg_dim }

-- This is the style used for drawing text tags attached to folded text.
--styles[view.STYLE_FOLDDISPLAYTEXT] = { fore = colors.fg_main, back = colors.bg_dim }

--  The main selection’s text color.
--view.element_color[view.ELEMENT_SELECTION_TEXT] = colors.fg_main

-- The main selection’s background color.
view.element_color[view.ELEMENT_SELECTION_BACK] = colors.bg_selection

-- [Linux only] The text color of selections when another window contains the primary selection.
--view.element_color[view.ELEMENT_SELECTION_SECONDARY_TEXT] = colors.fg_main

-- [Linux only] The background color of selections when another window contains the primary selection.
view.element_color[view.ELEMENT_SELECTION_SECONDARY_BACK] = colors.bg_selection

-- The text color of selections when another window has focus.
--view.element_color[view.ELEMENT_SELECTION_INACTIVE_TEXT] = colors.fg_main

-- The background color of selections when another window has focus.
view.element_color[view.ELEMENT_SELECTION_INACTIVE_BACK] = colors.bg_selection_inactive

-- The main selection’s caret color.
view.element_color[view.ELEMENT_CARET] = colors.red

-- The caret color of additional selections.
--view.element_color[view.ELEMENT_CARET_ADDITIONAL] = colors.red

-- The background color of the line that contains the caret.
if view ~= ui.command_entry then
  view.element_color[view.ELEMENT_CARET_LINE_BACK] = colors.bg_line
end

-- The line caret’s pixel width in insert mode, between 0 and 20. The default value is 1.
view.caret_width = 2

-- The caret line layer mode.
-- [view.LAYER_UNDER_TEXT] Draw the caret line translucently under text.
view.caret_line_layer = view.LAYER_UNDER_TEXT -- <--- Problem seems to go away when I comment this line out.

-- The color of fold lines.
view.element_color[view.ELEMENT_FOLD_LINE] = colors.bg_line

-- Fold Margin.
view:set_fold_margin_color(true, colors.bg_main)
view:set_fold_margin_hi_color(true, colors.bg_main)

-- Markers.
-- view.marker_fore[textadept.bookmarks.MARK_BOOKMARK] = colors.white
view.marker_back[textadept.bookmarks.MARK_BOOKMARK] = colors.blue
-- view.marker_fore[textadept.run.MARK_WARNING] = colors.white
view.marker_back[textadept.run.MARK_WARNING] = colors.yellow
-- view.marker_fore[textadept.run.MARK_ERROR] = colors.white
view.marker_back[textadept.run.MARK_ERROR] = colors.red
for i = view.MARKNUM_FOLDEREND, view.MARKNUM_FOLDEROPEN do -- fold margin
    view.marker_fore[i] = colors.bg_main
    view.marker_back[i] = colors.bg_line
    --view.marker_back_selected[i] = colors.selection
end

-- Long Lines.
view.edge_color = colors.border

-- Call tips.
--view.call_tip_fore_hlt = colors.blue

-- Find & replace pane entries.
ui.find.entry_font = font .. ' ' .. size
orbitalquark commented 1 year ago

Your view.element_color[view.ELEMENT_CARET_LINE_BACK] is not a translucent color. I think Scintilla (Textadept's editing component) draws selections first and then the caret line, so with an opaque caret line, it's overwriting the selection background.

I was able to see the selection background using this:

  view.element_color[view.ELEMENT_CARET_LINE_BACK] = colors.bg_line | 0x60000000

Tweak the alpha byte to something that suits you.

merlindiavova commented 1 year ago

@orbitalquark Thanks!