mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-29 07:58:01 -04:00
commit
28d27f49bf
6 changed files with 71 additions and 21 deletions
|
|
@ -35,6 +35,8 @@
|
||||||
(https://codeberg.org/dnkl/foot/issues/459).
|
(https://codeberg.org/dnkl/foot/issues/459).
|
||||||
* `cursor.beam-thickness` option to `foot.ini`
|
* `cursor.beam-thickness` option to `foot.ini`
|
||||||
(https://codeberg.org/dnkl/foot/issues/464).
|
(https://codeberg.org/dnkl/foot/issues/464).
|
||||||
|
* `cursor.underline-thickness` option to `foot.ini`
|
||||||
|
(https://codeberg.org/dnkl/foot/issues/524).
|
||||||
* Unicode 13 characters U+1FB70 - U+1FB8B to list of box drawing
|
* Unicode 13 characters U+1FB70 - U+1FB8B to list of box drawing
|
||||||
characters rendered by foot itself (rather than using font glyphs)
|
characters rendered by foot itself (rather than using font glyphs)
|
||||||
(https://codeberg.org/dnkl/foot/issues/471).
|
(https://codeberg.org/dnkl/foot/issues/471).
|
||||||
|
|
|
||||||
8
config.c
8
config.c
|
|
@ -1059,6 +1059,13 @@ parse_section_cursor(const char *key, const char *value, struct config *conf,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (strcmp(key, "underline-thickness") == 0) {
|
||||||
|
if (!str_to_pt_or_px(
|
||||||
|
value, &conf->cursor.underline_thickness,
|
||||||
|
conf, path, lineno, "cursor", "underline-thickness"))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
LOG_AND_NOTIFY_ERR("%s:%d: [cursor]: %s: invalid key", path, lineno, key);
|
LOG_AND_NOTIFY_ERR("%s:%d: [cursor]: %s: invalid key", path, lineno, key);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -2373,6 +2380,7 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
.cursor = 0,
|
.cursor = 0,
|
||||||
},
|
},
|
||||||
.beam_thickness = {.pt = 1.5},
|
.beam_thickness = {.pt = 1.5},
|
||||||
|
.underline_thickness = {.pt = 0., .px = -1},
|
||||||
},
|
},
|
||||||
.mouse = {
|
.mouse = {
|
||||||
.hide_when_typing = false,
|
.hide_when_typing = false,
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -157,6 +157,7 @@ struct config {
|
||||||
uint32_t cursor;
|
uint32_t cursor;
|
||||||
} color;
|
} color;
|
||||||
struct pt_or_px beam_thickness;
|
struct pt_or_px beam_thickness;
|
||||||
|
struct pt_or_px underline_thickness;
|
||||||
} cursor;
|
} cursor;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
|
|
@ -344,9 +344,21 @@ applications can change these at runtime.
|
||||||
|
|
||||||
*beam-thickness*
|
*beam-thickness*
|
||||||
Thickness (width) of the beam styled cursor. The value is in
|
Thickness (width) of the beam styled cursor. The value is in
|
||||||
_points_, and its exact value thus depends on the monitor's
|
points, and its exact value thus depends on the monitor's DPI. To
|
||||||
DPI. To instead specify a thickness in _pixels_, use the *px*
|
instead specify a thickness in pixels, use the *px* suffix:
|
||||||
suffix: e.g. *beam-thickness=2px*. Default: _1.5_
|
e.g. *beam-thickness=2px*. Default: _1.5_
|
||||||
|
|
||||||
|
*underline-thickness*
|
||||||
|
Thickness (height) of the underline styled cursor. The value is in
|
||||||
|
points, and its exact value thus depends on the monitor's DPI.
|
||||||
|
|
||||||
|
To instead specify a thickness in pixels, use the *px* suffix:
|
||||||
|
e.g. *underline-thickness=2px*.
|
||||||
|
|
||||||
|
Note that if left unset, the cursor's thickness will scale with
|
||||||
|
the font size, while if set, the size is fixed.
|
||||||
|
|
||||||
|
Default: _font underline thickness_.
|
||||||
|
|
||||||
# SECTION: mouse
|
# SECTION: mouse
|
||||||
|
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -49,6 +49,7 @@
|
||||||
# color=111111 dcdccc
|
# color=111111 dcdccc
|
||||||
# blink=no
|
# blink=no
|
||||||
# beam-thickness=1.5
|
# beam-thickness=1.5
|
||||||
|
# underline-thickness=<font underline thickness>
|
||||||
|
|
||||||
[mouse]
|
[mouse]
|
||||||
# hide-when-typing=no
|
# hide-when-typing=no
|
||||||
|
|
|
||||||
62
render.c
62
render.c
|
|
@ -299,9 +299,9 @@ draw_unfocused_block(const struct terminal *term, pixman_image_t *pix,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_beam(const struct terminal *term, pixman_image_t *pix,
|
draw_beam_cursor(const struct terminal *term, pixman_image_t *pix,
|
||||||
const struct fcft_font *font,
|
const struct fcft_font *font,
|
||||||
const pixman_color_t *color, int x, int y)
|
const pixman_color_t *color, int x, int y)
|
||||||
{
|
{
|
||||||
int baseline = y + font_baseline(term) - term->fonts[0]->ascent;
|
int baseline = y + font_baseline(term) - term->fonts[0]->ascent;
|
||||||
pixman_image_fill_rectangles(
|
pixman_image_fill_rectangles(
|
||||||
|
|
@ -313,18 +313,43 @@ draw_beam(const struct terminal *term, pixman_image_t *pix,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_underline(const struct terminal *term, pixman_image_t *pix,
|
draw_underline_with_thickness(
|
||||||
const struct fcft_font *font,
|
const struct terminal *term, pixman_image_t *pix,
|
||||||
const pixman_color_t *color, int x, int y, int cols)
|
const struct fcft_font *font,
|
||||||
|
const pixman_color_t *color, int x, int y, int cols, int thickness)
|
||||||
{
|
{
|
||||||
/* Make sure the line isn't positioned below the cell */
|
/* Make sure the line isn't positioned below the cell */
|
||||||
int y_ofs = font_baseline(term) - font->underline.position;
|
int y_ofs = font_baseline(term) - font->underline.position;
|
||||||
y_ofs = min(y_ofs, term->cell_height - font->underline.thickness);
|
y_ofs = min(y_ofs, term->cell_height - thickness);
|
||||||
|
|
||||||
pixman_image_fill_rectangles(
|
pixman_image_fill_rectangles(
|
||||||
PIXMAN_OP_SRC, pix, color,
|
PIXMAN_OP_SRC, pix, color,
|
||||||
1, &(pixman_rectangle16_t){
|
1, &(pixman_rectangle16_t){
|
||||||
x, y + y_ofs, cols * term->cell_width, font->underline.thickness});
|
x, y + y_ofs, cols * term->cell_width, thickness});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
draw_underline_cursor(const struct terminal *term, pixman_image_t *pix,
|
||||||
|
const struct fcft_font *font,
|
||||||
|
const pixman_color_t *color, int x, int y, int cols)
|
||||||
|
{
|
||||||
|
int thickness = term->conf->cursor.underline_thickness.px >= 0
|
||||||
|
? term_pt_or_px_as_pixels(
|
||||||
|
term, &term->conf->cursor.underline_thickness)
|
||||||
|
: font->underline.thickness;
|
||||||
|
|
||||||
|
draw_underline_with_thickness(
|
||||||
|
term, pix, font, color, x, y + font->underline.thickness, cols,
|
||||||
|
thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
draw_underline(const struct terminal *term, pixman_image_t *pix,
|
||||||
|
const struct fcft_font *font,
|
||||||
|
const pixman_color_t *color, int x, int y, int cols)
|
||||||
|
{
|
||||||
|
draw_underline_with_thickness(
|
||||||
|
term, pix, font, color, x, y, cols, font->underline.thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -394,7 +419,7 @@ draw_cursor(const struct terminal *term, const struct cell *cell,
|
||||||
if (likely(term->cursor_blink.state == CURSOR_BLINK_ON ||
|
if (likely(term->cursor_blink.state == CURSOR_BLINK_ON ||
|
||||||
!term->kbd_focus))
|
!term->kbd_focus))
|
||||||
{
|
{
|
||||||
draw_beam(term, pix, font, &cursor_color, x, y);
|
draw_beam_cursor(term, pix, font, &cursor_color, x, y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -402,10 +427,7 @@ draw_cursor(const struct terminal *term, const struct cell *cell,
|
||||||
if (likely(term->cursor_blink.state == CURSOR_BLINK_ON ||
|
if (likely(term->cursor_blink.state == CURSOR_BLINK_ON ||
|
||||||
!term->kbd_focus))
|
!term->kbd_focus))
|
||||||
{
|
{
|
||||||
struct fcft_font *font = attrs_to_font(term, &cell->attrs);
|
draw_underline_cursor(term, pix, font, &cursor_color, x, y, cols);
|
||||||
draw_underline(
|
|
||||||
term, pix, font, &cursor_color,
|
|
||||||
x, y + font->underline.thickness, cols);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1303,7 +1325,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat,
|
||||||
/* Bar */
|
/* Bar */
|
||||||
if (start >= 0) {
|
if (start >= 0) {
|
||||||
struct fcft_font *font = attrs_to_font(term, &start_cell->attrs);
|
struct fcft_font *font = attrs_to_font(term, &start_cell->attrs);
|
||||||
draw_beam(term, buf->pix[0], font, &cursor_color, x, y);
|
draw_beam_cursor(term, buf->pix[0], font, &cursor_color, x, y);
|
||||||
}
|
}
|
||||||
term_ime_set_cursor_rect(term, x, y, 1, term->cell_height);
|
term_ime_set_cursor_rect(term, x, y, 1, term->cell_height);
|
||||||
}
|
}
|
||||||
|
|
@ -2645,8 +2667,12 @@ render_search_box(struct terminal *term)
|
||||||
draw_underline(term, buf->pix[0], font, &fg, x, y, count);
|
draw_underline(term, buf->pix[0], font, &fg, x, y, count);
|
||||||
|
|
||||||
/* Bar-styled cursor, if in the visible area */
|
/* Bar-styled cursor, if in the visible area */
|
||||||
if (start >= 0 && start <= visible_cells)
|
if (start >= 0 && start <= visible_cells) {
|
||||||
draw_beam(term, buf->pix[0], font, &fg, x + start * term->cell_width, y);
|
draw_beam_cursor(
|
||||||
|
term, buf->pix[0], font, &fg,
|
||||||
|
x + start * term->cell_width, y);
|
||||||
|
}
|
||||||
|
|
||||||
term_ime_set_cursor_rect(term,
|
term_ime_set_cursor_rect(term,
|
||||||
WINDOW_X(x + start * term->cell_width), WINDOW_Y(y),
|
WINDOW_X(x + start * term->cell_width), WINDOW_Y(y),
|
||||||
1, term->cell_height);
|
1, term->cell_height);
|
||||||
|
|
@ -2675,7 +2701,7 @@ render_search_box(struct terminal *term)
|
||||||
/* Cursor *should* be in the visible area */
|
/* Cursor *should* be in the visible area */
|
||||||
xassert(cell_idx >= glyph_offset);
|
xassert(cell_idx >= glyph_offset);
|
||||||
xassert(cell_idx <= glyph_offset + visible_cells);
|
xassert(cell_idx <= glyph_offset + visible_cells);
|
||||||
draw_beam(term, buf->pix[0], font, &fg, x, y);
|
draw_beam_cursor(term, buf->pix[0], font, &fg, x, y);
|
||||||
term_ime_set_cursor_rect(
|
term_ime_set_cursor_rect(
|
||||||
term, WINDOW_X(x), WINDOW_Y(y), 1, term->cell_height);
|
term, WINDOW_X(x), WINDOW_Y(y), 1, term->cell_height);
|
||||||
}
|
}
|
||||||
|
|
@ -2731,7 +2757,7 @@ render_search_box(struct terminal *term)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (term->search.cursor >= term->search.len) {
|
if (term->search.cursor >= term->search.len) {
|
||||||
draw_beam(term, buf->pix[0], font, &fg, x, y);
|
draw_beam_cursor(term, buf->pix[0], font, &fg, x, y);
|
||||||
term_ime_set_cursor_rect(
|
term_ime_set_cursor_rect(
|
||||||
term, WINDOW_X(x), WINDOW_Y(y), 1, term->cell_height);
|
term, WINDOW_X(x), WINDOW_Y(y), 1, term->cell_height);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue