martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.2k stars 258 forks source link

Add a theming option for dimmed text #970

Closed hyphenrf closed 7 months ago

hyphenrf commented 2 years ago

This small patch adds a new theming keyword: [not]dim, and equips vis to handle it in both the curses backend and the hand rolled vt-100 backend

rnpnr commented 7 months ago

Applied in f1abd79.

sansfontieres commented 7 months ago

I get this funny outcome since this commit.

image

EDIT: I see, it seems to take the colour of vis.lexers.STYLE_LINENUMBER_CURSOR

rnpnr commented 7 months ago

I get this funny outcome since this commit.

EDIT: I see, it seems to take the colour of vis.lexers.STYLE_LINENUMBER_CURSOR

Hi, can you please send the rest of your theme file? I suspect that this will be fixed #1154

sansfontieres commented 7 months ago

Sure! Here is the table and the event that defines my theme (a bit messy, sorry):

local colors = {
  bg_0 = "#fdfdfc",
  bg_1 = "#ebebeb",
  bg_2 = "#cccccc",
  md_0 = "#858585",
  md_1 = "#5c5c5c",
  fg_0 = "#3d3d3d",
  fg_1 = "#2a2a2a",
  red = "#d11100",
  green = "#309900",
  yellow = "#c79800",
  blue = "#0063db",
  magenta = "#d4008d",
  cyan = "#00b8a5",
  bred = "#b80f00",
  bgreen = "#218f00",
  byellow = "#b38900",
  bblue = "#0059d2",
  bmagenta = "#b8007a",
  bcyan = "#009485",
  mblue = "#587ae2",
  gold = "#846d21",
  specials = "#fed200",
  orange = "#db6600",
  selection = "#e2e3fa"
}

vis.events.subscribe(vis.events.INIT, function()
  vis:command('set escdelay 0')
  vis:command("set autoindent on")
  vis:command("set ignorecase")
  vis_tmux_pane = os.getenv("TMUX_PANE")

  local lexers = vis.lexers
  lexers.STYLE_DEFAULT = "fore:" .. colors.fg_1
  lexers.STYLE_NOTHING = "back:" .. colors.bg_0
  lexers.STYLE_CLASS = "bold"

  -- Dimmed not current line
  -- Dimmed current line
  lexers.STYLE_COMMENT = "fore" .. colors.fg_1 .. ",italics,dim"

  lexers.STYLE_CONSTANT = "italics"
  lexers.STYLE_DEFINITION = "fore:" .. colors.orange
  lexers.STYLE_ERROR = "fore:" .. colors.red .. ",italics"
  lexers.STYLE_FUNCTION = "bold"
  lexers.STYLE_KEYWORD = "bold,italics"
  lexers.STYLE_LABEL = "fore:" .. colors.green
  lexers.STYLE_NUMBER = "fore:" .. colors.md_0
  lexers.STYLE_OPERATOR = "fore:" .. colors.md_0
  lexers.STYLE_REGEX = "fore:" .. colors.magenta
  lexers.STYLE_STRING = "fore:" .. colors.green
  lexers.STYLE_PREPROCESSOR = "fore:" .. colors.md_0
  lexers.STYLE_TAG = "fore:" .. colors.fg_0
  lexers.STYLE_TYPE = "bold"
  lexers.STYLE_VARIABLE = "fore:" .. colors.blue
  lexers.STYLE_WHITESPACE = ""
  lexers.STYLE_EMBEDDED = "back:" .. colors.bg_1 .. ",fore:" .. colors.gold
  lexers.STYLE_IDENTIFIER = "fore:" .. colors.fg_1
  lexers.STYLE_LINENUMBER = "fore:" .. colors.bg_2
  lexers.STYLE_LINENUMBER_CURSOR = "fore:" .. colors.md_1 .. ",back:" ..
                                       colors.specials
  lexers.STYLE_CURSOR = "back:" .. colors.specials
  lexers.STYLE_CURSOR_PRIMARY = "fore:" .. colors.bg_0 .. ",back:" ..
                                    colors.orange
  lexers.STYLE_CURSOR_LINE = lexers.STYLE_DEFAULT
  lexers.STYLE_COLOR_COLUMN = "back:" .. colors.bg_1 .. ",fore:" .. colors.red
  lexers.STYLE_SELECTION = "back:" .. colors.selection
  lexers.STYLE_STATUS = "back:" .. colors.bg_2 .. ",fore:" .. colors.md_0
  lexers.STYLE_STATUS_FOCUSED = "back:" .. colors.bg_2 .. ",fore:" ..
                                    colors.bmagenta
  lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
  lexers.STYLE_INFO = "fore:default,back:default,bold"
end)
rnpnr commented 7 months ago

Sure!

Hmm, I'm not able to recreate on master or with #1154. I did find a slightly different bug in #1154 though. This is possibly related to tmux (which I see you were using in this example). Can you open a proper issue an include information such as the terminal you are using, if this appears only in tmux, tmux version, output of vis -v, etc. Also if possible can you test with #1154 applied and see if the issue persists.

Thanks!

sansfontieres commented 7 months ago

Looks like it appears on iTerm2, but not on Terminal.app.

Can you open a proper issue an include information such as the terminal you are using [...] test with #1154 applied and see if the issue persists.

Sure, I’ll try to gather what I can during this week 🤠