diff options
author | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-05-28 00:21:57 +0200 |
---|---|---|
committer | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-05-28 00:21:57 +0200 |
commit | 04faad945a56380d41cdf3757c23b918bedf1e9b (patch) | |
tree | bfc1654e4e1dab43da8f6fef81d6e41bf614f6cf /source | |
parent | 21982db45041604b645f73dc0c9b8a3914adb49d (diff) | |
parent | f1261e181c888c212c860dcd77a4f7ccb0053ffa (diff) |
Merge branch 'master' into wip/meson
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source')
-rw-r--r-- | source/css-colors.c | 154 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 2 | ||||
-rw-r--r-- | source/helper.c | 12 | ||||
-rw-r--r-- | source/rofi.c | 19 | ||||
-rw-r--r-- | source/theme.c | 63 | ||||
-rw-r--r-- | source/view.c | 21 | ||||
-rw-r--r-- | source/widgets/textbox.c | 36 | ||||
-rw-r--r-- | source/x11-helper.c | 20 |
8 files changed, 277 insertions, 50 deletions
diff --git a/source/css-colors.c b/source/css-colors.c new file mode 100644 index 00000000..cc2a6b35 --- /dev/null +++ b/source/css-colors.c @@ -0,0 +1,154 @@ +#include <stdint.h> +#include "css-colors.h" +const CSSColor CSSColors[] = { + { .name = "AliceBlue", .r = 0xF0, .g = 0xF8, .b = 0xFF }, + { .name = "AntiqueWhite", .r = 0xFA, .g = 0xEB, .b = 0xD7 }, + { .name = "Aqua", .r = 0x00, .g = 0xFF, .b = 0xFF }, + { .name = "Aquamarine", .r = 0x7F, .g = 0xFF, .b = 0xD4 }, + { .name = "Azure", .r = 0xF0, .g = 0xFF, .b = 0xFF }, + { .name = "Beige", .r = 0xF5, .g = 0xF5, .b = 0xDC }, + { .name = "Bisque", .r = 0xFF, .g = 0xE4, .b = 0xC4 }, + { .name = "Black", .r = 0x00, .g = 0x00, .b = 0x00 }, + { .name = "BlanchedAlmond", .r = 0xFF, .g = 0xEB, .b = 0xCD }, + { .name = "Blue", .r = 0x00, .g = 0x00, .b = 0xFF }, + { .name = "BlueViolet", .r = 0x8A, .g = 0x2B, .b = 0xE2 }, + { .name = "Brown", .r = 0xA5, .g = 0x2A, .b = 0x2A }, + { .name = "BurlyWood", .r = 0xDE, .g = 0xB8, .b = 0x87 }, + { .name = "CadetBlue", .r = 0x5F, .g = 0x9E, .b = 0xA0 }, + { .name = "Chartreuse", .r = 0x7F, .g = 0xFF, .b = 0x00 }, + { .name = "Chocolate", .r = 0xD2, .g = 0x69, .b = 0x1E }, + { .name = "Coral", .r = 0xFF, .g = 0x7F, .b = 0x50 }, + { .name = "CornflowerBlue", .r = 0x64, .g = 0x95, .b = 0xED }, + { .name = "Cornsilk", .r = 0xFF, .g = 0xF8, .b = 0xDC }, + { .name = "Crimson", .r = 0xDC, .g = 0x14, .b = 0x3C }, + { .name = "Cyan", .r = 0x00, .g = 0xFF, .b = 0xFF }, + { .name = "DarkBlue", .r = 0x00, .g = 0x00, .b = 0x8B }, + { .name = "DarkCyan", .r = 0x00, .g = 0x8B, .b = 0x8B }, + { .name = "DarkGoldenRod", .r = 0xB8, .g = 0x86, .b = 0x0B }, + { .name = "DarkGray", .r = 0xA9, .g = 0xA9, .b = 0xA9 }, + { .name = "DarkGrey", .r = 0xA9, .g = 0xA9, .b = 0xA9 }, + { .name = "DarkGreen", .r = 0x00, .g = 0x64, .b = 0x00 }, + { .name = "DarkKhaki", .r = 0xBD, .g = 0xB7, .b = 0x6B }, + { .name = "DarkMagenta", .r = 0x8B, .g = 0x00, .b = 0x8B }, + { .name = "DarkOliveGreen", .r = 0x55, .g = 0x6B, .b = 0x2F }, + { .name = "DarkOrange", .r = 0xFF, .g = 0x8C, .b = 0x00 }, + { .name = "DarkOrchid", .r = 0x99, .g = 0x32, .b = 0xCC }, + { .name = "DarkRed", .r = 0x8B, .g = 0x00, .b = 0x00 }, + { .name = "DarkSalmon", .r = 0xE9, .g = 0x96, .b = 0x7A }, + { .name = "DarkSeaGreen", .r = 0x8F, .g = 0xBC, .b = 0x8F }, + { .name = "DarkSlateBlue", .r = 0x48, .g = 0x3D, .b = 0x8B }, + { .name = "DarkSlateGray", .r = 0x2F, .g = 0x4F, .b = 0x4F }, + { .name = "DarkSlateGrey", .r = 0x2F, .g = 0x4F, .b = 0x4F }, + { .name = "DarkTurquoise", .r = 0x00, .g = 0xCE, .b = 0xD1 }, + { .name = "DarkViolet", .r = 0x94, .g = 0x00, .b = 0xD3 }, + { .name = "DeepPink", .r = 0xFF, .g = 0x14, .b = 0x93 }, + { .name = "DeepSkyBlue", .r = 0x00, .g = 0xBF, .b = 0xFF }, + { .name = "DimGray", .r = 0x69, .g = 0x69, .b = 0x69 }, + { .name = "DimGrey", .r = 0x69, .g = 0x69, .b = 0x69 }, + { .name = "DodgerBlue", .r = 0x1E, .g = 0x90, .b = 0xFF }, + { .name = "FireBrick", .r = 0xB2, .g = 0x22, .b = 0x22 }, + { .name = "FloralWhite", .r = 0xFF, .g = 0xFA, .b = 0xF0 }, + { .name = "ForestGreen", .r = 0x22, .g = 0x8B, .b = 0x22 }, + { .name = "Fuchsia", .r = 0xFF, .g = 0x00, .b = 0xFF }, + { .name = "Gainsboro", .r = 0xDC, .g = 0xDC, .b = 0xDC }, + { .name = "GhostWhite", .r = 0xF8, .g = 0xF8, .b = 0xFF }, + { .name = "Gold", .r = 0xFF, .g = 0xD7, .b = 0x00 }, + { .name = "GoldenRod", .r = 0xDA, .g = 0xA5, .b = 0x20 }, + { .name = "Gray", .r = 0x80, .g = 0x80, .b = 0x80 }, + { .name = "Grey", .r = 0x80, .g = 0x80, .b = 0x80 }, + { .name = "Green", .r = 0x00, .g = 0x80, .b = 0x00 }, + { .name = "GreenYellow", .r = 0xAD, .g = 0xFF, .b = 0x2F }, + { .name = "HoneyDew", .r = 0xF0, .g = 0xFF, .b = 0xF0 }, + { .name = "HotPink", .r = 0xFF, .g = 0x69, .b = 0xB4 }, + { .name = "IndianRed", .r = 0xCD, .g = 0x5C, .b = 0x5C }, + { .name = "Indigo", .r = 0x4B, .g = 0x00, .b = 0x82 }, + { .name = "Ivory", .r = 0xFF, .g = 0xFF, .b = 0xF0 }, + { .name = "Khaki", .r = 0xF0, .g = 0xE6, .b = 0x8C }, + { .name = "Lavender", .r = 0xE6, .g = 0xE6, .b = 0xFA }, + { .name = "LavenderBlush", .r = 0xFF, .g = 0xF0, .b = 0xF5 }, + { .name = "LawnGreen", .r = 0x7C, .g = 0xFC, .b = 0x00 }, + { .name = "LemonChiffon", .r = 0xFF, .g = 0xFA, .b = 0xCD }, + { .name = "LightBlue", .r = 0xAD, .g = 0xD8, .b = 0xE6 }, + { .name = "LightCoral", .r = 0xF0, .g = 0x80, .b = 0x80 }, + { .name = "LightCyan", .r = 0xE0, .g = 0xFF, .b = 0xFF }, + { .name = "LightGoldenRodYellow", .r = 0xFA, .g = 0xFA, .b = 0xD2 }, + { .name = "LightGray", .r = 0xD3, .g = 0xD3, .b = 0xD3 }, + { .name = "LightGrey", .r = 0xD3, .g = 0xD3, .b = 0xD3 }, + { .name = "LightGreen", .r = 0x90, .g = 0xEE, .b = 0x90 }, + { .name = "LightPink", .r = 0xFF, .g = 0xB6, .b = 0xC1 }, + { .name = "LightSalmon", .r = 0xFF, .g = 0xA0, .b = 0x7A }, + { .name = "LightSeaGreen", .r = 0x20, .g = 0xB2, .b = 0xAA }, + { .name = "LightSkyBlue", .r = 0x87, .g = 0xCE, .b = 0xFA }, + { .name = "LightSlateGray", .r = 0x77, .g = 0x88, .b = 0x99 }, + { .name = "LightSlateGrey", .r = 0x77, .g = 0x88, .b = 0x99 }, + { .name = "LightSteelBlue", .r = 0xB0, .g = 0xC4, .b = 0xDE }, + { .name = "LightYellow", .r = 0xFF, .g = 0xFF, .b = 0xE0 }, + { .name = "Lime", .r = 0x00, .g = 0xFF, .b = 0x00 }, + { .name = "LimeGreen", .r = 0x32, .g = 0xCD, .b = 0x32 }, + { .name = "Linen", .r = 0xFA, .g = 0xF0, .b = 0xE6 }, + { .name = "Magenta", .r = 0xFF, .g = 0x00, .b = 0xFF }, + { .name = "Maroon", .r = 0x80, .g = 0x00, .b = 0x00 }, + { .name = "MediumAquaMarine", .r = 0x66, .g = 0xCD, .b = 0xAA }, + { .name = "MediumBlue", .r = 0x00, .g = 0x00, .b = 0xCD }, + { .name = "MediumOrchid", .r = 0xBA, .g = 0x55, .b = 0xD3 }, + { .name = "MediumPurple", .r = 0x93, .g = 0x70, .b = 0xDB }, + { .name = "MediumSeaGreen", .r = 0x3C, .g = 0xB3, .b = 0x71 }, + { .name = "MediumSlateBlue", .r = 0x7B, .g = 0x68, .b = 0xEE }, + { .name = "MediumSpringGreen", .r = 0x00, .g = 0xFA, .b = 0x9A }, + { .name = "MediumTurquoise", .r = 0x48, .g = 0xD1, .b = 0xCC }, + { .name = "MediumVioletRed", .r = 0xC7, .g = 0x15, .b = 0x85 }, + { .name = "MidnightBlue", .r = 0x19, .g = 0x19, .b = 0x70 }, + { .name = "MintCream", .r = 0xF5, .g = 0xFF, .b = 0xFA }, + { .name = "MistyRose", .r = 0xFF, .g = 0xE4, .b = 0xE1 }, + { .name = "Moccasin", .r = 0xFF, .g = 0xE4, .b = 0xB5 }, + { .name = "NavajoWhite", .r = 0xFF, .g = 0xDE, .b = 0xAD }, + { .name = "Navy", .r = 0x00, .g = 0x00, .b = 0x80 }, + { .name = "OldLace", .r = 0xFD, .g = 0xF5, .b = 0xE6 }, + { .name = "Olive", .r = 0x80, .g = 0x80, .b = 0x00 }, + { .name = "OliveDrab", .r = 0x6B, .g = 0x8E, .b = 0x23 }, + { .name = "Orange", .r = 0xFF, .g = 0xA5, .b = 0x00 }, + { .name = "OrangeRed", .r = 0xFF, .g = 0x45, .b = 0x00 }, + { .name = "Orchid", .r = 0xDA, .g = 0x70, .b = 0xD6 }, + { .name = "PaleGoldenRod", .r = 0xEE, .g = 0xE8, .b = 0xAA }, + { .name = "PaleGreen", .r = 0x98, .g = 0xFB, .b = 0x98 }, + { .name = "PaleTurquoise", .r = 0xAF, .g = 0xEE, .b = 0xEE }, + { .name = "PaleVioletRed", .r = 0xDB, .g = 0x70, .b = 0x93 }, + { .name = "PapayaWhip", .r = 0xFF, .g = 0xEF, .b = 0xD5 }, + { .name = "PeachPuff", .r = 0xFF, .g = 0xDA, .b = 0xB9 }, + { .name = "Peru", .r = 0xCD, .g = 0x85, .b = 0x3F }, + { .name = "Pink", .r = 0xFF, .g = 0xC0, .b = 0xCB }, + { .name = "Plum", .r = 0xDD, .g = 0xA0, .b = 0xDD }, + { .name = "PowderBlue", .r = 0xB0, .g = 0xE0, .b = 0xE6 }, + { .name = "Purple", .r = 0x80, .g = 0x00, .b = 0x80 }, + { .name = "RebeccaPurple", .r = 0x66, .g = 0x33, .b = 0x99 }, + { .name = "Red", .r = 0xFF, .g = 0x00, .b = 0x00 }, + { .name = "RosyBrown", .r = 0xBC, .g = 0x8F, .b = 0x8F }, + { .name = "RoyalBlue", .r = 0x41, .g = 0x69, .b = 0xE1 }, + { .name = "SaddleBrown", .r = 0x8B, .g = 0x45, .b = 0x13 }, + { .name = "Salmon", .r = 0xFA, .g = 0x80, .b = 0x72 }, + { .name = "SandyBrown", .r = 0xF4, .g = 0xA4, .b = 0x60 }, + { .name = "SeaGreen", .r = 0x2E, .g = 0x8B, .b = 0x57 }, + { .name = "SeaShell", .r = 0xFF, .g = 0xF5, .b = 0xEE }, + { .name = "Sienna", .r = 0xA0, .g = 0x52, .b = 0x2D }, + { .name = "Silver", .r = 0xC0, .g = 0xC0, .b = 0xC0 }, + { .name = "SkyBlue", .r = 0x87, .g = 0xCE, .b = 0xEB }, + { .name = "SlateBlue", .r = 0x6A, .g = 0x5A, .b = 0xCD }, + { .name = "SlateGray", .r = 0x70, .g = 0x80, .b = 0x90 }, + { .name = "SlateGrey", .r = 0x70, .g = 0x80, .b = 0x90 }, + { .name = "Snow", .r = 0xFF, .g = 0xFA, .b = 0xFA }, + { .name = "SpringGreen", .r = 0x00, .g = 0xFF, .b = 0x7F }, + { .name = "SteelBlue", .r = 0x46, .g = 0x82, .b = 0xB4 }, + { .name = "Tan", .r = 0xD2, .g = 0xB4, .b = 0x8C }, + { .name = "Teal", .r = 0x00, .g = 0x80, .b = 0x80 }, + { .name = "Thistle", .r = 0xD8, .g = 0xBF, .b = 0xD8 }, + { .name = "Tomato", .r = 0xFF, .g = 0x63, .b = 0x47 }, + { .name = "Turquoise", .r = 0x40, .g = 0xE0, .b = 0xD0 }, + { .name = "Violet", .r = 0xEE, .g = 0x82, .b = 0xEE }, + { .name = "Wheat", .r = 0xF5, .g = 0xDE, .b = 0xB3 }, + { .name = "White", .r = 0xFF, .g = 0xFF, .b = 0xFF }, + { .name = "WhiteSmoke", .r = 0xF5, .g = 0xF5, .b = 0xF5 }, + { .name = "Yellow", .r = 0xFF, .g = 0xFF, .b = 0x00 }, + { .name = "YellowGreen", .r = 0x9A, .g = 0xCD, .b = 0x32 } +}; + +const unsigned int num_CSSColors = sizeof ( CSSColors ) / sizeof ( *CSSColors ); diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index a639646c..36392da4 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -298,7 +298,7 @@ static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned else { full_path = g_strdup ( path ); } - glob_t globbuf = { 0, }; + glob_t globbuf = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 }; if ( glob ( full_path, 0, NULL, &globbuf ) == 0 ) { for ( size_t iter = 0; iter < globbuf.gl_pathc; iter++ ) { diff --git a/source/helper.c b/source/helper.c index d31a4e20..7fa07478 100644 --- a/source/helper.c +++ b/source/helper.c @@ -423,6 +423,18 @@ PangoAttrList *helper_token_match_get_pango_attr ( ThemeHighlight th, GRegex **t pa->end_index = end; pango_attr_list_insert ( retv, pa ); } + if ( th.style & HL_STRIKETHROUGH ) { + PangoAttribute *pa = pango_attr_strikethrough_new ( TRUE ); + pa->start_index = start; + pa->end_index = end; + pango_attr_list_insert ( retv, pa ); + } + if ( th.style & HL_SMALL_CAPS ) { + PangoAttribute *pa = pango_attr_variant_new ( PANGO_VARIANT_SMALL_CAPS ); + pa->start_index = start; + pa->end_index = end; + pango_attr_list_insert ( retv, pa ); + } if ( th.style & HL_ITALIC ) { PangoAttribute *pa = pango_attr_style_new ( PANGO_STYLE_ITALIC ); pa->start_index = start; diff --git a/source/rofi.c b/source/rofi.c index 4ca2460e..e802f0ed 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1148,17 +1148,16 @@ int main ( int argc, char *argv[] ) // Load in config from X resources. config_parse_xresource_options ( xcb ); config_parse_xresource_options_file ( config_path ); - - find_arg_str ( "-theme", &( config.theme ) ); - if ( config.theme ) { - TICK_N ( "Parse theme" ); - if ( rofi_theme_parse_file ( config.theme ) ) { - // TODO: instantiate fallback theme.? - rofi_theme_free ( rofi_theme ); - rofi_theme = NULL; - } - TICK_N ( "Parsed theme" ); + } + find_arg_str ( "-theme", &( config.theme ) ); + if ( config.theme ) { + TICK_N ( "Parse theme" ); + if ( rofi_theme_parse_file ( config.theme ) ) { + // TODO: instantiate fallback theme.? + rofi_theme_free ( rofi_theme ); + rofi_theme = NULL; } + TICK_N ( "Parsed theme" ); } // Parse command line for settings, independent of other -no-config. config_parse_cmd_options ( ); diff --git a/source/theme.c b/source/theme.c index 274a866a..1c4711c6 100644 --- a/source/theme.c +++ b/source/theme.c @@ -170,15 +170,18 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p if ( p->value.highlight.style & HL_UNDERLINE ) { printf ( "underline " ); } + if ( p->value.highlight.style & HL_STRIKETHROUGH ) { + printf ( "strikethrough " ); + } if ( p->value.highlight.style & HL_ITALIC ) { printf ( "italic " ); } if ( p->value.highlight.style & HL_COLOR ) { - printf ( "#%02X%02X%02X%02X", - (unsigned char) ( p->value.highlight.color.alpha * 255.0 ), - (unsigned char) ( p->value.highlight.color.red * 255.0 ), - (unsigned char) ( p->value.highlight.color.green * 255.0 ), - (unsigned char) ( p->value.highlight.color.blue * 255.0 ) ); + printf ( "rgba ( %.0f, %.0f, %.0f, %.0f %% )", + ( p->value.highlight.color.red * 255.0 ), + ( p->value.highlight.color.green * 255.0 ), + ( p->value.highlight.color.blue * 255.0 ), + ( p->value.highlight.color.alpha * 100.0 ) ); } printf ( ";" ); break; @@ -198,11 +201,11 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p printf ( "%s;", p->value.b ? "true" : "false" ); break; case P_COLOR: - printf ( "#%02X%02X%02X%02X;", - (unsigned char) ( p->value.color.alpha * 255.0 ), - (unsigned char) ( p->value.color.red * 255.0 ), - (unsigned char) ( p->value.color.green * 255.0 ), - (unsigned char) ( p->value.color.blue * 255.0 ) ); + printf ( "rgba ( %.0f, %.0f, %.0f, %.0f %% );", + ( p->value.color.red * 255.0 ), + ( p->value.color.green * 255.0 ), + ( p->value.color.blue * 255.0 ), + ( p->value.color.alpha * 100.0 ) ); break; case P_PADDING: if ( distance_compare ( p->value.padding.top, p->value.padding.bottom ) && @@ -318,7 +321,7 @@ extern FILE* yyin; */ void yyerror ( YYLTYPE *yylloc, const char *what, const char* s ) { - char *what_esc = g_markup_escape_text ( what, -1 ); + char *what_esc = what ? g_markup_escape_text ( what, -1 ) : g_strdup ( "" ); GString *str = g_string_new ( "" ); g_string_printf ( str, "<big><b>Error while parsing theme:</b></big> <i>%s</i>\n", what_esc ); g_free ( what_esc ); @@ -636,25 +639,39 @@ gboolean rofi_theme_is_empty ( void ) #ifdef THEME_CONVERTER +static char * rofi_theme_convert_color ( char *col ) +{ + char *r = g_strstrip ( col ); + if ( *r == '#' && strlen ( r ) == 9 ) { + char t1 = r[7]; + char t2 = r[8]; + r[7] = r[1]; + r[8] = r[2]; + r[1] = t1; + r[2] = t2; + } + + return r; +} void rofi_theme_convert_old ( void ) { if ( config.color_window ) { - char **retv = g_strsplit ( config.color_window, ",", -1 ); - const char const *conf[] = { + char **retv = g_strsplit ( config.color_window, ",", -1 ); + const char * const conf[] = { "* { background: %s; }", "* { bordercolor: %s; }", "* { separatorcolor: %s; }" }; for ( int i = 0; retv && retv[i] && i < 3; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } g_strfreev ( retv ); } if ( config.color_normal ) { - char **retv = g_strsplit ( config.color_normal, ",", -1 ); - const char const *conf[] = { + char **retv = g_strsplit ( config.color_normal, ",", -1 ); + const char * const conf[] = { "* { normal-background: %s; }", "* { foreground: %s; normal-foreground: @foreground; alternate-normal-foreground: @foreground; }", "* { alternate-normal-background: %s; }", @@ -662,15 +679,15 @@ void rofi_theme_convert_old ( void ) "* { selected-normal-foreground: %s; }" }; for ( int i = 0; retv && retv[i]; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } g_strfreev ( retv ); } if ( config.color_urgent ) { - char **retv = g_strsplit ( config.color_urgent, ",", -1 ); - const char const *conf[] = { + char **retv = g_strsplit ( config.color_urgent, ",", -1 ); + const char * const conf[] = { "* { urgent-background: %s; }", "* { urgent-foreground: %s; alternate-urgent-foreground: @urgent-foreground;}", "* { alternate-urgent-background: %s; }", @@ -678,15 +695,15 @@ void rofi_theme_convert_old ( void ) "* { selected-urgent-foreground: %s; }" }; for ( int i = 0; retv && retv[i]; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } g_strfreev ( retv ); } if ( config.color_active ) { - char **retv = g_strsplit ( config.color_active, ",", -1 ); - const char const *conf[] = { + char **retv = g_strsplit ( config.color_active, ",", -1 ); + const char * const conf[] = { "* { active-background: %s; }", "* { active-foreground: %s; alternate-active-foreground: @active-foreground;}", "* { alternate-active-background: %s; }", @@ -694,7 +711,7 @@ void rofi_theme_convert_old ( void ) "* { selected-active-foreground: %s; }" }; for ( int i = 0; retv && retv[i]; i++ ) { - char *str = g_strdup_printf ( conf[i], retv[i] ); + char *str = g_strdup_printf ( conf[i], rofi_theme_convert_color ( retv[i] ) ); rofi_theme_parse_string ( str ); g_free ( str ); } diff --git a/source/view.c b/source/view.c index 3186c873..416bad7d 100644 --- a/source/view.c +++ b/source/view.c @@ -68,6 +68,11 @@ #include "theme.h" #include "xcb.h" + +#ifdef XkBCOMMON_HAS_CONSUMED2 +#define xkb_state_key_get_consumed_mods( s, k ) xkb_state_key_get_consumed_mods2 ( s, k, XKB_CONSUMED_MODE_GTK ) +#endif + /** * @param state The handle to the view * @param qr Indicate if queue_redraw should be called on changes. @@ -709,8 +714,8 @@ void __create_window ( MenuFlags menu_flags ) } // Setup font. // Dummy widget. - container *win = container_create ( "window.box" ); - const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font ); + container *win = container_create ( "window.box" ); + const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font ); if ( font ) { PangoFontDescription *pfd = pango_font_description_from_string ( font ); if ( helper_validate_font ( pfd, font ) ) { @@ -1292,7 +1297,19 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio break; // If you add a binding here, make sure to add it to textbox_keybinding too case MOVE_CHAR_BACK: + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_left ( state->list_view ); + } + break; + } case MOVE_CHAR_FORWARD: + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_right ( state->list_view ); + } + break; + } case CLEAR_LINE: case MOVE_FRONT: case MOVE_END: diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 16e1ed69..c0761f11 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -135,7 +135,7 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType if ( helper_validate_font ( tbfc->pfd, font ) ) { tbfc->metrics = pango_context_get_metrics ( p_context, tbfc->pfd, NULL ); // Cast away consts. (*yuck*) because table_insert does not know it is const. - g_hash_table_insert ( tbfc_cache, (char *)font, tbfc ); + g_hash_table_insert ( tbfc_cache, (char *) font, tbfc ); } else { pango_font_description_free ( tbfc->pfd ); @@ -173,7 +173,7 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType /** * State names used for theming. */ -const char const *const theme_prop_names[][3] = { +const char *const theme_prop_names[][3] = { /** Normal row */ { "normal.normal", "selected.normal", "alternate.normal" }, /** Urgent row */ @@ -405,20 +405,28 @@ void textbox_cursor ( textbox *tb, int pos ) * @param tb Handle to the textbox * * Move cursor one position forward. + * + * @returns if cursor was moved. */ -static void textbox_cursor_inc ( textbox *tb ) +static int textbox_cursor_inc ( textbox *tb ) { + int old = tb->cursor; textbox_cursor ( tb, tb->cursor + 1 ); + return old != tb->cursor; } /** * @param tb Handle to the textbox * * Move cursor one position backward. + * + * @returns if cursor was moved. */ -static void textbox_cursor_dec ( textbox *tb ) +static int textbox_cursor_dec ( textbox *tb ) { + int old = tb->cursor; textbox_cursor ( tb, tb->cursor - 1 ); + return old != tb->cursor; } // Move word right @@ -625,12 +633,10 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action ) { // Left or Ctrl-b case MOVE_CHAR_BACK: - textbox_cursor_dec ( tb ); - return 2; + return ( textbox_cursor_dec ( tb ) == TRUE ) ? 2 : 0; // Right or Ctrl-F case MOVE_CHAR_FORWARD: - textbox_cursor_inc ( tb ); - return 2; + return ( textbox_cursor_inc ( tb ) == TRUE ) ? 2 : 0; // Ctrl-U: Kill from the beginning to the end of the line. case CLEAR_LINE: textbox_text ( tb, "" ); @@ -791,3 +797,17 @@ int textbox_get_estimated_height ( const textbox *tb, int eh ) int height = pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics ); return ( eh * height ) / PANGO_SCALE + widget_padding_get_padding_height ( WIDGET ( tb ) ); } +int textbox_get_desired_width ( widget *wid ) +{ + textbox *tb = (textbox *) wid; + unsigned int offset = ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0; + if ( tb->flags & TB_AUTOWIDTH ) { + return textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( wid ) + offset; + } + int width = 0; + pango_layout_set_width ( tb->layout, -1); + width = textbox_get_font_width ( tb ); + // Restore. + pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ); + return width + widget_padding_get_padding_width ( wid ) + offset; +} diff --git a/source/x11-helper.c b/source/x11-helper.c index 0e58d829..5e1dce04 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -659,11 +659,13 @@ unsigned int x11_get_current_mask ( xkb_stuff *xkb ) // convert a Mod+key arg to mod mask and keysym gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key, gboolean *release, GString *str ) { - char *input_key = g_strdup ( combo ); - char *mod_key = input_key; - char *error_msg = NULL; - unsigned int modmask = 0; - xkb_keysym_t sym = XKB_KEY_NoSymbol; + char *input_key = g_strdup ( combo ); + char *mod_key = input_key; + char *error_msg = NULL; + unsigned int last_modmask = 0; + unsigned int modmask = 0; + xkb_keysym_t last_sym = XKB_KEY_NoSymbol; + xkb_keysym_t sym = XKB_KEY_NoSymbol; // Test if this works on release. if ( g_str_has_prefix ( mod_key, "!" ) ) { ++mod_key; @@ -676,6 +678,8 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key // Remove trailing and leading spaces. entry = g_strstrip ( entry ); // Compare against lowered version. + last_modmask = modmask; + last_sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS ); char *entry_lowered = g_utf8_strdown ( entry, -1 ); if ( g_utf8_collate ( entry_lowered, "shift" ) == 0 ) { modmask |= x11_mod_masks[X11MOD_SHIFT]; @@ -720,7 +724,7 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key if ( sym != XKB_KEY_NoSymbol ) { error_msg = g_markup_printf_escaped ( "Only one (non modifier) key can be bound per binding: <b>%s</b> is invalid.\n", entry ); } - sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS ); + sym = last_sym; if ( sym == XKB_KEY_NoSymbol ) { error_msg = g_markup_printf_escaped ( "∙ Key <i>%s</i> is not understood\n", entry ); } @@ -730,6 +734,10 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key g_strfreev ( entries ); g_free ( input_key ); + if ( ( sym == XKB_KEY_NoSymbol ) && ( last_sym != XKB_KEY_NoSymbol ) ) { + sym = last_sym; + modmask = last_modmask; + } if ( error_msg ) { char *name = g_markup_escape_text ( combo, -1 ); |