1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[Textbox] Cursor goes over, not under. allow cursor outline.

This commit is contained in:
Dave Davenport 2022-12-23 22:11:22 +01:00
parent 0ff6ff21c3
commit 3d73cf2554
3 changed files with 41 additions and 19 deletions

View file

@ -1537,6 +1537,12 @@ The text appears to the right of the tab stop position (other alignments are not
.IP \(bu 2 .IP \(bu 2
\fBcursor-color\fP: The color used to draw the cursor. \fBcursor-color\fP: The color used to draw the cursor.
.IP \(bu 2 .IP \(bu 2
\fBcursor-outline\fP: Enable a border (outline) around the cursor. (Boolean)
.IP \(bu 2
\fBcursor-outline-width\fP: The width of the border around the cursor. (Double)
.IP \(bu 2
\fBcursor-outline-color\fP: The color to use for the cursor outline. (Color)
.IP \(bu 2
\fBtext-outline\fP: Enable a border (outline) around the text. (Boolean) \fBtext-outline\fP: Enable a border (outline) around the text. (Boolean)
.IP \(bu 2 .IP \(bu 2
\fBtext-outline-width\fP: The width of the border around the text. (Double) \fBtext-outline-width\fP: The width of the border around the text. (Double)

View file

@ -951,6 +951,9 @@ The following properties are currently supported:
The text appears to the right of the tab stop position (other alignments are not supported yet). The text appears to the right of the tab stop position (other alignments are not supported yet).
* **cursor-width**: The width of the cursor. * **cursor-width**: The width of the cursor.
* **cursor-color**: The color used to draw the cursor. * **cursor-color**: The color used to draw the cursor.
* **cursor-outline**: Enable a border (outline) around the cursor. (Boolean)
* **cursor-outline-width**: The width of the border around the cursor. (Double)
* **cursor-outline-color**: The color to use for the cursor outline. (Color)
* **text-outline**: Enable a border (outline) around the text. (Boolean) * **text-outline**: Enable a border (outline) around the text. (Boolean)
* **text-outline-width**: The width of the border around the text. (Double) * **text-outline-width**: The width of the border around the text. (Double)
* **text-outline-color**: The color to use for the text outline. (Color) * **text-outline-color**: The color to use for the text outline. (Color)

View file

@ -518,6 +518,28 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
} }
} }
// draw the text
cairo_save(draw);
cairo_reset_clip(draw);
gboolean show_outline =
rofi_theme_get_boolean(WIDGET(tb), "text-outline", FALSE);
if (tb->show_placeholder) {
rofi_theme_get_color(WIDGET(tb), "placeholder-color", draw);
show_outline = FALSE;
}
pango_cairo_show_layout(draw, tb->layout);
if (show_outline) {
rofi_theme_get_color(WIDGET(tb), "text-outline-color", draw);
double width = rofi_theme_get_double(WIDGET(tb), "text-outline-width", 0.5);
pango_cairo_layout_path(draw, tb->layout);
cairo_set_line_width(draw, width);
cairo_stroke(draw);
}
cairo_restore(draw);
// draw the cursor // draw the cursor
if (tb->flags & TB_EDITABLE) { if (tb->flags & TB_EDITABLE) {
// We want to place the cursor based on the text shown. // We want to place the cursor based on the text shown.
@ -544,28 +566,19 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
rofi_theme_get_color(WIDGET(tb), "cursor-color", draw); rofi_theme_get_color(WIDGET(tb), "cursor-color", draw);
cairo_rectangle(draw, x + cursor_x, y + cursor_y, cursor_pixel_width, cairo_rectangle(draw, x + cursor_x, y + cursor_y, cursor_pixel_width,
cursor_height); cursor_height);
cairo_fill(draw); if (rofi_theme_get_boolean(WIDGET(tb), "cursor-outline", FALSE)) {
cairo_fill_preserve(draw);
rofi_theme_get_color(WIDGET(tb), "cursor-outline-color", draw);
double width =
rofi_theme_get_double(WIDGET(tb), "cursor-outline-width", 0.5);
cairo_set_line_width(draw, width);
cairo_stroke(draw);
} else {
cairo_fill(draw);
}
cairo_restore(draw); cairo_restore(draw);
} }
} }
// draw the text
cairo_save(draw);
cairo_reset_clip(draw);
if (tb->show_placeholder) {
rofi_theme_get_color(WIDGET(tb), "placeholder-color", draw);
}
pango_cairo_show_layout(draw, tb->layout);
if (rofi_theme_get_boolean(WIDGET(tb), "text-outline", FALSE)) {
rofi_theme_get_color(WIDGET(tb), "text-outline-color", draw);
double width = rofi_theme_get_double(WIDGET(tb), "text-outline-width", 0.5);
pango_cairo_layout_path(draw, tb->layout);
cairo_set_line_width(draw, width);
cairo_stroke(draw);
}
cairo_restore(draw);
} }
// cursor handling for edit mode // cursor handling for edit mode