Make FaceRegistry scoped

set-face now takes a scope argument, and faces can be overridden on
a buffer or window basis.

colorscheme apply on global scope, which should be good enough for
now.

Fixes #1411
This commit is contained in:
Maxime Coste 2018-04-07 15:36:39 +10:00
parent 6adb28ec12
commit 57baad4afd
36 changed files with 760 additions and 667 deletions

View File

@ -18,56 +18,56 @@
## code ## code
echo " echo "
face value ${orange_dark}+b face global value ${orange_dark}+b
face type ${orange_light} face global type ${orange_light}
face variable ${magenta_dark} face global variable ${magenta_dark}
face module ${green_dark} face global module ${green_dark}
face function ${cyan_light} face global function ${cyan_light}
face string ${green_dark} face global string ${green_dark}
face keyword ${purple_dark}+b face global keyword ${purple_dark}+b
face operator ${cyan_light} face global operator ${cyan_light}
face attribute ${orange_dark} face global attribute ${orange_dark}
face comment ${grey_dark} face global comment ${grey_dark}
face meta ${orange_light} face global meta ${orange_light}
face builtin default+b face global builtin default+b
" "
## markup ## markup
echo " echo "
face title blue face global title blue
face header ${cyan_light} face global header ${cyan_light}
face bold ${orange_light} face global bold ${orange_light}
face italic ${orange_dark} face global italic ${orange_dark}
face mono ${green_dark} face global mono ${green_dark}
face block ${orange_dark} face global block ${orange_dark}
face link blue face global link blue
face bullet ${magenta_light} face global bullet ${magenta_light}
face list ${magenta_dark} face global list ${magenta_dark}
" "
## builtin ## builtin
echo " echo "
face Default ${grey_light},${black_lighter} face global Default ${grey_light},${black_lighter}
face PrimarySelection white,blue face global PrimarySelection white,blue
face SecondarySelection black,blue face global SecondarySelection black,blue
face PrimaryCursor black,white face global PrimaryCursor black,white
face SecondaryCursor black,white face global SecondaryCursor black,white
face PrimaryCursorEol black,${cyan_light} face global PrimaryCursorEol black,${cyan_light}
face SecondaryCursorEol black,${cyan_light} face global SecondaryCursorEol black,${cyan_light}
face LineNumbers ${grey_light},${black_lighter} face global LineNumbers ${grey_light},${black_lighter}
face LineNumberCursor ${grey_light},rgb:282828+b face global LineNumberCursor ${grey_light},rgb:282828+b
face MenuForeground ${grey_light},blue face global MenuForeground ${grey_light},blue
face MenuBackground blue,${grey_light} face global MenuBackground blue,${grey_light}
face MenuInfo ${cyan_light} face global MenuInfo ${cyan_light}
face Information ${black_light},${cyan_light} face global Information ${black_light},${cyan_light}
face Error ${grey_light},${magenta_light} face global Error ${grey_light},${magenta_light}
face StatusLine ${grey_light},${black_lighterer} face global StatusLine ${grey_light},${black_lighterer}
face StatusLineMode ${orange_dark} face global StatusLineMode ${orange_dark}
face StatusLineInfo ${cyan_light} face global StatusLineInfo ${cyan_light}
face StatusLineValue ${green_dark} face global StatusLineValue ${green_dark}
face StatusCursor ${black_lighterer},${cyan_light} face global StatusCursor ${black_lighterer},${cyan_light}
face Prompt ${black_light},${cyan_light} face global Prompt ${black_light},${cyan_light}
face MatchingChar ${cyan_light},${black_light}+b face global MatchingChar ${cyan_light},${black_light}+b
face BufferPadding ${cyan_light},${black_lighter} face global BufferPadding ${cyan_light},${black_lighter}
" "
} }

View File

@ -1,50 +1,50 @@
# Kakoune default color scheme # Kakoune default color scheme
# For Code # For Code
face value red face global value red
face type yellow face global type yellow
face variable green face global variable green
face module green face global module green
face function cyan face global function cyan
face string magenta face global string magenta
face keyword blue face global keyword blue
face operator yellow face global operator yellow
face attribute green face global attribute green
face comment cyan face global comment cyan
face meta magenta face global meta magenta
face builtin default+b face global builtin default+b
# For markup # For markup
face title blue face global title blue
face header cyan face global header cyan
face bold red face global bold red
face italic yellow face global italic yellow
face mono green face global mono green
face block magenta face global block magenta
face link cyan face global link cyan
face bullet cyan face global bullet cyan
face list yellow face global list yellow
# builtin faces # builtin faces
face Default default,default face global Default default,default
face PrimarySelection white,blue face global PrimarySelection white,blue
face SecondarySelection black,blue face global SecondarySelection black,blue
face PrimaryCursor black,white face global PrimaryCursor black,white
face SecondaryCursor black,white face global SecondaryCursor black,white
face PrimaryCursorEol black,cyan face global PrimaryCursorEol black,cyan
face SecondaryCursorEol black,cyan face global SecondaryCursorEol black,cyan
face LineNumbers default,default face global LineNumbers default,default
face LineNumberCursor default,default+r face global LineNumberCursor default,default+r
face MenuForeground white,blue face global MenuForeground white,blue
face MenuBackground blue,white face global MenuBackground blue,white
face MenuInfo cyan face global MenuInfo cyan
face Information black,yellow face global Information black,yellow
face Error black,red face global Error black,red
face StatusLine cyan,default face global StatusLine cyan,default
face StatusLineMode yellow,default face global StatusLineMode yellow,default
face StatusLineInfo blue,default face global StatusLineInfo blue,default
face StatusLineValue green,default face global StatusLineValue green,default
face StatusCursor black,cyan face global StatusCursor black,cyan
face Prompt yellow,default face global Prompt yellow,default
face MatchingChar default,default+b face global MatchingChar default,default+b
face BufferPadding blue,default face global BufferPadding blue,default

View File

@ -1,79 +1,79 @@
# desertex theme # desertex theme
# Code # Code
face value rgb:fa8072 face global value rgb:fa8072
face type rgb:dfdfbf face global type rgb:dfdfbf
face identifier rgb:87ceeb face global identifier rgb:87ceeb
face string rgb:fa8072 face global string rgb:fa8072
face error rgb:c3bf9f+b face global error rgb:c3bf9f+b
face keyword rgb:eedc82 face global keyword rgb:eedc82
face operator rgb:87ceeb face global operator rgb:87ceeb
face attribute rgb:eedc82 face global attribute rgb:eedc82
face comment rgb:7ccd7c+i face global comment rgb:7ccd7c+i
# #include <...> # #include <...>
face meta rgb:ee799f face global meta rgb:ee799f
# Markup # Markup
face title blue face global title blue
face header cyan face global header cyan
face bold red face global bold red
face italic yellow face global italic yellow
face mono green face global mono green
face block magenta face global block magenta
face link cyan face global link cyan
face bullet cyan face global bullet cyan
face list yellow face global list yellow
# Builtin # Builtin
# fg,bg+attributes # fg,bg+attributes
# face Default default,rgb:262626 <- change the terminal bg color instead # face global Default default,rgb:262626 <- change the terminal bg color instead
face Default default,default face global Default default,default
face PrimarySelection white,blue face global PrimarySelection white,blue
face SecondarySelection black,blue face global SecondarySelection black,blue
face PrimaryCursor black,white face global PrimaryCursor black,white
face SecondaryCursor black,white face global SecondaryCursor black,white
face PrimaryCursorEol black,rgb:7ccd7c face global PrimaryCursorEol black,rgb:7ccd7c
face SecondaryCursorEol black,rgb:7ccd7c face global SecondaryCursorEol black,rgb:7ccd7c
face LineNumbers rgb:605958 face global LineNumbers rgb:605958
face LineNumberCursor yellow,default+b face global LineNumberCursor yellow,default+b
# Bottom menu: # Bottom menu:
# text + background # text + background
face MenuBackground black,rgb:c2bfa5+b face global MenuBackground black,rgb:c2bfa5+b
# selected entry in the menu (use 302028 when true color support is fixed) # selected entry in the menu (use 302028 when true color support is fixed)
face MenuForeground rgb:f0a0c0,magenta face global MenuForeground rgb:f0a0c0,magenta
# completion menu info # completion menu info
face MenuInfo white,rgb:445599 face global MenuInfo white,rgb:445599
# assistant, [+] # assistant, [+]
face Information black,yellow face global Information black,yellow
face Error white,red face global Error white,red
face StatusLine cyan,default face global StatusLine cyan,default
# Status line modes and prompts: # Status line modes and prompts:
# insert, prompt, enter key... # insert, prompt, enter key...
face StatusLineMode rgb:ffd75f,default face global StatusLineMode rgb:ffd75f,default
# 1 sel # 1 sel
face StatusLineInfo blue,default face global StatusLineInfo blue,default
# param=value, reg=value. ex: "ey # param=value, reg=value. ex: "ey
face StatusLineValue green,default face global StatusLineValue green,default
face StatusCursor black,cyan face global StatusCursor black,cyan
# : # :
face Prompt blue face global Prompt blue
# (), {} # (), {}
face MatchingChar cyan+b face global MatchingChar cyan+b
# EOF tildas (~) # EOF tildas (~)
face BufferPadding blue,default face global BufferPadding blue,default

View File

@ -4,47 +4,47 @@
## ##
## code ## code
face value rgb:0086B3+b face global value rgb:0086B3+b
face type rgb:795DA3 face global type rgb:795DA3
face variable rgb:0086B3 face global variable rgb:0086B3
face module rgb:0086B3 face global module rgb:0086B3
face function rgb:A71D5D face global function rgb:A71D5D
face string rgb:183691 face global string rgb:183691
face keyword rgb:A71D5D+b face global keyword rgb:A71D5D+b
face operator yellow face global operator yellow
face attribute rgb:A71D5D face global attribute rgb:A71D5D
face comment rgb:AAAAAA face global comment rgb:AAAAAA
face meta rgb:183691 face global meta rgb:183691
face builtin default+b face global builtin default+b
## markup ## markup
face title blue face global title blue
face header cyan face global header cyan
face bold red face global bold red
face italic yellow face global italic yellow
face mono green face global mono green
face block magenta face global block magenta
face link cyan face global link cyan
face bullet cyan face global bullet cyan
face list yellow face global list yellow
## builtin ## builtin
face Default rgb:121213,rgb:F8F8FF face global Default rgb:121213,rgb:F8F8FF
face PrimarySelection default,rgb:A6F3A6 face global PrimarySelection default,rgb:A6F3A6
face SecondarySelection default,rgb:DBFFDB face global SecondarySelection default,rgb:DBFFDB
face PrimaryCursor black,rgb:888888 face global PrimaryCursor black,rgb:888888
face SecondaryCursor black,rgb:888888 face global SecondaryCursor black,rgb:888888
face PrimaryCursorEol black,rgb:A71D5D face global PrimaryCursorEol black,rgb:A71D5D
face SecondaryCursorEol black,rgb:A71D5D face global SecondaryCursorEol black,rgb:A71D5D
face LineNumbers rgb:A0A0A0,rgb:ECECEC face global LineNumbers rgb:A0A0A0,rgb:ECECEC
face LineNumberCursor rgb:434343,rgb:DDDDDD face global LineNumberCursor rgb:434343,rgb:DDDDDD
face MenuForeground rgb:434343,rgb:CDCDFD face global MenuForeground rgb:434343,rgb:CDCDFD
face MenuBackground rgb:F8F8FF,rgb:808080 face global MenuBackground rgb:F8F8FF,rgb:808080
face Information rgb:F8F8FF,rgb:4078C0 face global Information rgb:F8F8FF,rgb:4078C0
face Error rgb:F8F8FF,rgb:BD2C00 face global Error rgb:F8F8FF,rgb:BD2C00
face StatusLine rgb:434343,rgb:DDDDDD face global StatusLine rgb:434343,rgb:DDDDDD
face StatusCursor rgb:434343,rgb:CDCDFD face global StatusCursor rgb:434343,rgb:CDCDFD
face Prompt rgb:F8F8FF,rgb:4078C0 face global Prompt rgb:F8F8FF,rgb:4078C0
face MatchingChar rgb:F8F8FF,rgb:4078C0+b face global MatchingChar rgb:F8F8FF,rgb:4078C0+b
face Search default,default+u face global Search default,default+u
face BufferPadding rgb:A0A0A0,rgb:F8F8FF face global BufferPadding rgb:A0A0A0,rgb:F8F8FF

View File

@ -24,52 +24,52 @@
echo " echo "
# Code highlighting # Code highlighting
face value ${purple} face global value ${purple}
face type ${yellow} face global type ${yellow}
face variable ${blue} face global variable ${blue}
face module ${green} face global module ${green}
face function default face global function default
face string ${green} face global string ${green}
face keyword ${red} face global keyword ${red}
face operator default face global operator default
face attribute ${orange} face global attribute ${orange}
face comment ${gray} face global comment ${gray}
face meta ${aqua} face global meta ${aqua}
face builtin default+b face global builtin default+b
# Markdown highlighting # Markdown highlighting
face title ${green}+b face global title ${green}+b
face header ${orange} face global header ${orange}
face bold ${fg}+b face global bold ${fg}+b
face italic ${fg3} face global italic ${fg3}
face mono ${fg4} face global mono ${fg4}
face block default face global block default
face link default face global link default
face bullet default face global bullet default
face list default face global list default
face Default ${fg},${bg} face global Default ${fg},${bg}
face PrimarySelection ${fg},${blue} face global PrimarySelection ${fg},${blue}
face SecondarySelection ${bg},${blue} face global SecondarySelection ${bg},${blue}
face PrimaryCursor ${bg},${fg} face global PrimaryCursor ${bg},${fg}
face SecondaryCursor ${bg},${fg} face global SecondaryCursor ${bg},${fg}
face PrimaryCursorEol ${bg},${fg4} face global PrimaryCursorEol ${bg},${fg4}
face SecondaryCursorEol ${bg},${fg4} face global SecondaryCursorEol ${bg},${fg4}
face LineNumbers ${bg4} face global LineNumbers ${bg4}
face LineNumberCursor ${yellow},${bg1} face global LineNumberCursor ${yellow},${bg1}
face MenuForeground ${bg2},${blue} face global MenuForeground ${bg2},${blue}
face MenuBackground default,${bg2} face global MenuBackground default,${bg2}
face MenuInfo ${bg} face global MenuInfo ${bg}
face Information ${bg},${fg} face global Information ${bg},${fg}
face Error default,${red} face global Error default,${red}
face StatusLine default face global StatusLine default
face StatusLineMode ${yellow}+b face global StatusLineMode ${yellow}+b
face StatusLineInfo ${purple} face global StatusLineInfo ${purple}
face StatusLineValue ${red} face global StatusLineValue ${red}
face StatusCursor ${bg},${fg} face global StatusCursor ${bg},${fg}
face Prompt ${yellow} face global Prompt ${yellow}
face MatchingChar default+b face global MatchingChar default+b
face BufferPadding ${bg2},${bg} face global BufferPadding ${bg2},${bg}
face Whitespace ${bg2} face global Whitespace ${bg2}
" "
} }

View File

@ -24,52 +24,52 @@
echo " echo "
# then we map them to code # then we map them to code
face value ${lucius_light_green} face global value ${lucius_light_green}
face type ${lucius_blue} face global type ${lucius_blue}
face variable ${lucius_green} face global variable ${lucius_green}
face module ${lucius_green} face global module ${lucius_green}
face function ${lucius_light_blue} face global function ${lucius_light_blue}
face string ${lucius_light_green} face global string ${lucius_light_green}
face keyword ${lucius_light_blue} face global keyword ${lucius_light_blue}
face operator ${lucius_green} face global operator ${lucius_green}
face attribute ${lucius_light_blue} face global attribute ${lucius_light_blue}
face comment ${lucius_grey} face global comment ${lucius_grey}
face meta ${lucius_purple} face global meta ${lucius_purple}
face builtin default+b face global builtin default+b
# and markup # and markup
face title ${lucius_light_blue} face global title ${lucius_light_blue}
face header ${lucius_light_green} face global header ${lucius_light_green}
face bold ${lucius_blue} face global bold ${lucius_blue}
face italic ${lucius_green} face global italic ${lucius_green}
face mono ${lucius_light_green} face global mono ${lucius_light_green}
face block ${lucius_light_blue} face global block ${lucius_light_blue}
face link ${lucius_light_green} face global link ${lucius_light_green}
face bullet ${lucius_green} face global bullet ${lucius_green}
face list ${lucius_blue} face global list ${lucius_blue}
# and built in faces # and built in faces
face Default ${lucius_lighter_grey},${lucius_darker_grey} face global Default ${lucius_lighter_grey},${lucius_darker_grey}
face PrimarySelection ${lucius_darker_grey},${lucius_orange} face global PrimarySelection ${lucius_darker_grey},${lucius_orange}
face SecondarySelection ${lucius_lighter_grey},${lucius_dark_blue} face global SecondarySelection ${lucius_lighter_grey},${lucius_dark_blue}
face PrimaryCursor ${lucius_darker_grey},${lucius_lighter_grey} face global PrimaryCursor ${lucius_darker_grey},${lucius_lighter_grey}
face SecondaryCursor ${lucius_darker_grey},${lucius_lighter_grey} face global SecondaryCursor ${lucius_darker_grey},${lucius_lighter_grey}
face PrimaryCursorEol ${lucius_darker_grey},${lucius_dark_green} face global PrimaryCursorEol ${lucius_darker_grey},${lucius_dark_green}
face SecondaryCursorEol ${lucius_darker_grey},${lucius_dark_green} face global SecondaryCursorEol ${lucius_darker_grey},${lucius_dark_green}
face LineNumbers ${lucius_grey},${lucius_dark_grey} face global LineNumbers ${lucius_grey},${lucius_dark_grey}
face LineNumberCursor ${lucius_grey},${lucius_dark_grey}+b face global LineNumberCursor ${lucius_grey},${lucius_dark_grey}+b
face MenuForeground ${lucius_blue},${lucius_dark_blue} face global MenuForeground ${lucius_blue},${lucius_dark_blue}
face MenuBackground ${lucius_darker_grey},${lucius_light_grey} face global MenuBackground ${lucius_darker_grey},${lucius_light_grey}
face MenuInfo ${lucius_grey} face global MenuInfo ${lucius_grey}
face Information ${lucius_lighter_grey},${lucius_dark_green} face global Information ${lucius_lighter_grey},${lucius_dark_green}
face Error ${lucius_light_red},${lucius_dark_red} face global Error ${lucius_light_red},${lucius_dark_red}
face StatusLine ${lucius_lighter_grey},${lucius_dark_grey} face global StatusLine ${lucius_lighter_grey},${lucius_dark_grey}
face StatusLineMode ${lucius_lighter_grey},${lucius_dark_green}+b face global StatusLineMode ${lucius_lighter_grey},${lucius_dark_green}+b
face StatusLineInfo ${lucius_dark_grey},${lucius_lighter_grey} face global StatusLineInfo ${lucius_dark_grey},${lucius_lighter_grey}
face StatusLineValue ${lucius_lighter_grey} face global StatusLineValue ${lucius_lighter_grey}
face StatusCursor default,${lucius_blue} face global StatusCursor default,${lucius_blue}
face Prompt ${lucius_lighter_grey} face global Prompt ${lucius_lighter_grey}
face MatchingChar ${lucius_lighter_grey},${lucius_bright_green} face global MatchingChar ${lucius_lighter_grey},${lucius_bright_green}
face BufferPadding ${lucius_green},${lucius_darker_grey} face global BufferPadding ${lucius_green},${lucius_darker_grey}
" "
} }

View File

@ -22,52 +22,52 @@
# Base color definitions # Base color definitions
echo " echo "
# then we map them to code # then we map them to code
face value ${orange_light}+b face global value ${orange_light}+b
face type ${orange} face global type ${orange}
face variable default face global variable default
face module ${green} face global module ${green}
face function default face global function default
face string ${green} face global string ${green}
face keyword ${brown_dark} face global keyword ${brown_dark}
face operator default face global operator default
face attribute ${green} face global attribute ${green}
face comment ${brown_light} face global comment ${brown_light}
face meta ${brown_dark} face global meta ${brown_dark}
face builtin default+b face global builtin default+b
# and markup # and markup
face title ${orange}+b face global title ${orange}+b
face header ${orange}+b face global header ${orange}+b
face bold default+b face global bold default+b
face italic default+i face global italic default+i
face mono ${green_light} face global mono ${green_light}
face block ${green} face global block ${green}
face link ${orange} face global link ${orange}
face bullet ${brown_dark} face global bullet ${brown_dark}
face list ${black} face global list ${black}
# and built in faces # and built in faces
face Default ${black_light},${white} face global Default ${black_light},${white}
face PrimarySelection ${black},${brown_lighter} face global PrimarySelection ${black},${brown_lighter}
face SecondarySelection ${black_light},${grey_light} face global SecondarySelection ${black_light},${grey_light}
face PrimaryCursor ${black},${grey_dark} face global PrimaryCursor ${black},${grey_dark}
face SecondaryCursor ${black},${grey_dark} face global SecondaryCursor ${black},${grey_dark}
face PrimaryCursorEol ${black},${brown_dark} face global PrimaryCursorEol ${black},${brown_dark}
face SecondaryCursorEol ${black},${brown_dark} face global SecondaryCursorEol ${black},${brown_dark}
face LineNumbers ${grey_dark},${white} face global LineNumbers ${grey_dark},${white}
face LineNumberCursor ${grey_dark},${brown_lighter} face global LineNumberCursor ${grey_dark},${brown_lighter}
face MenuForeground ${orange},${brown_lighter} face global MenuForeground ${orange},${brown_lighter}
face MenuBackground ${black_light},${brown_lighter} face global MenuBackground ${black_light},${brown_lighter}
face MenuInfo default,${black} face global MenuInfo default,${black}
face Information ${black_light},${brown_lighter} face global Information ${black_light},${brown_lighter}
face Error default,${red} face global Error default,${red}
face StatusLine ${black},${grey_light} face global StatusLine ${black},${grey_light}
face StatusLineMode ${orange} face global StatusLineMode ${orange}
face StatusLineInfo ${black}+b face global StatusLineInfo ${black}+b
face StatusLineValue ${green_light} face global StatusLineValue ${green_light}
face StatusCursor ${orange},${white_light} face global StatusCursor ${orange},${white_light}
face Prompt ${black_light} face global Prompt ${black_light}
face MatchingChar default+b face global MatchingChar default+b
face BufferPadding ${grey_dark},${white} face global BufferPadding ${grey_dark},${white}
" "
} }

View File

@ -20,53 +20,53 @@
echo " echo "
# code # code
face value ${cyan} face global value ${cyan}
face type ${yellow} face global type ${yellow}
face variable ${blue} face global variable ${blue}
face module ${cyan} face global module ${cyan}
face function ${blue} face global function ${blue}
face string ${cyan} face global string ${cyan}
face keyword ${green} face global keyword ${green}
face operator ${green} face global operator ${green}
face attribute ${violet} face global attribute ${violet}
face comment ${base01} face global comment ${base01}
face meta ${orange} face global meta ${orange}
face builtin default+b face global builtin default+b
# markup # markup
face title ${blue}+b face global title ${blue}+b
face header ${blue} face global header ${blue}
face bold ${base0}+b face global bold ${base0}+b
face italic ${base0}+i face global italic ${base0}+i
face mono ${base1} face global mono ${base1}
face block ${cyan} face global block ${cyan}
face link ${base1} face global link ${base1}
face bullet ${yellow} face global bullet ${yellow}
face list ${green} face global list ${green}
# builtin # builtin
face Default ${base0},${base03} face global Default ${base0},${base03}
face PrimarySelection ${base03},${blue} face global PrimarySelection ${base03},${blue}
face SecondarySelection ${base01},${base1} face global SecondarySelection ${base01},${base1}
face PrimaryCursor ${base03},${base0} face global PrimaryCursor ${base03},${base0}
face SecondaryCursor ${base03},${base01} face global SecondaryCursor ${base03},${base01}
face PrimaryCursorEol ${base03},${base2} face global PrimaryCursorEol ${base03},${base2}
face SecondaryCursorEol ${base03},${base3} face global SecondaryCursorEol ${base03},${base3}
face LineNumbers ${base01},${base02} face global LineNumbers ${base01},${base02}
face LineNumberCursor ${base1},${base02} face global LineNumberCursor ${base1},${base02}
face LineNumbersWrapped ${base02},${base02} face global LineNumbersWrapped ${base02},${base02}
face MenuForeground ${base03},${yellow} face global MenuForeground ${base03},${yellow}
face MenuBackground ${base1},${base02} face global MenuBackground ${base1},${base02}
face MenuInfo ${base01} face global MenuInfo ${base01}
face Information ${base02},${base1} face global Information ${base02},${base1}
face Error ${red},default+b face global Error ${red},default+b
face StatusLine ${base1},${base02}+b face global StatusLine ${base1},${base02}+b
face StatusLineMode ${orange} face global StatusLineMode ${orange}
face StatusLineInfo ${cyan} face global StatusLineInfo ${cyan}
face StatusLineValue ${green} face global StatusLineValue ${green}
face StatusCursor ${base00},${base3} face global StatusCursor ${base00},${base3}
face Prompt ${yellow}+b face global Prompt ${yellow}+b
face MatchingChar ${red},${base01}+b face global MatchingChar ${red},${base01}+b
face BufferPadding ${base01},${base03} face global BufferPadding ${base01},${base03}
" "
} }

View File

@ -20,53 +20,53 @@
echo " echo "
# code # code
face value ${cyan} face global value ${cyan}
face type ${yellow} face global type ${yellow}
face variable ${blue} face global variable ${blue}
face module ${cyan} face global module ${cyan}
face function ${blue} face global function ${blue}
face string ${cyan} face global string ${cyan}
face keyword ${green} face global keyword ${green}
face operator ${green} face global operator ${green}
face attribute ${violet} face global attribute ${violet}
face comment ${base1} face global comment ${base1}
face meta ${orange} face global meta ${orange}
face builtin default+b face global builtin default+b
# markup # markup
face title ${blue}+b face global title ${blue}+b
face header ${blue} face global header ${blue}
face bold ${base01}+b face global bold ${base01}+b
face italic ${base01}+i face global italic ${base01}+i
face mono ${base1} face global mono ${base1}
face block ${cyan} face global block ${cyan}
face link ${base01} face global link ${base01}
face bullet ${yellow} face global bullet ${yellow}
face list ${green} face global list ${green}
# builtin # builtin
face Default ${base00},${base3} face global Default ${base00},${base3}
face PrimarySelection ${base3},${blue} face global PrimarySelection ${base3},${blue}
face SecondarySelection ${base1},${base01} face global SecondarySelection ${base1},${base01}
face PrimaryCursor ${base3},${base00} face global PrimaryCursor ${base3},${base00}
face SecondaryCursor ${base3},${base1} face global SecondaryCursor ${base3},${base1}
face PrimaryCursorEol ${base3},${yellow} face global PrimaryCursorEol ${base3},${yellow}
face SecondaryCursorEol ${base3},${orange} face global SecondaryCursorEol ${base3},${orange}
face LineNumbers ${base1},${base2} face global LineNumbers ${base1},${base2}
face LineNumberCursor ${base01},${base2} face global LineNumberCursor ${base01},${base2}
face LineNumbersWrapped ${base2},${base2} face global LineNumbersWrapped ${base2},${base2}
face MenuForeground ${base3},${yellow} face global MenuForeground ${base3},${yellow}
face MenuBackground ${base01},${base2} face global MenuBackground ${base01},${base2}
face MenuInfo ${base1} face global MenuInfo ${base1}
face Information ${base2},${base1} face global Information ${base2},${base1}
face Error ${red},default+b face global Error ${red},default+b
face StatusLine ${base01},${base2}+b face global StatusLine ${base01},${base2}+b
face StatusLineMode ${orange} face global StatusLineMode ${orange}
face StatusLineInfo ${cyan} face global StatusLineInfo ${cyan}
face StatusLineValue ${green} face global StatusLineValue ${green}
face StatusCursor ${base0},${base03} face global StatusCursor ${base0},${base03}
face Prompt ${yellow}+b face global Prompt ${yellow}+b
face MatchingChar ${red},${base2}+b face global MatchingChar ${red},${base2}+b
face BufferPadding ${base1},${base3} face global BufferPadding ${base1},${base3}
" "
} }

View File

@ -23,56 +23,56 @@
## code ## code
echo " echo "
face value ${orange} face global value ${orange}
face type ${yellow} face global type ${yellow}
face variable ${magenta} face global variable ${magenta}
face module ${green} face global module ${green}
face function ${aqua} face global function ${aqua}
face string ${green_dark} face global string ${green_dark}
face keyword ${purple} face global keyword ${purple}
face operator ${aqua} face global operator ${aqua}
face attribute ${purple} face global attribute ${purple}
face comment ${comment} face global comment ${comment}
face meta ${purple} face global meta ${purple}
face builtin ${orange} face global builtin ${orange}
" "
## markup ## markup
echo " echo "
face title blue face global title blue
face header ${aqua} face global header ${aqua}
face bold ${yellow} face global bold ${yellow}
face italic ${orange} face global italic ${orange}
face mono ${green_dark} face global mono ${green_dark}
face block ${orange} face global block ${orange}
face link blue face global link blue
face bullet ${red} face global bullet ${red}
face list ${red} face global list ${red}
" "
## builtin ## builtin
echo " echo "
face Default ${text},${background} face global Default ${text},${background}
face PrimarySelection default,${selection} face global PrimarySelection default,${selection}
face SecondarySelection default,${selection} face global SecondarySelection default,${selection}
face PrimaryCursor black,${aqua} face global PrimaryCursor black,${aqua}
face SecondaryCursor black,${aqua} face global SecondaryCursor black,${aqua}
face PrimaryCursorEol black,${green_dark} face global PrimaryCursorEol black,${green_dark}
face SecondaryCursorEol black,${green_dark} face global SecondaryCursorEol black,${green_dark}
face LineNumbers ${text_light},${background} face global LineNumbers ${text_light},${background}
face LineNumberCursor ${yellow},rgb:282828+b face global LineNumberCursor ${yellow},rgb:282828+b
face MenuForeground ${text_light},blue face global MenuForeground ${text_light},blue
face MenuBackground ${aqua},${window} face global MenuBackground ${aqua},${window}
face MenuInfo ${aqua} face global MenuInfo ${aqua}
face Information white,${window} face global Information white,${window}
face Error white,${red} face global Error white,${red}
face StatusLine ${text},${window} face global StatusLine ${text},${window}
face StatusLineMode ${yellow}+b face global StatusLineMode ${yellow}+b
face StatusLineInfo ${aqua} face global StatusLineInfo ${aqua}
face StatusLineValue ${green_dark} face global StatusLineValue ${green_dark}
face StatusCursor ${window},${aqua} face global StatusCursor ${window},${aqua}
face Prompt ${background},${aqua} face global Prompt ${background},${aqua}
face MatchingChar ${yellow},${background}+b face global MatchingChar ${yellow},${background}+b
face BufferPadding ${aqua},${background} face global BufferPadding ${aqua},${background}
" "
} }

View File

@ -31,52 +31,52 @@
echo " echo "
# then we map them to code # then we map them to code
face value ${zenconstant} face global value ${zenconstant}
face type ${zentype} face global type ${zentype}
face variable ${zenvariable} face global variable ${zenvariable}
face module ${zenstring} face global module ${zenstring}
face function ${zenfunction} face global function ${zenfunction}
face string ${zenstring} face global string ${zenstring}
face keyword ${zenkeyword} face global keyword ${zenkeyword}
face operator ${zenfunction} face global operator ${zenfunction}
face attribute ${zenstatement} face global attribute ${zenstatement}
face comment ${zencomment} face global comment ${zencomment}
face meta ${zenspecial} face global meta ${zenspecial}
face builtin default+b face global builtin default+b
# and markup # and markup
face title ${zenkeyword} face global title ${zenkeyword}
face header ${zenconstant} face global header ${zenconstant}
face bold ${zenstorageClass} face global bold ${zenstorageClass}
face italic ${zenfunction} face global italic ${zenfunction}
face mono ${zennumber} face global mono ${zennumber}
face block ${zenstatement} face global block ${zenstatement}
face link ${zenstring} face global link ${zenstring}
face bullet ${zenvariable} face global bullet ${zenvariable}
face list ${zentype} face global list ${zentype}
# and built in faces # and built in faces
face Default ${zendefault} face global Default ${zendefault}
face PrimarySelection ${zentext},${zenselectionbg} face global PrimarySelection ${zentext},${zenselectionbg}
face SecondarySelection ${zensecondaryfg},${zenselectionbg} face global SecondarySelection ${zensecondaryfg},${zenselectionbg}
face PrimaryCursor ${zencursor} face global PrimaryCursor ${zencursor}
face SecondaryCursor ${zencursor} face global SecondaryCursor ${zencursor}
face PrimaryCursorEol ${zencursoreol} face global PrimaryCursorEol ${zencursoreol}
face SecondaryCursorEol ${zencursoreol} face global SecondaryCursorEol ${zencursoreol}
face LineNumbers ${zendefault} face global LineNumbers ${zendefault}
face LineNumberCursor ${zenstatus} face global LineNumberCursor ${zenstatus}
face MenuForeground ${zenmenufg} face global MenuForeground ${zenmenufg}
face MenuBackground ${zenmenubg} face global MenuBackground ${zenmenubg}
face MenuInfo rgb:cc9393 face global MenuInfo rgb:cc9393
face Information ${zeninfo} face global Information ${zeninfo}
face Error default,red face global Error default,red
face StatusLine ${zenstatus} face global StatusLine ${zenstatus}
face StatusLineMode ${zencomment} face global StatusLineMode ${zencomment}
face StatusLineInfo ${zenspecial} face global StatusLineInfo ${zenspecial}
face StatusLineValue ${zennumber} face global StatusLineValue ${zennumber}
face StatusCursor ${zenstatuscursor} face global StatusCursor ${zenstatuscursor}
face Prompt ${zenconstant} face global Prompt ${zenconstant}
face MatchingChar default+b face global MatchingChar default+b
face BufferPadding ${zenpadding} face global BufferPadding ${zenpadding}
" "
} }

View File

@ -161,9 +161,12 @@ command *q!* has to be used). Aliases are mentionned below each commands.
*-debug*::: *-debug*:::
print the given text to the *\*debug** buffer print the given text to the *\*debug** buffer
*set-face* <name> <facespec>:: *set-face* <scope> <name> <facespec>::
*alias* face + *alias* face +
define a face (See <<faces#,`:doc faces`>>) define a face in *scope* (See <<faces#,`:doc faces`>>)
*unset-face* <scope> <name>::
Remove a face definition from *scope* (See <<faces#,`:doc faces`>>)
*colorscheme* <name>:: *colorscheme* <name>::
load named colorscheme load named colorscheme

View File

@ -4,7 +4,7 @@
# Faces # Faces
# ‾‾‾‾‾ # ‾‾‾‾‾
set-face MercurialCommitComment cyan set-face global MercurialCommitComment cyan
# Detection # Detection
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾

View File

@ -30,8 +30,8 @@ add-highlighter shared/ regions -default code kakrc \
buffer buffer-next buffer-previous delete-buffer add-highlighter remove-highlighter buffer buffer-next buffer-previous delete-buffer add-highlighter remove-highlighter
hook remove-hooks define-command echo debug source try fail hook remove-hooks define-command echo debug source try fail
set-option unset-option update-option declare-option execute-keys evaluate-commands set-option unset-option update-option declare-option execute-keys evaluate-commands
prompt menu on-key info set-face rename-client set-register select change-directory prompt menu on-key info set-face unset-face rename-client set-register select
rename-session colorscheme declare-user-mode enter-user-mode" change-directory rename-session colorscheme declare-user-mode enter-user-mode"
attributes="global buffer window current attributes="global buffer window current
normal insert menu prompt goto view user object normal insert menu prompt goto view user object
number_lines show_matching show_whitespaces fill regex dynregex group flag_lines number_lines show_matching show_whitespaces fill regex dynregex group flag_lines

View File

@ -20,8 +20,8 @@ hook -group git-status-highlight global WinSetOption filetype=(?!git-status).* %
declare-option -hidden line-specs git_blame_flags declare-option -hidden line-specs git_blame_flags
declare-option -hidden line-specs git_diff_flags declare-option -hidden line-specs git_diff_flags
set-face GitBlame default,magenta set-face global GitBlame default,magenta
set-face GitDiffFlags default,black set-face global GitDiffFlags default,black
define-command -params 1.. \ define-command -params 1.. \
-docstring %sh{printf '%%{git [<arguments>]: git wrapping helper -docstring %sh{printf '%%{git [<arguments>]: git wrapping helper

View File

@ -33,7 +33,7 @@ public:
private: private:
friend class Scope; friend class Scope;
AliasRegistry() {} AliasRegistry() = default;
SafePtr<AliasRegistry> m_parent; SafePtr<AliasRegistry> m_parent;
using AliasMap = HashMap<String, String, MemoryDomain::Aliases>; using AliasMap = HashMap<String, String, MemoryDomain::Aliases>;

View File

@ -96,7 +96,8 @@ bool Client::process_pending_inputs()
catch (Kakoune::runtime_error& error) catch (Kakoune::runtime_error& error)
{ {
write_to_debug_buffer(format("Error: {}", error.what())); write_to_debug_buffer(format("Error: {}", error.what()));
context().print_status({ fix_atom_text(error.what().str()), get_face("Error") }); context().print_status({ fix_atom_text(error.what().str()),
context().faces()["Error"] });
context().hooks().run_hook("RuntimeError", error.what(), context()); context().hooks().run_hook("RuntimeError", error.what(), context());
} }
} }
@ -142,15 +143,16 @@ DisplayLine Client::generate_mode_line() const
{ {
const String& modelinefmt = context().options()["modelinefmt"].get<String>(); const String& modelinefmt = context().options()["modelinefmt"].get<String>();
HashMap<String, DisplayLine> atoms{{ "mode_info", context().client().input_handler().mode_line() }, HashMap<String, DisplayLine> atoms{{ "mode_info", context().client().input_handler().mode_line() },
{ "context_info", {generate_context_info(context()), get_face("Information")}}}; { "context_info", {generate_context_info(context()),
context().faces()["Information"]}}};
auto expanded = expand(modelinefmt, context(), ShellContext{}, auto expanded = expand(modelinefmt, context(), ShellContext{},
[](String s) { return escape(s, '{', '\\'); }); [](String s) { return escape(s, '{', '\\'); });
modeline = parse_display_line(expanded, atoms); modeline = parse_display_line(expanded, context().faces(), atoms);
} }
catch (runtime_error& err) catch (runtime_error& err)
{ {
write_to_debug_buffer(format("Error while parsing modelinefmt: {}", err.what())); write_to_debug_buffer(format("Error while parsing modelinefmt: {}", err.what()));
modeline.push_back({ "modelinefmt error, see *debug* buffer", get_face("Error") }); modeline.push_back({ "modelinefmt error, see *debug* buffer", context().faces()["Error"] });
} }
return modeline; return modeline;
@ -207,9 +209,11 @@ void Client::redraw_ifn()
if (m_ui_pending == 0) if (m_ui_pending == 0)
return; return;
auto& faces = context().faces();
if (m_ui_pending & Draw) if (m_ui_pending & Draw)
m_ui->draw(window.update_display_buffer(context()), m_ui->draw(window.update_display_buffer(context()),
get_face("Default"), get_face("BufferPadding")); faces["Default"], faces["BufferPadding"]);
const bool update_menu_anchor = (m_ui_pending & Draw) and not (m_ui_pending & MenuHide) and const bool update_menu_anchor = (m_ui_pending & Draw) and not (m_ui_pending & MenuHide) and
not m_menu.items.empty() and m_menu.style == MenuStyle::Inline; not m_menu.items.empty() and m_menu.style == MenuStyle::Inline;
@ -224,7 +228,7 @@ void Client::redraw_ifn()
if (m_ui_pending & MenuShow and m_menu.ui_anchor) if (m_ui_pending & MenuShow and m_menu.ui_anchor)
m_ui->menu_show(m_menu.items, *m_menu.ui_anchor, m_ui->menu_show(m_menu.items, *m_menu.ui_anchor,
get_face("MenuForeground"), get_face("MenuBackground"), faces["MenuForeground"], faces["MenuBackground"],
m_menu.style); m_menu.style);
if (m_ui_pending & MenuSelect and m_menu.ui_anchor) if (m_ui_pending & MenuSelect and m_menu.ui_anchor)
m_ui->menu_select(m_menu.selected); m_ui->menu_select(m_menu.selected);
@ -244,12 +248,12 @@ void Client::redraw_ifn()
if (m_ui_pending & InfoShow and m_info.ui_anchor) if (m_ui_pending & InfoShow and m_info.ui_anchor)
m_ui->info_show(m_info.title, m_info.content, *m_info.ui_anchor, m_ui->info_show(m_info.title, m_info.content, *m_info.ui_anchor,
get_face("Information"), m_info.style); faces["Information"], m_info.style);
if (m_ui_pending & InfoHide) if (m_ui_pending & InfoHide)
m_ui->info_hide(); m_ui->info_hide();
if (m_ui_pending & StatusLine) if (m_ui_pending & StatusLine)
m_ui->draw_status(m_status_line, m_mode_line, get_face("StatusLine")); m_ui->draw_status(m_status_line, m_mode_line, faces["StatusLine"]);
auto cursor = m_input_handler.get_cursor_info(); auto cursor = m_input_handler.get_cursor_info();
m_ui->set_cursor(cursor.first, cursor.second); m_ui->set_cursor(cursor.first, cursor.second);
@ -272,12 +276,12 @@ void Client::reload_buffer()
{ {
reload_file_buffer(buffer); reload_file_buffer(buffer);
context().print_status({ format("'{}' reloaded", buffer.display_name()), context().print_status({ format("'{}' reloaded", buffer.display_name()),
get_face("Information") }); context().faces()["Information"] });
} }
catch (runtime_error& error) catch (runtime_error& error)
{ {
context().print_status({ format("error while reloading buffer: '{}'", error.what()), context().print_status({ format("error while reloading buffer: '{}'", error.what()),
get_face("Error") }); context().faces()["Error"] });
buffer.set_fs_timestamp(get_fs_timestamp(buffer.name())); buffer.set_fs_timestamp(get_fs_timestamp(buffer.name()));
} }
} }
@ -305,14 +309,14 @@ void Client::on_buffer_reload_key(Key key)
// reread timestamp in case the file was modified again // reread timestamp in case the file was modified again
buffer.set_fs_timestamp(get_fs_timestamp(buffer.name())); buffer.set_fs_timestamp(get_fs_timestamp(buffer.name()));
print_status({ format("'{}' kept", buffer.display_name()), print_status({ format("'{}' kept", buffer.display_name()),
get_face("Information") }); context().faces()["Information"] });
if (key == 'N') if (key == 'N')
set_autoreload(Autoreload::No); set_autoreload(Autoreload::No);
} }
else else
{ {
print_status({ format("'{}' is not a valid choice", key_to_str(key)), print_status({ format("'{}' is not a valid choice", key_to_str(key)),
get_face("Error") }); context().faces()["Error"] });
m_input_handler.on_next_key(KeymapMode::None, [this](Key key, Context&){ on_buffer_reload_key(key); }); m_input_handler.on_next_key(KeymapMode::None, [this](Key key, Context&){ on_buffer_reload_key(key); });
return; return;
} }

View File

@ -65,7 +65,8 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui, int pi
} }
catch (Kakoune::runtime_error& error) catch (Kakoune::runtime_error& error)
{ {
client->context().print_status({ fix_atom_text(error.what().str()), get_face("Error") }); client->context().print_status({ fix_atom_text(error.what().str()),
client->context().faces()["Error"] });
client->context().hooks().run_hook("RuntimeError", error.what(), client->context().hooks().run_hook("RuntimeError", error.what(),
client->context()); client->context());
} }

View File

@ -249,7 +249,7 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&)
: open_or_create_file_buffer(name, flags); : open_or_create_file_buffer(name, flags);
if (buffer->flags() & Buffer::Flags::New) if (buffer->flags() & Buffer::Flags::New)
context.print_status({ format("new file '{}'", name), context.print_status({ format("new file '{}'", name),
get_face("StatusLine") }); context.faces()["StatusLine"] });
} }
buffer->flags() &= ~Buffer::Flags::NoHooks; buffer->flags() &= ~Buffer::Flags::NoHooks;
@ -1102,9 +1102,9 @@ const CommandDesc echo_cmd = {
if (parser.get_switch("debug")) if (parser.get_switch("debug"))
write_to_debug_buffer(message); write_to_debug_buffer(message);
else if (parser.get_switch("markup")) else if (parser.get_switch("markup"))
context.print_status(parse_display_line(message)); context.print_status(parse_display_line(message, context.faces()));
else else
context.print_status({ std::move(message), get_face("StatusLine") }); context.print_status({ std::move(message), context.faces()["StatusLine"] });
} }
}; };
@ -1192,7 +1192,7 @@ const CommandDesc debug_cmd = {
else if (parser[0] == "faces") else if (parser[0] == "faces")
{ {
write_to_debug_buffer("Faces:"); write_to_debug_buffer("Faces:");
for (auto& face : FaceRegistry::instance().aliases()) for (auto& face : context.faces().flatten_faces())
write_to_debug_buffer(format(" * {}: {}", face.key, face.value.face)); write_to_debug_buffer(format(" * {}: {}", face.key, face.value.face));
} }
else if (parser[0] == "mappings") else if (parser[0] == "mappings")
@ -1809,7 +1809,7 @@ const CommandDesc prompt_cmd = {
CapturedShellContext sc{shell_context}; CapturedShellContext sc{shell_context};
context.input_handler().prompt( context.input_handler().prompt(
parser[0], initstr.str(), {}, get_face("Prompt"), parser[0], initstr.str(), {}, context.faces()["Prompt"],
flags, std::move(completer), flags, std::move(completer),
[=](StringView str, PromptEvent event, Context& context) mutable [=](StringView str, PromptEvent event, Context& context) mutable
{ {
@ -1873,7 +1873,7 @@ const CommandDesc menu_cmd = {
Vector<String> select_cmds; Vector<String> select_cmds;
for (int i = 0; i < count; i += modulo) for (int i = 0; i < count; i += modulo)
{ {
choices.push_back(markup ? parse_display_line(parser[i]) choices.push_back(markup ? parse_display_line(parser[i], context.faces())
: DisplayLine{ parser[i], {} }); : DisplayLine{ parser[i], {} });
commands.push_back(parser[i+1]); commands.push_back(parser[i+1]);
if (with_select_cmds) if (with_select_cmds)
@ -1998,17 +1998,18 @@ const CommandDesc try_catch_cmd = {
} }
}; };
static Completions complete_face(const Context&, CompletionFlags flags, static Completions complete_face(const Context& context, CompletionFlags flags,
const String& prefix, ByteCount cursor_pos) const String& prefix, ByteCount cursor_pos)
{ {
return {0_byte, cursor_pos, return {0_byte, cursor_pos,
FaceRegistry::instance().complete_alias_name(prefix, cursor_pos)}; complete(prefix, cursor_pos, context.faces().flatten_faces() |
transform([](auto& entry) -> const String& { return entry.key; }))};
} }
const CommandDesc set_face_cmd = { const CommandDesc set_face_cmd = {
"set-face", "set-face",
"face", "face",
"set-face <name> <facespec>: set face <name> to refer to <facespec>\n" "set-face <scope> <name> <facespec>: set face <name> to refer to <facespec> in <scope>\n"
"\n" "\n"
"facespec format is <fg color>[,<bg color>][+<attributes>]\n" "facespec format is <fg color>[,<bg color>][+<attributes>]\n"
"colors are either a color name, or rgb:###### values.\n" "colors are either a color name, or rgb:###### values.\n"
@ -2016,19 +2017,33 @@ const CommandDesc set_face_cmd = {
" u: underline, i: italic, b: bold, r: reverse,\n" " u: underline, i: italic, b: bold, r: reverse,\n"
" B: blink, d: dim, e: exclusive\n" " B: blink, d: dim, e: exclusive\n"
"facespec can as well just be the name of another face", "facespec can as well just be the name of another face",
ParameterDesc{{}, ParameterDesc::Flags::None, 2, 2}, ParameterDesc{{}, ParameterDesc::Flags::None, 3, 3},
CommandFlags::None, CommandFlags::None,
CommandHelper{}, CommandHelper{},
make_completer(complete_face, complete_face), make_completer(complete_scope, complete_face, complete_face),
[](const ParametersParser& parser, Context& context, const ShellContext&) [](const ParametersParser& parser, Context& context, const ShellContext&)
{ {
FaceRegistry::instance().register_alias(parser[0], parser[1], true); get_scope(parser[0], context).faces().add_face(parser[1], parser[2], true);
for (auto& client : ClientManager::instance()) for (auto& client : ClientManager::instance())
client->force_redraw(); client->force_redraw();
} }
}; };
const CommandDesc unset_face_cmd = {
"unset-face",
nullptr,
"unset-face <scope> <name>: remove <face> from <scope>",
ParameterDesc{{}, ParameterDesc::Flags::None, 2, 2},
CommandFlags::None,
CommandHelper{},
make_completer(complete_scope, complete_face),
[](const ParametersParser& parser, Context& context, const ShellContext&)
{
get_scope(parser[0], context).faces().remove_face(parser[1]);
}
};
const CommandDesc rename_client_cmd = { const CommandDesc rename_client_cmd = {
"rename-client", "rename-client",
"nc", "nc",
@ -2257,6 +2272,7 @@ void register_commands()
register_command(info_cmd); register_command(info_cmd);
register_command(try_catch_cmd); register_command(try_catch_cmd);
register_command(set_face_cmd); register_command(set_face_cmd);
register_command(unset_face_cmd);
register_command(rename_client_cmd); register_command(rename_client_cmd);
register_command(set_register_cmd); register_command(set_register_cmd);
register_command(select_cmd); register_command(select_cmd);

View File

@ -96,7 +96,7 @@ const SelectionList& JumpList::forward(Context& context, int count)
res.update(); res.update();
context.print_status({ format("jumped to #{} ({})", context.print_status({ format("jumped to #{} ({})",
m_current, m_jumps.size() - 1), m_current, m_jumps.size() - 1),
get_face("Information") }); context.faces()["Information"] });
return res; return res;
} }
throw runtime_error("no next jump"); throw runtime_error("no next jump");
@ -117,7 +117,7 @@ const SelectionList& JumpList::backward(Context& context, int count)
res.update(); res.update();
context.print_status({ format("jumped to #{} ({})", context.print_status({ format("jumped to #{} ({})",
m_current, m_jumps.size() - 1), m_current, m_jumps.size() - 1),
get_face("Information") }); context.faces()["Information"] });
return res; return res;
} }
if (m_current != 0) if (m_current != 0)
@ -133,7 +133,7 @@ const SelectionList& JumpList::backward(Context& context, int count)
res.update(); res.update();
context.print_status({ format("jumped to #{} ({})", context.print_status({ format("jumped to #{} ({})",
m_current, m_jumps.size() - 1), m_current, m_jumps.size() - 1),
get_face("Information") }); context.faces()["Information"] });
return res; return res;
} }
throw runtime_error("no previous jump"); throw runtime_error("no previous jump");

View File

@ -92,9 +92,10 @@ public:
Scope& scope() const; Scope& scope() const;
OptionManager& options() const { return scope().options(); } OptionManager& options() const { return scope().options(); }
HookManager& hooks() const { return scope().hooks(); } HookManager& hooks() const { return scope().hooks(); }
KeymapManager& keymaps() const { return scope().keymaps(); } KeymapManager& keymaps() const { return scope().keymaps(); }
AliasRegistry& aliases() const { return scope().aliases(); } AliasRegistry& aliases() const { return scope().aliases(); }
FaceRegistry& faces() const { return scope().faces(); }
void print_status(DisplayLine status) const; void print_status(DisplayLine status) const;

View File

@ -3,6 +3,7 @@
#include "assert.hh" #include "assert.hh"
#include "buffer.hh" #include "buffer.hh"
#include "buffer_utils.hh" #include "buffer_utils.hh"
#include "face_registry.hh"
#include "utf8.hh" #include "utf8.hh"
#include "face_registry.hh" #include "face_registry.hh"
@ -241,7 +242,7 @@ void DisplayBuffer::optimize()
line.optimize(); line.optimize();
} }
DisplayLine parse_display_line(StringView line, const HashMap<String, DisplayLine>& builtins) DisplayLine parse_display_line(StringView line, const FaceRegistry& faces, const HashMap<String, DisplayLine>& builtins)
{ {
DisplayLine res; DisplayLine res;
bool was_antislash = false; bool was_antislash = false;
@ -278,7 +279,7 @@ DisplayLine parse_display_line(StringView line, const HashMap<String, DisplayLin
++closing; ++closing;
} }
else else
face = get_face({it+1, closing}); face = faces[{it+1, closing}];
it = closing; it = closing;
pos = closing + 1; pos = closing + 1;
} }

View File

@ -142,8 +142,10 @@ private:
AtomList m_atoms; AtomList m_atoms;
}; };
class FaceRegistry;
String fix_atom_text(StringView str); String fix_atom_text(StringView str);
DisplayLine parse_display_line(StringView line, const HashMap<String, DisplayLine>& builtins = {}); DisplayLine parse_display_line(StringView line, const FaceRegistry& faces, const HashMap<String, DisplayLine>& builtins = {});
class DisplayBuffer : public UseMemoryDomain<MemoryDomain::Display> class DisplayBuffer : public UseMemoryDomain<MemoryDomain::Display>
{ {

View File

@ -71,63 +71,62 @@ String to_string(Face face)
return format("{},{}{}", face.fg, face.bg, face.attributes); return format("{},{}{}", face.fg, face.bg, face.attributes);
} }
Face FaceRegistry::operator[](StringView facedesc) Face FaceRegistry::operator[](StringView facedesc) const
{ {
auto it = m_aliases.find(facedesc); auto it = m_faces.find(facedesc);
while (it != m_aliases.end()) if (it != m_faces.end())
{ {
if (it->value.alias.empty()) if (it->value.alias.empty())
return it->value.face; return it->value.face;
it = m_aliases.find(it->value.alias); return operator[](it->value.alias);
} }
if (m_parent)
return (*m_parent)[facedesc];
return parse_face(facedesc); return parse_face(facedesc);
} }
void FaceRegistry::register_alias(StringView name, StringView facedesc, void FaceRegistry::add_face(StringView name, StringView facedesc, bool override)
bool override)
{ {
if (not override and m_aliases.find(name) != m_aliases.end()) if (not override and m_faces.find(name) != m_faces.end())
throw runtime_error(format("alias '{}' already defined", name)); throw runtime_error(format("face '{}' already defined", name));
if (name.empty() or is_color_name(name) or if (name.empty() or is_color_name(name) or
std::any_of(name.begin(), name.end(), std::any_of(name.begin(), name.end(),
[](char c){ return not isalnum(c); })) [](char c){ return not isalnum(c); }))
throw runtime_error(format("invalid alias name: '{}'", name)); throw runtime_error(format("invalid face name: '{}'", name));
if (name == facedesc) if (name == facedesc)
throw runtime_error(format("cannot alias face '{}' to itself", name)); throw runtime_error(format("cannot alias face '{}' to itself", name));
FaceOrAlias& alias = m_aliases[name]; FaceOrAlias& face = m_faces[name];
auto it = m_aliases.find(facedesc); auto it = m_faces.find(facedesc);
if (it != m_aliases.end()) if (it != m_faces.end())
{ {
while (it != m_aliases.end()) while (it != m_faces.end())
{ {
if (it->value.alias.empty()) if (it->value.alias.empty())
break; break;
if (it->value.alias == name) if (it->value.alias == name)
throw runtime_error("face cycle detected"); throw runtime_error("face cycle detected");
it = m_aliases.find(it->value.alias); it = m_faces.find(it->value.alias);
} }
alias.alias = facedesc.str(); face.alias = facedesc.str();
} }
else else
{ {
alias.alias = ""; face.alias = "";
alias.face = parse_face(facedesc); face.face = parse_face(facedesc);
} }
} }
CandidateList FaceRegistry::complete_alias_name(StringView prefix, void FaceRegistry::remove_face(StringView name)
ByteCount cursor_pos) const
{ {
return complete(prefix, cursor_pos, m_faces.remove(name);
m_aliases | transform(&AliasMap::Item::key));
} }
FaceRegistry::FaceRegistry() FaceRegistry::FaceRegistry()
: m_aliases{ : m_faces{
{ "Default", {Face{ Color::Default, Color::Default }} }, { "Default", {Face{ Color::Default, Color::Default }} },
{ "PrimarySelection", {Face{ Color::White, Color::Blue }} }, { "PrimarySelection", {Face{ Color::White, Color::Blue }} },
{ "SecondarySelection", {Face{ Color::Black, Color::Blue }} }, { "SecondarySelection", {Face{ Color::Black, Color::Blue }} },

View File

@ -3,23 +3,35 @@
#include "face.hh" #include "face.hh"
#include "utils.hh" #include "utils.hh"
#include "completion.hh"
#include "hash_map.hh" #include "hash_map.hh"
#include "ranges.hh"
#include "string.hh"
#include "safe_ptr.hh"
namespace Kakoune namespace Kakoune
{ {
class FaceRegistry : public Singleton<FaceRegistry> class FaceRegistry : public SafeCountable
{ {
public: public:
FaceRegistry(); FaceRegistry(FaceRegistry& parent) : SafeCountable{}, m_parent(&parent) {}
Face operator[](StringView facedesc); Face operator[](StringView facedesc) const;
void register_alias(StringView name, StringView facedesc, void add_face(StringView name, StringView facedesc, bool override = false);
bool override = false); void remove_face(StringView name);
CandidateList complete_alias_name(StringView prefix, auto flatten_faces() const
ByteCount cursor_pos) const; {
auto merge = [](auto&& first, const FaceMap& second) {
return concatenated(std::forward<decltype(first)>(first)
| filter([&second](auto& i) { return not second.contains(i.key); }),
second);
};
static const FaceMap empty;
auto& parent = m_parent ? m_parent->m_faces : empty;
auto& grand_parent = (m_parent and m_parent->m_parent) ? m_parent->m_parent->m_faces : empty;
return merge(merge(grand_parent, parent), m_faces);
}
struct FaceOrAlias struct FaceOrAlias
{ {
@ -27,19 +39,15 @@ public:
String alias = {}; String alias = {};
}; };
using AliasMap = HashMap<String, FaceOrAlias, MemoryDomain::Faces>;
const AliasMap &aliases() const { return m_aliases; }
private: private:
AliasMap m_aliases; friend class Scope;
}; FaceRegistry();
inline Face get_face(StringView facedesc) SafePtr<FaceRegistry> m_parent;
{
if (FaceRegistry::has_instance()) using FaceMap = HashMap<String, FaceOrAlias, MemoryDomain::Faces>;
return FaceRegistry::instance()[facedesc]; FaceMap m_faces;
return Face{}; };
}
String to_string(Face face); String to_string(Face face);

55
src/highlighter.cc Normal file
View File

@ -0,0 +1,55 @@
#include "highlighter.hh"
#include "buffer_utils.hh"
namespace Kakoune
{
void Highlighter::highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range)
{
if (context.pass & m_passes) try
{
do_highlight(context, display_buffer, range);
}
catch (runtime_error& error)
{
write_to_debug_buffer(format("Error while highlighting: {}", error.what()));
}
}
void Highlighter::compute_display_setup(HighlightContext context, DisplaySetup& setup) const
{
if (context.pass & m_passes)
do_compute_display_setup(context, setup);
}
bool Highlighter::has_children() const
{
return false;
}
Highlighter& Highlighter::get_child(StringView path)
{
throw runtime_error("this highlighter do not hold children");
}
void Highlighter::add_child(HighlighterAndId&& hl)
{
throw runtime_error("this highlighter do not hold children");
}
void Highlighter::remove_child(StringView id)
{
throw runtime_error("this highlighter do not hold children");
}
Completions Highlighter::complete_child(StringView path, ByteCount cursor_pos, bool group) const
{
throw runtime_error("this highlighter do not hold children");
}
void Highlighter::fill_unique_ids(Vector<StringView>& unique_ids) const
{}
}

View File

@ -65,25 +65,15 @@ struct Highlighter
Highlighter(HighlightPass passes) : m_passes{passes} {} Highlighter(HighlightPass passes) : m_passes{passes} {}
virtual ~Highlighter() = default; virtual ~Highlighter() = default;
void highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range) void highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range);
{ void compute_display_setup(HighlightContext context, DisplaySetup& setup) const;
if (context.pass & m_passes)
do_highlight(context, display_buffer, range);
}
void compute_display_setup(HighlightContext context, DisplaySetup& setup) const virtual bool has_children() const;
{ virtual Highlighter& get_child(StringView path);
if (context.pass & m_passes) virtual void add_child(HighlighterAndId&& hl);
do_compute_display_setup(context, setup); virtual void remove_child(StringView id);
} virtual Completions complete_child(StringView path, ByteCount cursor_pos, bool group) const;
virtual void fill_unique_ids(Vector<StringView>& unique_ids) const;
virtual bool has_children() const { return false; }
virtual Highlighter& get_child(StringView path) { throw runtime_error("this highlighter do not hold children"); }
virtual void add_child(HighlighterAndId&& hl) { throw runtime_error("this highlighter do not hold children"); }
virtual void remove_child(StringView id) { throw runtime_error("this highlighter do not hold children"); }
virtual Completions complete_child(StringView path, ByteCount cursor_pos, bool group) const { throw runtime_error("this highlighter do not hold children"); }
virtual void fill_unique_ids(Vector<StringView>& unique_ids) const {}
HighlightPass passes() const { return m_passes; } HighlightPass passes() const { return m_passes; }

View File

@ -225,12 +225,10 @@ static HighlighterAndId create_fill_highlighter(HighlighterParameters params)
throw runtime_error("wrong parameter count"); throw runtime_error("wrong parameter count");
const String& facespec = params[0]; const String& facespec = params[0];
get_face(facespec); // validate param auto func = [facespec](HighlightContext context, DisplayBuffer& display_buffer, BufferRange range)
auto func = [=](HighlightContext, DisplayBuffer& display_buffer, BufferRange range)
{ {
highlight_range(display_buffer, range.begin, range.end, false, highlight_range(display_buffer, range.begin, range.end, false,
apply_face(get_face(facespec))); apply_face(context.context.faces()[facespec]));
}; };
return {"fill_" + facespec, make_highlighter(std::move(func))}; return {"fill_" + facespec, make_highlighter(std::move(func))};
} }
@ -278,7 +276,7 @@ public:
for (int f = 0; f < m_faces.size(); ++f) for (int f = 0; f < m_faces.size(); ++f)
{ {
if (not m_faces[f].second.empty()) if (not m_faces[f].second.empty())
faces[f] = get_face(m_faces[f].second); faces[f] = context.context.faces()[m_faces[f].second];
} }
auto& matches = get_matches(context.context.buffer(), display_buffer.range(), range); auto& matches = get_matches(context.context.buffer(), display_buffer.range(), range);
@ -314,7 +312,6 @@ public:
auto colon = find(spec, ':'); auto colon = find(spec, ':');
if (colon == spec.end()) if (colon == spec.end())
throw runtime_error(format("wrong face spec: '{}' expected <capture>:<facespec>", spec)); throw runtime_error(format("wrong face spec: '{}' expected <capture>:<facespec>", spec));
get_face({colon+1, spec.end()}); // throw if wrong face spec
int capture = str_to_int({spec.begin(), colon}); int capture = str_to_int({spec.begin(), colon});
faces.emplace_back(capture, String{colon+1, spec.end()}); faces.emplace_back(capture, String{colon+1, spec.end()});
} }
@ -495,7 +492,6 @@ HighlighterAndId create_dynamic_regex_highlighter(HighlighterParameters params)
if (colon == spec.end()) if (colon == spec.end())
throw runtime_error("wrong face spec: '" + spec + throw runtime_error("wrong face spec: '" + spec +
"' expected <capture>:<facespec>"); "' expected <capture>:<facespec>");
get_face({colon+1, spec.end()}); // throw if wrong face spec
int capture = str_to_int({spec.begin(), colon}); int capture = str_to_int({spec.begin(), colon});
faces.emplace_back(capture, String{colon+1, spec.end()}); faces.emplace_back(capture, String{colon+1, spec.end()});
} }
@ -539,12 +535,8 @@ HighlighterAndId create_line_highlighter(HighlighterParameters params)
if (params.size() != 2) if (params.size() != 2)
throw runtime_error("wrong parameter count"); throw runtime_error("wrong parameter count");
String facespec = params[1]; auto func = [line_expr=params[0], facespec=params[1]]
String line_expr = params[0]; (HighlightContext context, DisplayBuffer& display_buffer, BufferRange)
get_face(facespec); // validate facespec
auto func = [=](HighlightContext context, DisplayBuffer& display_buffer, BufferRange)
{ {
LineCount line = -1; LineCount line = -1;
try try
@ -566,7 +558,7 @@ HighlighterAndId create_line_highlighter(HighlighterParameters params)
if (it == display_buffer.lines().end()) if (it == display_buffer.lines().end())
return; return;
auto face = get_face(facespec); auto face = context.context.faces()[facespec];
ColumnCount column = 0; ColumnCount column = 0;
for (auto& atom : *it) for (auto& atom : *it)
{ {
@ -590,12 +582,8 @@ HighlighterAndId create_column_highlighter(HighlighterParameters params)
if (params.size() != 2) if (params.size() != 2)
throw runtime_error("wrong parameter count"); throw runtime_error("wrong parameter count");
String facespec = params[1]; auto func = [col_expr=params[0], facespec=params[1]]
String col_expr = params[0]; (HighlightContext context, DisplayBuffer& display_buffer, BufferRange)
get_face(facespec); // validate facespec
auto func = [=](HighlightContext context, DisplayBuffer& display_buffer, BufferRange)
{ {
ColumnCount column = -1; ColumnCount column = -1;
try try
@ -611,7 +599,7 @@ HighlighterAndId create_column_highlighter(HighlighterParameters params)
if (column < 0) if (column < 0)
return; return;
auto face = get_face(facespec); auto face = context.context.faces()[facespec];
auto win_column = context.context.window().position().column; auto win_column = context.context.window().position().column;
for (auto& line : display_buffer.lines()) for (auto& line : display_buffer.lines())
{ {
@ -937,7 +925,7 @@ void show_whitespaces(HighlightContext context, DisplayBuffer& display_buffer, B
StringView spc, StringView lf, StringView nbsp) StringView spc, StringView lf, StringView nbsp)
{ {
const int tabstop = context.context.options()["tabstop"].get<int>(); const int tabstop = context.context.options()["tabstop"].get<int>();
auto whitespaceface = get_face("Whitespace"); auto whitespaceface = context.context.faces()["Whitespace"];
auto& buffer = context.context.buffer(); auto& buffer = context.context.buffer();
auto win_column = context.context.window().position().column; auto win_column = context.context.window().position().column;
for (auto& line : display_buffer.lines()) for (auto& line : display_buffer.lines())
@ -1043,9 +1031,10 @@ private:
if (contains(context.disabled_ids, ms_id)) if (contains(context.disabled_ids, ms_id))
return; return;
const Face face = get_face("LineNumbers"); auto& faces = context.context.faces();
const Face face_wrapped = get_face("LineNumbersWrapped"); const Face face = faces["LineNumbers"];
const Face face_absolute = get_face("LineNumberCursor"); const Face face_wrapped = faces["LineNumbersWrapped"];
const Face face_absolute = faces["LineNumberCursor"];
int digit_count = compute_digit_count(context.context); int digit_count = compute_digit_count(context.context);
char format[16]; char format[16];
@ -1102,7 +1091,7 @@ constexpr StringView LineNumbersHighlighter::ms_id;
void show_matching_char(HighlightContext context, DisplayBuffer& display_buffer, BufferRange) void show_matching_char(HighlightContext context, DisplayBuffer& display_buffer, BufferRange)
{ {
const Face face = get_face("MatchingChar"); const Face face = context.context.faces()["MatchingChar"];
using CodepointPair = std::pair<Codepoint, Codepoint>; using CodepointPair = std::pair<Codepoint, Codepoint>;
static const CodepointPair matching_chars[] = { { '(', ')' }, { '{', '}' }, { '[', ']' }, { '<', '>' } }; static const CodepointPair matching_chars[] = { { '(', ')' }, { '{', '}' }, { '[', ']' }, { '<', '>' } };
const auto range = display_buffer.range(); const auto range = display_buffer.range();
@ -1162,10 +1151,11 @@ HighlighterAndId create_matching_char_highlighter(HighlighterParameters params)
void highlight_selections(HighlightContext context, DisplayBuffer& display_buffer, BufferRange) void highlight_selections(HighlightContext context, DisplayBuffer& display_buffer, BufferRange)
{ {
const auto& buffer = context.context.buffer(); const auto& buffer = context.context.buffer();
const Face faces[6] = { const auto& faces = context.context.faces();
get_face("PrimarySelection"), get_face("SecondarySelection"), const Face sel_faces[6] = {
get_face("PrimaryCursor"), get_face("SecondaryCursor"), faces["PrimarySelection"], faces["SecondarySelection"],
get_face("PrimaryCursorEol"), get_face("SecondaryCursorEol"), faces["PrimaryCursor"], faces["SecondaryCursor"],
faces["PrimaryCursorEol"], faces["SecondaryCursorEol"],
}; };
const auto& selections = context.context.selections(); const auto& selections = context.context.selections();
@ -1178,7 +1168,7 @@ void highlight_selections(HighlightContext context, DisplayBuffer& display_buffe
const bool primary = (i == selections.main_index()); const bool primary = (i == selections.main_index());
highlight_range(display_buffer, begin, end, false, highlight_range(display_buffer, begin, end, false,
apply_face(faces[primary ? 0 : 1])); apply_face(sel_faces[primary ? 0 : 1]));
} }
for (size_t i = 0; i < selections.size(); ++i) for (size_t i = 0; i < selections.size(); ++i)
{ {
@ -1187,14 +1177,14 @@ void highlight_selections(HighlightContext context, DisplayBuffer& display_buffe
const bool primary = (i == selections.main_index()); const bool primary = (i == selections.main_index());
const bool eol = buffer[coord.line].length() - 1 == coord.column; const bool eol = buffer[coord.line].length() - 1 == coord.column;
highlight_range(display_buffer, coord, buffer.char_next(coord), false, highlight_range(display_buffer, coord, buffer.char_next(coord), false,
apply_face(faces[2 + (eol ? 2 : 0) + (primary ? 0 : 1)])); apply_face(sel_faces[2 + (eol ? 2 : 0) + (primary ? 0 : 1)]));
} }
} }
void expand_unprintable(HighlightContext context, DisplayBuffer& display_buffer, BufferRange) void expand_unprintable(HighlightContext context, DisplayBuffer& display_buffer, BufferRange)
{ {
auto& buffer = context.context.buffer(); auto& buffer = context.context.buffer();
auto error = get_face("Error"); auto error = context.context.faces()["Error"];
for (auto& line : display_buffer.lines()) for (auto& line : display_buffer.lines())
{ {
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it) for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
@ -1281,7 +1271,6 @@ struct FlagLinesHighlighter : Highlighter
const String& option_name = params[1]; const String& option_name = params[1];
const String& default_face = params[0]; const String& default_face = params[0];
get_face(default_face); // validate param
// throw if wrong option type // throw if wrong option type
GlobalScope::instance().options()[option_name].get<LineAndSpecList>(); GlobalScope::instance().options()[option_name].get<LineAndSpecList>();
@ -1296,14 +1285,14 @@ private:
auto& buffer = context.context.buffer(); auto& buffer = context.context.buffer();
update_line_specs_ifn(buffer, line_flags); update_line_specs_ifn(buffer, line_flags);
auto def_face = get_face(m_default_face); auto def_face = context.context.faces()[m_default_face];
Vector<DisplayLine> display_lines; Vector<DisplayLine> display_lines;
auto& lines = line_flags.list; auto& lines = line_flags.list;
try try
{ {
for (auto& line : lines) for (auto& line : lines)
{ {
display_lines.push_back(parse_display_line(std::get<1>(line))); display_lines.push_back(parse_display_line(std::get<1>(line), context.context.faces()));
for (auto& atom : display_lines.back()) for (auto& atom : display_lines.back())
atom.face = merge_faces(def_face, atom.face); atom.face = merge_faces(def_face, atom.face);
} }
@ -1350,7 +1339,7 @@ private:
try try
{ {
for (auto& line : line_flags.list) for (auto& line : line_flags.list)
width = std::max(parse_display_line(std::get<1>(line)).length(), width); width = std::max(parse_display_line(std::get<1>(line), context.context.faces()).length(), width);
} }
catch (runtime_error& err) catch (runtime_error& err)
{ {
@ -1471,7 +1460,7 @@ private:
auto& r = std::get<0>(range); auto& r = std::get<0>(range);
if (buffer.is_valid(r.first) and (buffer.is_valid(r.last) and not buffer.is_end(r.last))) if (buffer.is_valid(r.first) and (buffer.is_valid(r.last) and not buffer.is_end(r.last)))
highlight_range(display_buffer, r.first, buffer.char_next(r.last), false, highlight_range(display_buffer, r.first, buffer.char_next(r.last), false,
apply_face(get_face(std::get<1>(range)))); apply_face(context.context.faces()[std::get<1>(range)]));
} }
catch (runtime_error&) catch (runtime_error&)
{} {}
@ -1513,7 +1502,7 @@ private:
auto& r = std::get<0>(range); auto& r = std::get<0>(range);
if (buffer.is_valid(r.first) and buffer.is_valid(r.last)) if (buffer.is_valid(r.first) and buffer.is_valid(r.last))
{ {
auto replacement = parse_display_line(std::get<1>(range)); auto replacement = parse_display_line(std::get<1>(range), context.context.faces());
replace_range(display_buffer, r.first, buffer.char_next(r.last), replace_range(display_buffer, r.first, buffer.char_next(r.last),
[&](DisplayLine& line, int beg_idx, int end_idx){ [&](DisplayLine& line, int beg_idx, int end_idx){
auto it = line.erase(line.begin() + beg_idx, line.begin() + end_idx); auto it = line.erase(line.begin() + beg_idx, line.begin() + end_idx);

View File

@ -133,7 +133,7 @@ void HookManager::run_hook(StringView hook_name, StringView param, Context& cont
if (hook_error) if (hook_error)
context.print_status({ context.print_status({
format("Error running hooks for '{}' '{}', see *debug* buffer", format("Error running hooks for '{}' '{}', see *debug* buffer",
hook_name, param), get_face("Error") }); hook_name, param), context.faces()["Error"] });
if (profile) if (profile)
{ {

View File

@ -251,7 +251,7 @@ public:
{ {
long long new_val = (long long)m_params.count * 10 + *cp - '0'; long long new_val = (long long)m_params.count * 10 + *cp - '0';
if (new_val > std::numeric_limits<int>::max()) if (new_val > std::numeric_limits<int>::max())
context().print_status({ "parameter overflowed", get_face("Error") }); context().print_status({ "parameter overflowed", context().faces()["Error"] });
else else
m_params.count = new_val; m_params.count = new_val;
} }
@ -277,7 +277,7 @@ public:
else else
context.print_status( context.print_status(
{ format("invalid register '{}'", *cp), { format("invalid register '{}'", *cp),
get_face("Error") }); context.faces()["Error"] });
}, "enter target register", register_doc); }, "enter target register", register_doc);
} }
else else
@ -319,19 +319,19 @@ public:
auto num_sel = context().selections().size(); auto num_sel = context().selections().size();
auto main_index = context().selections().main_index(); auto main_index = context().selections().main_index();
if (num_sel == 1) if (num_sel == 1)
atoms.emplace_back(format("{} sel", num_sel), get_face("StatusLineInfo")); atoms.emplace_back(format("{} sel", num_sel), context().faces()["StatusLineInfo"]);
else else
atoms.emplace_back(format("{} sels ({})", num_sel, main_index + 1), get_face("StatusLineInfo")); atoms.emplace_back(format("{} sels ({})", num_sel, main_index + 1), context().faces()["StatusLineInfo"]);
if (m_params.count != 0) if (m_params.count != 0)
{ {
atoms.emplace_back(" param=", get_face("StatusLineInfo")); atoms.emplace_back(" param=", context().faces()["StatusLineInfo"]);
atoms.emplace_back(to_string(m_params.count), get_face("StatusLineValue")); atoms.emplace_back(to_string(m_params.count), context().faces()["StatusLineValue"]);
} }
if (m_params.reg) if (m_params.reg)
{ {
atoms.emplace_back(" reg=", get_face("StatusLineInfo")); atoms.emplace_back(" reg=", context().faces()["StatusLineInfo"]);
atoms.emplace_back(StringView(m_params.reg).str(), get_face("StatusLineValue")); atoms.emplace_back(StringView(m_params.reg).str(), context().faces()["StatusLineValue"]);
} }
return atoms; return atoms;
} }
@ -425,6 +425,8 @@ void to_prev_word_begin(CharCount& pos, StringView line)
class LineEditor class LineEditor
{ {
public: public:
LineEditor(const FaceRegistry& faces) : m_faces{faces} {}
void handle_key(Key key) void handle_key(Key key)
{ {
if (key == Key::Left or key == alt('h')) if (key == Key::Left or key == alt('h'))
@ -528,8 +530,8 @@ public:
const bool empty = m_line.empty(); const bool empty = m_line.empty();
StringView str = empty ? m_empty_text : m_line; StringView str = empty ? m_empty_text : m_line;
const Face line_face = get_face(empty ? "StatusLineInfo" : "StatusLine"); const Face line_face = m_faces[empty ? "StatusLineInfo" : "StatusLine"];
const Face cursor_face = get_face("StatusCursor"); const Face cursor_face = m_faces["StatusCursor"];
if (m_cursor_pos == str.char_length()) if (m_cursor_pos == str.char_length())
return DisplayLine{{ { fix_atom_text(str.substr(m_display_pos, width-1)), line_face }, return DisplayLine{{ { fix_atom_text(str.substr(m_display_pos, width-1)), line_face },
@ -545,6 +547,8 @@ private:
String m_line; String m_line;
StringView m_empty_text = {}; StringView m_empty_text = {};
const FaceRegistry& m_faces;
}; };
class Menu : public InputMode class Menu : public InputMode
@ -554,7 +558,8 @@ public:
MenuCallback callback) MenuCallback callback)
: InputMode(input_handler), : InputMode(input_handler),
m_callback(std::move(callback)), m_choices(choices.begin(), choices.end()), m_callback(std::move(callback)), m_choices(choices.begin(), choices.end()),
m_selected(m_choices.begin()) m_selected(m_choices.begin()),
m_filter_editor{context().faces()}
{ {
if (not context().has_client()) if (not context().has_client())
return; return;
@ -648,14 +653,14 @@ public:
auto prompt = "filter:"_str; auto prompt = "filter:"_str;
auto width = context().client().dimensions().column - prompt.column_length(); auto width = context().client().dimensions().column - prompt.column_length();
auto display_line = m_filter_editor.build_display_line(width); auto display_line = m_filter_editor.build_display_line(width);
display_line.insert(display_line.begin(), { prompt, get_face("Prompt") }); display_line.insert(display_line.begin(), { prompt, context().faces()["Prompt"] });
context().print_status(display_line); context().print_status(display_line);
} }
} }
DisplayLine mode_line() const override DisplayLine mode_line() const override
{ {
return { "menu", get_face("StatusLineMode") }; return { "menu", context().faces()["StatusLineMode"] };
} }
KeymapMode keymap_mode() const override { return KeymapMode::Menu; } KeymapMode keymap_mode() const override { return KeymapMode::Menu; }
@ -714,7 +719,8 @@ public:
m_line_changed = false; m_line_changed = false;
} }
context().hooks().run_hook("PromptIdle", "", context()); context().hooks().run_hook("PromptIdle", "", context());
}} }},
m_line_editor{context().faces()}
{ {
m_history_it = ms_history[m_prompt].end(); m_history_it = ms_history[m_prompt].end();
m_line_editor.reset(std::move(initstr), m_empty_text); m_line_editor.reset(std::move(initstr), m_empty_text);
@ -884,7 +890,7 @@ public:
} }
catch (std::runtime_error& error) catch (std::runtime_error& error)
{ {
context().print_status({error.what(), get_face("Error")}); context().print_status({error.what(), context().faces()["Error"]});
return; return;
} }
} }
@ -912,7 +918,7 @@ public:
DisplayLine mode_line() const override DisplayLine mode_line() const override
{ {
return { "prompt", get_face("StatusLineMode") }; return { "prompt", context().faces()["StatusLineMode"] };
} }
KeymapMode keymap_mode() const override { return KeymapMode::Prompt; } KeymapMode keymap_mode() const override { return KeymapMode::Prompt; }
@ -1046,7 +1052,7 @@ public:
DisplayLine mode_line() const override DisplayLine mode_line() const override
{ {
return { "enter key", get_face("StatusLineMode") }; return { "enter key", context().faces()["StatusLineMode"] };
} }
KeymapMode keymap_mode() const override { return m_keymap_mode; } KeymapMode keymap_mode() const override { return m_keymap_mode; }
@ -1257,7 +1263,7 @@ public:
context().buffer().commit_undo_group(); context().buffer().commit_undo_group();
context().print_status({ format("committed change #{}", context().print_status({ format("committed change #{}",
context().buffer().current_history_id()), context().buffer().current_history_id()),
get_face("Information") }); context().faces()["Information"] });
} }
else if (key == ctrl('v')) else if (key == ctrl('v'))
{ {
@ -1291,9 +1297,10 @@ public:
{ {
auto num_sel = context().selections().size(); auto num_sel = context().selections().size();
auto main_index = context().selections().main_index(); auto main_index = context().selections().main_index();
return {AtomList{ { "insert", get_face("StatusLineMode") }, return {AtomList{ { "insert", context().faces()["StatusLineMode"] },
{ " ", get_face("StatusLine") }, { " ", context().faces()["StatusLine"] },
{ format( "{} sels ({})", num_sel, main_index + 1), get_face("StatusLineInfo") } }}; { format( "{} sels ({})", num_sel, main_index + 1),
context().faces()["StatusLineInfo"] } }};
} }
KeymapMode keymap_mode() const override { return KeymapMode::Insert; } KeymapMode keymap_mode() const override { return KeymapMode::Insert; }

View File

@ -89,7 +89,9 @@ WordDB& get_word_db(const Buffer& buffer)
} }
template<bool other_buffers> template<bool other_buffers>
InsertCompletion complete_word(const SelectionList& sels, const OptionManager& options) InsertCompletion complete_word(const SelectionList& sels,
const OptionManager& options,
const FaceRegistry& faces)
{ {
ConstArrayView<Codepoint> extra_word_chars = options["extra_word_chars"].get<Vector<Codepoint, MemoryDomain::Options>>(); ConstArrayView<Codepoint> extra_word_chars = options["extra_word_chars"].get<Vector<Codepoint, MemoryDomain::Options>>();
auto is_word_pred = [extra_word_chars](Codepoint c) { return is_word(c, extra_word_chars); }; auto is_word_pred = [extra_word_chars](Codepoint c) { return is_word(c, extra_word_chars); };
@ -190,7 +192,7 @@ InsertCompletion complete_word(const SelectionList& sels, const OptionManager& o
const auto pad_len = longest + 1 - first->candidate().char_length(); const auto pad_len = longest + 1 - first->candidate().char_length();
menu_entry.push_back(first->candidate().str()); menu_entry.push_back(first->candidate().str());
menu_entry.push_back(String{' ', pad_len}); menu_entry.push_back(String{' ', pad_len});
menu_entry.push_back({ first->buffer->display_name(), get_face("MenuInfo") }); menu_entry.push_back({ first->buffer->display_name(), faces["MenuInfo"] });
} }
else else
menu_entry.push_back(first->candidate().str()); menu_entry.push_back(first->candidate().str());
@ -205,7 +207,8 @@ InsertCompletion complete_word(const SelectionList& sels, const OptionManager& o
template<bool require_slash> template<bool require_slash>
InsertCompletion complete_filename(const SelectionList& sels, InsertCompletion complete_filename(const SelectionList& sels,
const OptionManager& options) const OptionManager& options,
const FaceRegistry&)
{ {
const Buffer& buffer = sels.buffer(); const Buffer& buffer = sels.buffer();
auto pos = buffer.iterator_at(sels.main().cursor()); auto pos = buffer.iterator_at(sels.main().cursor());
@ -268,6 +271,7 @@ InsertCompletion complete_filename(const SelectionList& sels,
InsertCompletion complete_option(const SelectionList& sels, InsertCompletion complete_option(const SelectionList& sels,
const OptionManager& options, const OptionManager& options,
const FaceRegistry& faces,
StringView option_name) StringView option_name)
{ {
const Buffer& buffer = sels.buffer(); const Buffer& buffer = sels.buffer();
@ -323,7 +327,7 @@ InsertCompletion complete_option(const SelectionList& sels,
match.docstring = std::get<1>(candidate); match.docstring = std::get<1>(candidate);
auto& menu = std::get<2>(candidate); auto& menu = std::get<2>(candidate);
match.menu_entry = not menu.empty() ? match.menu_entry = not menu.empty() ?
parse_display_line(expand_tabs(menu, tabstop, column)) parse_display_line(expand_tabs(menu, tabstop, column), faces)
: DisplayLine{ expand_tabs(menu, tabstop, column) }; : DisplayLine{ expand_tabs(menu, tabstop, column) };
matches.push_back(std::move(match)); matches.push_back(std::move(match));
@ -353,7 +357,9 @@ InsertCompletion complete_option(const SelectionList& sels,
} }
template<bool other_buffers> template<bool other_buffers>
InsertCompletion complete_line(const SelectionList& sels, const OptionManager& options) InsertCompletion complete_line(const SelectionList& sels,
const OptionManager& options,
const FaceRegistry&)
{ {
const Buffer& buffer = sels.buffer(); const Buffer& buffer = sels.buffer();
BufferCoord cursor_pos = sels.main().cursor(); BufferCoord cursor_pos = sels.main().cursor();
@ -403,7 +409,7 @@ InsertCompletion complete_line(const SelectionList& sels, const OptionManager& o
} }
InsertCompleter::InsertCompleter(Context& context) InsertCompleter::InsertCompleter(Context& context)
: m_context(context), m_options(context.options()) : m_context(context), m_options(context.options()), m_faces(context.faces())
{ {
m_options.register_watcher(*this); m_options.register_watcher(*this);
} }
@ -516,8 +522,10 @@ bool InsertCompleter::setup_ifn()
try_complete(complete_filename<true>)) try_complete(complete_filename<true>))
return true; return true;
if (completer.mode == InsertCompleterDesc::Option and if (completer.mode == InsertCompleterDesc::Option and
try_complete([&](const SelectionList& sels, const OptionManager& options) { try_complete([&](const SelectionList& sels,
return complete_option(sels, options, *completer.param); const OptionManager& options,
const FaceRegistry& faces) {
return complete_option(sels, options, faces, *completer.param);
})) }))
return true; return true;
if (completer.mode == InsertCompleterDesc::Word and if (completer.mode == InsertCompleterDesc::Word and
@ -583,7 +591,7 @@ bool InsertCompleter::try_complete(Func complete_func)
auto& sels = m_context.selections(); auto& sels = m_context.selections();
try try
{ {
m_completions = complete_func(sels, m_options); m_completions = complete_func(sels, m_options, m_faces);
} }
catch (runtime_error& e) catch (runtime_error& e)
{ {

View File

@ -13,6 +13,7 @@ namespace Kakoune
struct SelectionList; struct SelectionList;
struct Key; struct Key;
class FaceRegistry;
struct InsertCompleterDesc struct InsertCompleterDesc
{ {
@ -100,12 +101,15 @@ private:
void menu_show(); void menu_show();
Context& m_context; Context& m_context;
OptionManager& m_options; OptionManager& m_options;
InsertCompletion m_completions; const FaceRegistry& m_faces;
int m_current_candidate = -1; InsertCompletion m_completions;
int m_current_candidate = -1;
using CompleteFunc = InsertCompletion (const SelectionList& sels, const OptionManager& options); using CompleteFunc = InsertCompletion (const SelectionList& sels,
const OptionManager& options,
const FaceRegistry& faces);
CompleteFunc* m_explicit_completer = nullptr; CompleteFunc* m_explicit_completer = nullptr;
}; };

View File

@ -50,7 +50,8 @@ static const char* startup_info =
" * selections merging behaviour is now a bit more complex again\n" " * selections merging behaviour is now a bit more complex again\n"
" * 'x' will only jump to next line if full line is already selected\n" " * 'x' will only jump to next line if full line is already selected\n"
" * WORD text object moved to <a-w> instead of W for consistency\n" " * WORD text object moved to <a-w> instead of W for consistency\n"
" * rotate main selection moved to ), rotate content to <a-)>, ( for backward\n"; " * rotate main selection moved to ), rotate content to <a-)>, ( for backward\n"
" * faces are now scoped, set-face command takes an additional scope parameter\n";
struct startup_error : runtime_error struct startup_error : runtime_error
{ {
@ -585,7 +586,6 @@ int run_server(StringView session, StringView server_init,
RegisterManager register_manager; RegisterManager register_manager;
HighlighterRegistry highlighter_registry; HighlighterRegistry highlighter_registry;
DefinedHighlighters defined_highlighters; DefinedHighlighters defined_highlighters;
FaceRegistry face_registry;
ClientManager client_manager; ClientManager client_manager;
BufferManager buffer_manager; BufferManager buffer_manager;
@ -667,7 +667,7 @@ int run_server(StringView session, StringView server_init,
if (startup_error) if (startup_error)
local_client->print_status({ local_client->print_status({
"error during startup, see *debug* buffer for details", "error during startup, see *debug* buffer for details",
get_face("Error") local_client->context().faces()["Error"]
}); });
if (flags & ServerFlags::StartupInfo) if (flags & ServerFlags::StartupInfo)

View File

@ -444,7 +444,7 @@ void command(Context& context, NormalParams params)
context.input_handler().prompt( context.input_handler().prompt(
":", {}, context.main_sel_register_value(':').str(), ":", {}, context.main_sel_register_value(':').str(),
get_face("Prompt"), PromptFlags::DropHistoryEntriesWithBlankPrefix, context.faces()["Prompt"], PromptFlags::DropHistoryEntriesWithBlankPrefix,
[](const Context& context, CompletionFlags flags, [](const Context& context, CompletionFlags flags,
StringView cmd_line, ByteCount pos) { StringView cmd_line, ByteCount pos) {
return CommandManager::instance().complete(context, flags, cmd_line, pos); return CommandManager::instance().complete(context, flags, cmd_line, pos);
@ -456,7 +456,7 @@ void command(Context& context, NormalParams params)
if (event == PromptEvent::Change) if (event == PromptEvent::Change)
{ {
auto info = CommandManager::instance().command_info(context, cmdline); auto info = CommandManager::instance().command_info(context, cmdline);
context.input_handler().set_prompt_face(get_face(info ? "Prompt" : "Error")); context.input_handler().set_prompt_face(context.faces()[info ? "Prompt" : "Error"]);
auto autoinfo = context.options()["autoinfo"].get<AutoInfo>(); auto autoinfo = context.options()["autoinfo"].get<AutoInfo>();
if (autoinfo & AutoInfo::Command) if (autoinfo & AutoInfo::Command)
@ -524,7 +524,7 @@ void pipe(Context& context, NormalParams)
{ {
const char* prompt = replace ? "pipe:" : "pipe-to:"; const char* prompt = replace ? "pipe:" : "pipe-to:";
context.input_handler().prompt( context.input_handler().prompt(
prompt, {}, context.main_sel_register_value("|").str(), get_face("Prompt"), prompt, {}, context.main_sel_register_value("|").str(), context.faces()["Prompt"],
PromptFlags::DropHistoryEntriesWithBlankPrefix, PromptFlags::DropHistoryEntriesWithBlankPrefix,
shell_complete, shell_complete,
[](StringView cmdline, PromptEvent event, Context& context) [](StringView cmdline, PromptEvent event, Context& context)
@ -599,7 +599,7 @@ void insert_output(Context& context, NormalParams)
{ {
const char* prompt = mode == InsertMode::Insert ? "insert-output:" : "append-output:"; const char* prompt = mode == InsertMode::Insert ? "insert-output:" : "append-output:";
context.input_handler().prompt( context.input_handler().prompt(
prompt, {}, context.main_sel_register_value("|").str(), get_face("Prompt"), prompt, {}, context.main_sel_register_value("|").str(), context.faces()["Prompt"],
PromptFlags::DropHistoryEntriesWithBlankPrefix, PromptFlags::DropHistoryEntriesWithBlankPrefix,
shell_complete, shell_complete,
[](StringView cmdline, PromptEvent event, Context& context) [](StringView cmdline, PromptEvent event, Context& context)
@ -628,7 +628,7 @@ void yank(Context& context, NormalParams params)
RegisterManager::instance()[reg].set(context, context.selections_content()); RegisterManager::instance()[reg].set(context, context.selections_content());
context.print_status({ format("yanked {} selections to register {}", context.print_status({ format("yanked {} selections to register {}",
context.selections().size(), reg), context.selections().size(), reg),
get_face("Information") }); context.faces()["Information"] });
} }
template<bool yank> template<bool yank>
@ -733,7 +733,7 @@ void regex_prompt(Context& context, String prompt, String default_regex, T func)
DisplayCoord position = context.has_window() ? context.window().position() : DisplayCoord{}; DisplayCoord position = context.has_window() ? context.window().position() : DisplayCoord{};
SelectionList selections = context.selections(); SelectionList selections = context.selections();
context.input_handler().prompt( context.input_handler().prompt(
std::move(prompt), {}, default_regex, get_face("Prompt"), std::move(prompt), {}, default_regex, context.faces()["Prompt"],
PromptFlags::None, complete_nothing, PromptFlags::None, complete_nothing,
[=](StringView str, PromptEvent event, Context& context) mutable { [=](StringView str, PromptEvent event, Context& context) mutable {
try try
@ -749,7 +749,7 @@ void regex_prompt(Context& context, String prompt, String default_regex, T func)
if (context.has_window()) if (context.has_window())
context.window().set_position(position); context.window().set_position(position);
context.input_handler().set_prompt_face(get_face("Prompt")); context.input_handler().set_prompt_face(context.faces()["Prompt"]);
} }
if (not incsearch and event == PromptEvent::Change) if (not incsearch and event == PromptEvent::Change)
@ -766,7 +766,7 @@ void regex_prompt(Context& context, String prompt, String default_regex, T func)
if (event == PromptEvent::Validate) if (event == PromptEvent::Validate)
throw; throw;
else else
context.input_handler().set_prompt_face(get_face("Error")); context.input_handler().set_prompt_face(context.faces()["Error"]);
} }
catch (runtime_error&) catch (runtime_error&)
{ {
@ -852,7 +852,7 @@ void search_next(Context& context, NormalParams params)
} while (--params.count > 0); } while (--params.count > 0);
if (main_wrapped) if (main_wrapped)
context.print_status({"main selection search wrapped around buffer", get_face("Information")}); context.print_status({"main selection search wrapped around buffer", context.faces()["Information"]});
} }
else else
throw runtime_error("no search pattern"); throw runtime_error("no search pattern");
@ -877,7 +877,7 @@ void use_selection_as_search_pattern(Context& context, NormalParams params)
context.print_status({ context.print_status({
format("register '{}' set to '{}'", reg, fix_atom_text(patterns[sels.main_index()])), format("register '{}' set to '{}'", reg, fix_atom_text(patterns[sels.main_index()])),
get_face("Information") }); context.faces()["Information"] });
RegisterManager::instance()[reg].set(context, patterns); RegisterManager::instance()[reg].set(context, patterns);
@ -1059,7 +1059,7 @@ void keep(Context& context, NormalParams params)
void keep_pipe(Context& context, NormalParams) void keep_pipe(Context& context, NormalParams)
{ {
context.input_handler().prompt( context.input_handler().prompt(
"keep pipe:", {}, {}, get_face("Prompt"), "keep pipe:", {}, {}, context.faces()["Prompt"],
PromptFlags::DropHistoryEntriesWithBlankPrefix, shell_complete, PromptFlags::DropHistoryEntriesWithBlankPrefix, shell_complete,
[](StringView cmdline, PromptEvent event, Context& context) { [](StringView cmdline, PromptEvent event, Context& context) {
if (event != PromptEvent::Validate) if (event != PromptEvent::Validate)
@ -1216,7 +1216,7 @@ void select_object(Context& context, NormalParams params)
AutoInfo::Command, context); AutoInfo::Command, context);
context.input_handler().prompt( context.input_handler().prompt(
"object desc:", {}, {}, get_face("Prompt"), "object desc:", {}, {}, context.faces()["Prompt"],
PromptFlags::None, complete_nothing, PromptFlags::None, complete_nothing,
[count,info](StringView cmdline, PromptEvent event, Context& context) { [count,info](StringView cmdline, PromptEvent event, Context& context) {
if (event != PromptEvent::Change) if (event != PromptEvent::Change)
@ -1499,7 +1499,7 @@ void push_selections(Context& context, NormalParams)
{ {
context.push_jump(); context.push_jump();
context.print_status({ format("saved {} selections", context.selections().size()), context.print_status({ format("saved {} selections", context.selections().size()),
get_face("Information") }); context.faces()["Information"] });
} }
void align(Context& context, NormalParams) void align(Context& context, NormalParams)
@ -1813,7 +1813,7 @@ void save_selections(Context& context, NormalParams params)
RegisterManager::instance()[reg].set(context, desc); RegisterManager::instance()[reg].set(context, desc);
context.print_status({format("{} {} selections to register '{}'", context.print_status({format("{} {} selections to register '{}'",
combine ? "Combined" : "Saved", sels.size(), reg), combine ? "Combined" : "Saved", sels.size(), reg),
get_face("Information")}); context.faces()["Information"]});
}; };
if (combine and not empty) if (combine and not empty)
@ -1833,7 +1833,7 @@ void restore_selections(Context& context, NormalParams params)
context.selections_write_only() = std::move(sels); context.selections_write_only() = std::move(sels);
context.print_status({format("{} {} selections from register '{}'", context.print_status({format("{} {} selections from register '{}'",
combine ? "Combined" : "Restored", size, reg), combine ? "Combined" : "Restored", size, reg),
get_face("Information")}); context.faces()["Information"]});
}; };
if (not combine) if (not combine)
@ -1890,7 +1890,7 @@ void move_in_history(Context& context, NormalParams params)
context.print_status({ format("moved to change #{} ({})", context.print_status({ format("moved to change #{} ({})",
history_id, max_history_id), history_id, max_history_id),
get_face("Information") }); context.faces()["Information"] });
} }
else else
throw runtime_error(format("no such change: #{} ({})", throw runtime_error(format("no such change: #{} ({})",

View File

@ -2,10 +2,11 @@
#define scope_hh_INCLUDED #define scope_hh_INCLUDED
#include "alias_registry.hh" #include "alias_registry.hh"
#include "face_registry.hh"
#include "highlighter_group.hh"
#include "hook_manager.hh" #include "hook_manager.hh"
#include "keymap_manager.hh" #include "keymap_manager.hh"
#include "option_manager.hh" #include "option_manager.hh"
#include "highlighter_group.hh"
#include "utils.hh" #include "utils.hh"
namespace Kakoune namespace Kakoune
@ -19,6 +20,7 @@ public:
m_hooks(parent.hooks()), m_hooks(parent.hooks()),
m_keymaps(parent.keymaps()), m_keymaps(parent.keymaps()),
m_aliases(parent.aliases()), m_aliases(parent.aliases()),
m_faces(parent.faces()),
m_highlighters(parent.highlighters()) {} m_highlighters(parent.highlighters()) {}
OptionManager& options() { return m_options; } OptionManager& options() { return m_options; }
@ -29,6 +31,8 @@ public:
const KeymapManager& keymaps() const { return m_keymaps; } const KeymapManager& keymaps() const { return m_keymaps; }
AliasRegistry& aliases() { return m_aliases; } AliasRegistry& aliases() { return m_aliases; }
const AliasRegistry& aliases() const { return m_aliases; } const AliasRegistry& aliases() const { return m_aliases; }
FaceRegistry& faces() { return m_faces; }
const FaceRegistry& faces() const { return m_faces; }
Highlighters& highlighters() { return m_highlighters; } Highlighters& highlighters() { return m_highlighters; }
const Highlighters& highlighters() const { return m_highlighters; } const Highlighters& highlighters() const { return m_highlighters; }
@ -40,6 +44,7 @@ private:
HookManager m_hooks; HookManager m_hooks;
KeymapManager m_keymaps; KeymapManager m_keymaps;
AliasRegistry m_aliases; AliasRegistry m_aliases;
FaceRegistry m_faces;
Highlighters m_highlighters; Highlighters m_highlighters;
}; };

View File

@ -268,7 +268,7 @@ std::pair<String, int> ShellManager::eval(
client.print_status({ format("waiting for shell command to finish ({}s)", client.print_status({ format("waiting for shell command to finish ({}s)",
duration_cast<seconds>(wait_duration).count()), duration_cast<seconds>(wait_duration).count()),
get_face("Information") }); context.faces()["Information"] });
client.redraw_ifn(); client.redraw_ifn();
} }
timer.set_next_date(Clock::now() + wait_timeout); timer.set_next_date(Clock::now() + wait_timeout);