Rename :colalias to :face and update documentation

This commit is contained in:
Maxime Coste 2014-07-12 10:55:50 +01:00
parent 608e188960
commit d0d4108085
3 changed files with 58 additions and 45 deletions

View File

@ -588,21 +588,20 @@ and
general highlighters are: general highlighters are:
* +regex <ex> <color>...+: highlight a regex, takes the regex as first parameter, * +regex <ex> <capture_id>:<face>...+: highlight a regex, takes the regex as
followed by any number of color parameters. color format is: first parameter, followed by any number of face parameters.
<capture_id>:<fg_color>[,<bg_color>]
For example: `:addhl regex //(\h+TODO:)?[^\n]+ 0:cyan 1:yellow,red` For example: `:addhl regex //(\h+TODO:)?[^\n]+ 0:cyan 1:yellow,red`
will highlight C++ style comments in cyan, with an eventual 'TODO:' in will highlight C++ style comments in cyan, with an eventual 'TODO:' in
yellow on red background. yellow on red background.
* +search <color>+: highlight every matches to the current search pattern. takes * +search+: highlight every matches to the current search pattern with the
one parameter for the color to apply to highlighted elements. +Search+ face
* +flag_lines <flag> <option_name>+: add a column in front of text, and display the * +flag_lines <flag> <option_name>+: add a column in front of text, and display the
given flag in it for everly lines contained in the int-list option named given flag in it for everly lines contained in the int-list option named
<option_name>. <option_name>.
* +show_matching+: highlight matching char of the character under the selections * +show_matching+: highlight matching char of the character under the selections
cursor using +MatchingChar+ color alias. cursor using +MatchingChar+ face.
* +number_lines+: show line numbers * +number_lines+: show line numbers
* +fill <color>+: fill with given color, mostly useful with region highlighters * +fill <face>+: fill using given face, mostly useful with region highlighters
(see below) (see below)
Highlighting Groups Highlighting Groups
@ -814,15 +813,25 @@ with +scope+ being one of +global, buffer or window+ (or any prefix),
mode being +insert, normal, prompt or menu+ (or any prefix), +key+ being mode being +insert, normal, prompt or menu+ (or any prefix), +key+ being
a single key name and +keys+ a list of keys. a single key name and +keys+ a list of keys.
Color Aliases Faces
------------- -----
Color aliases give a name to a pair of foreground/background colors, and A Face refer the how specified text is displayed, a Face has a foreground
can be used in place of them. color, a background color, and some attributes.
-------------------------- Faces can be defined and modified with the face command.
:colalias <name> <fg_color[,bg_color]>
-------------------------- -----------------------
:face <name> <facespec>
-----------------------
Any place requiring a face can take either a face name defined with the +face+
command or a direct face description (called _facespec_) with the following
syntax:
--------------------------------
fg_color[,bg_color][+attributes]
--------------------------------
fg_color and bg_color can be: fg_color and bg_color can be:
@ -832,27 +841,31 @@ fg_color and bg_color can be:
not specifying bg_color uses +default+ not specifying bg_color uses +default+
In place of +<fg_color[,bg_color]>+, another color alias name can be referenced. attributes is a string of letters each defining an attributes:
Using color alias instead of colorspec permits to change the effective colors * +u+: Underline
* +r+: Reverse
* +b+: Bold
Using named faces instead of facespec permits to change the effective faces
afterward. afterward.
there are some builtins color aliases used by internal Kakoune functionalities: there are some builtins faces used by internal Kakoune functionalities:
* +PrimarySelection+: main selection color for every selected character except * +PrimarySelection+: main selection face for every selected character except
the cursor the cursor
* +SecondarySelection+: secondary selection color for every selected character * +SecondarySelection+: secondary selection face for every selected character
except the cursor except the cursor
* +PrimaryCursor+: cursor of the primary selection * +PrimaryCursor+: cursor of the primary selection
* +SecondaryCursor+: cursor of the secondary selection * +SecondaryCursor+: cursor of the secondary selection
* +LineNumbers+: colors used by the number_lines highlighter * +LineNumbers+: face used by the number_lines highlighter
* +MenuForeground+: colors for the selected element in menus * +MenuForeground+: face for the selected element in menus
* +MenuBackground+: colors for the not selected elements in menus * +MenuBackground+: face for the not selected elements in menus
* +Information+: colors the informations windows and information messages * +Information+: face for the informations windows and information messages
* +Error+: colors of error messages * +Error+: face of error messages
* +StatusLine+: colors used for the status line * +StatusLine+: face used for the status line
* +StatusCursor+: colors used for the status line cursor * +StatusCursor+: face used for the status line cursor
* +Prompt+: colors used prompt displayed on the status line * +Prompt+: face used prompt displayed on the status line
Shell expansion Shell expansion
--------------- ---------------

View File

@ -1,14 +1,14 @@
# define color scheme # define color scheme
colalias value red face value red
colalias type yellow face type yellow
colalias identifier cyan face identifier cyan
colalias string magenta face string magenta
colalias error default,red face error default,red
colalias keyword blue face keyword blue
colalias operator yellow face operator yellow
colalias attribute green face attribute green
colalias comment cyan face comment cyan
colalias macro magenta face macro magenta
def -shell-params runtime %{ %sh{ def -shell-params runtime %{ %sh{
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do

View File

@ -1245,20 +1245,20 @@ const CommandDesc try_catch_cmd = {
} }
}; };
static Completions complete_colalias(const Context&, CompletionFlags flags, static Completions complete_face(const 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)}; FaceRegistry::instance().complete_alias_name(prefix, cursor_pos)};
} }
const CommandDesc define_color_alias_cmd = { const CommandDesc face_cmd = {
"colalias", "face",
"ca", nullptr,
"colalias <name> <color>: set <name> to refer to color <color> (which can be an alias itself)", "face <name> <facespec>: set face <name> to refer to <facespec>\n",
ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::None, 2, 2 }, ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::None, 2, 2 },
CommandFlags::None, CommandFlags::None,
PerArgumentCommandCompleter({ complete_colalias, complete_colalias }), PerArgumentCommandCompleter({ complete_face, complete_face }),
[](const ParametersParser& parser, Context& context) [](const ParametersParser& parser, Context& context)
{ {
FaceRegistry::instance().register_alias(parser[0], parser[1], true); FaceRegistry::instance().register_alias(parser[0], parser[1], true);
@ -1382,7 +1382,7 @@ void register_commands()
register_command(cm, menu_cmd); register_command(cm, menu_cmd);
register_command(cm, info_cmd); register_command(cm, info_cmd);
register_command(cm, try_catch_cmd); register_command(cm, try_catch_cmd);
register_command(cm, define_color_alias_cmd); register_command(cm, face_cmd);
register_command(cm, set_client_name_cmd); register_command(cm, set_client_name_cmd);
register_command(cm, set_register_cmd); register_command(cm, set_register_cmd);
register_command(cm, change_working_directory_cmd); register_command(cm, change_working_directory_cmd);