mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-07 04:34:03 -05:00
commit
29b697a9af
10 changed files with 57 additions and 29 deletions
|
|
@ -33,6 +33,9 @@
|
||||||
* Support for DECSET/DECRST 2026, as an alternative to the existing
|
* Support for DECSET/DECRST 2026, as an alternative to the existing
|
||||||
"synchronized updates" DCS sequences
|
"synchronized updates" DCS sequences
|
||||||
(https://codeberg.org/dnkl/foot/issues/459).
|
(https://codeberg.org/dnkl/foot/issues/459).
|
||||||
|
* `cursor.beam-thickness` option to `foot.ini`
|
||||||
|
(https://codeberg.org/dnkl/foot/issues/464).
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
@ -43,6 +46,11 @@
|
||||||
foreground and background colors are the same, making the
|
foreground and background colors are the same, making the
|
||||||
highlighted text legible
|
highlighted text legible
|
||||||
(https://codeberg.org/dnkl/foot/issues/455).
|
(https://codeberg.org/dnkl/foot/issues/455).
|
||||||
|
* `cursor.style=bar` to `cursor.style=beam`. `bar` remains a
|
||||||
|
recognized value, but will eventually be deprecated, and removed.
|
||||||
|
* Point values in `line-height`, `letter-spacing`,
|
||||||
|
`horizontal-letter-offset` and `vertical-letter-offset` are now
|
||||||
|
rounded, not truncated, when translated to pixel values.
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
||||||
15
config.c
15
config.c
|
|
@ -941,13 +941,14 @@ parse_section_cursor(const char *key, const char *value, struct config *conf,
|
||||||
if (strcmp(key, "style") == 0) {
|
if (strcmp(key, "style") == 0) {
|
||||||
if (strcmp(value, "block") == 0)
|
if (strcmp(value, "block") == 0)
|
||||||
conf->cursor.style = CURSOR_BLOCK;
|
conf->cursor.style = CURSOR_BLOCK;
|
||||||
else if (strcmp(value, "bar") == 0)
|
else if (strcmp(value, "beam") == 0 || strcmp(value, "bar") == 0)
|
||||||
conf->cursor.style = CURSOR_BAR;
|
conf->cursor.style = CURSOR_BEAM;
|
||||||
else if (strcmp(value, "underline") == 0)
|
else if (strcmp(value, "underline") == 0)
|
||||||
conf->cursor.style = CURSOR_UNDERLINE;
|
conf->cursor.style = CURSOR_UNDERLINE;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
LOG_AND_NOTIFY_ERR("%s:%d: invalid 'style': %s", path, lineno, value);
|
LOG_AND_NOTIFY_ERR("%s:%d: style: one of block, beam or underline",
|
||||||
|
path, lineno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -967,6 +968,13 @@ parse_section_cursor(const char *key, const char *value, struct config *conf,
|
||||||
conf->cursor.color.cursor |= 1u << 31;
|
conf->cursor.color.cursor |= 1u << 31;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (strcmp(key, "beam-thickness") == 0) {
|
||||||
|
if (!str_to_pt_or_px(
|
||||||
|
value, &conf->cursor.beam_thickness,
|
||||||
|
conf, path, lineno, "cursor", "beam-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;
|
||||||
|
|
@ -2261,6 +2269,7 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
.text = 0,
|
.text = 0,
|
||||||
.cursor = 0,
|
.cursor = 0,
|
||||||
},
|
},
|
||||||
|
.beam_thickness = {.pt = 1.5},
|
||||||
},
|
},
|
||||||
.mouse = {
|
.mouse = {
|
||||||
.hide_when_typing = false,
|
.hide_when_typing = false,
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -154,6 +154,7 @@ struct config {
|
||||||
uint32_t text;
|
uint32_t text;
|
||||||
uint32_t cursor;
|
uint32_t cursor;
|
||||||
} color;
|
} color;
|
||||||
|
struct pt_or_px beam_thickness;
|
||||||
} cursor;
|
} cursor;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
2
csi.c
2
csi.c
|
|
@ -1591,7 +1591,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
|
|
||||||
case 5: /* blinking bar */
|
case 5: /* blinking bar */
|
||||||
case 6: /* steady bar */
|
case 6: /* steady bar */
|
||||||
term->cursor_style = CURSOR_BAR;
|
term->cursor_style = CURSOR_BEAM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ in this order:
|
||||||
An absolute value, in _points_, that override line height from the
|
An absolute value, in _points_, that override line height from the
|
||||||
font metrics.
|
font metrics.
|
||||||
|
|
||||||
You can specify a height in _pixels_ by using the _px_ suffix:
|
You can specify a height in _pixels_ by using the *px* suffix:
|
||||||
e.g. *line-height=12px*.
|
e.g. *line-height=12px*.
|
||||||
|
|
||||||
See also: *vertical-letter-offset*.
|
See also: *vertical-letter-offset*.
|
||||||
|
|
@ -79,7 +79,7 @@ in this order:
|
||||||
Spacing between letters, in _points_. A positive value will
|
Spacing between letters, in _points_. A positive value will
|
||||||
increase the cell size, and a negative value shrinks it.
|
increase the cell size, and a negative value shrinks it.
|
||||||
|
|
||||||
You can specify a letter spacing in _pixels_ by using the _px_
|
You can specify a letter spacing in _pixels_ by using the *px*
|
||||||
suffix: e.g. *letter-spacing=2px*.
|
suffix: e.g. *letter-spacing=2px*.
|
||||||
|
|
||||||
See also: *horizontal-letter-offset*.
|
See also: *horizontal-letter-offset*.
|
||||||
|
|
@ -91,7 +91,7 @@ in this order:
|
||||||
positioning glyphs within cells, in _points_, relative to the top
|
positioning glyphs within cells, in _points_, relative to the top
|
||||||
left corner.
|
left corner.
|
||||||
|
|
||||||
To specify an offset in _pixels_, append _px_:
|
To specify an offset in _pixels_, append *px*:
|
||||||
e.g. *horizontal-letter-offset=2px*.
|
e.g. *horizontal-letter-offset=2px*.
|
||||||
|
|
||||||
Default: _0_.
|
Default: _0_.
|
||||||
|
|
@ -320,8 +320,8 @@ This section controls the cursor style and color. Note that
|
||||||
applications can change these at runtime.
|
applications can change these at runtime.
|
||||||
|
|
||||||
*style*
|
*style*
|
||||||
Configures the default cursor style, and is one of: _block_, _bar_
|
Configures the default cursor style, and is one of: *block*,
|
||||||
or _underline_. Note that this can be overridden by
|
*beam* or *underline*. Note that this can be overridden by
|
||||||
applications. Default: _block_.
|
applications. Default: _block_.
|
||||||
|
|
||||||
*blink*
|
*blink*
|
||||||
|
|
@ -335,6 +335,11 @@ applications can change these at runtime.
|
||||||
cursor. The other cursor styles are always rendered with the
|
cursor. The other cursor styles are always rendered with the
|
||||||
foreground color.
|
foreground color.
|
||||||
|
|
||||||
|
*beam-thickness*
|
||||||
|
Thickness (width) of the beam 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. *beam-thickness=2px*. Default: _1.5_
|
||||||
|
|
||||||
# SECTION: mouse
|
# SECTION: mouse
|
||||||
|
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -42,6 +42,7 @@
|
||||||
# style=block
|
# style=block
|
||||||
# color=111111 dcdccc
|
# color=111111 dcdccc
|
||||||
# blink=no
|
# blink=no
|
||||||
|
# beam-thickness=1.5
|
||||||
|
|
||||||
[mouse]
|
[mouse]
|
||||||
# hide-when-typing=no
|
# hide-when-typing=no
|
||||||
|
|
|
||||||
2
ime.c
2
ime.c
|
|
@ -466,7 +466,7 @@ ime_update_cursor_rect(struct seat *seat)
|
||||||
x = term->margins.left + col * term->cell_width;
|
x = term->margins.left + col * term->cell_width;
|
||||||
y = term->margins.top + row * term->cell_height;
|
y = term->margins.top + row * term->cell_height;
|
||||||
|
|
||||||
if (term->cursor_style == CURSOR_BAR)
|
if (term->cursor_style == CURSOR_BEAM)
|
||||||
width = 1;
|
width = 1;
|
||||||
else
|
else
|
||||||
width = term->cell_width;
|
width = term->cell_width;
|
||||||
|
|
|
||||||
21
render.c
21
render.c
|
|
@ -299,16 +299,17 @@ draw_unfocused_block(const struct terminal *term, pixman_image_t *pix,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_bar(const struct terminal *term, pixman_image_t *pix,
|
draw_beam(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(
|
||||||
PIXMAN_OP_SRC, pix, color,
|
PIXMAN_OP_SRC, pix, color,
|
||||||
1, &(pixman_rectangle16_t){
|
1, &(pixman_rectangle16_t){
|
||||||
x, baseline,
|
x, baseline,
|
||||||
font->underline.thickness, term->fonts[0]->ascent + term->fonts[0]->descent});
|
term_pt_or_px_as_pixels(term, &term->conf->cursor.beam_thickness),
|
||||||
|
term->fonts[0]->ascent + term->fonts[0]->descent});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -386,11 +387,11 @@ draw_cursor(const struct terminal *term, const struct cell *cell,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURSOR_BAR:
|
case CURSOR_BEAM:
|
||||||
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_bar(term, pix, font, &cursor_color, x, y);
|
draw_beam(term, pix, font, &cursor_color, x, y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1265,7 +1266,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_bar(term, buf->pix[0], font, &cursor_color, x, y);
|
draw_beam(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);
|
||||||
}
|
}
|
||||||
|
|
@ -2475,7 +2476,7 @@ render_search_box(struct terminal *term)
|
||||||
|
|
||||||
/* 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_bar(term, buf->pix[0], font, &fg, x + start * term->cell_width, y);
|
draw_beam(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);
|
||||||
|
|
@ -2504,7 +2505,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_bar(term, buf->pix[0], font, &fg, x, y);
|
draw_beam(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);
|
||||||
}
|
}
|
||||||
|
|
@ -2560,7 +2561,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_bar(term, buf->pix[0], font, &fg, x, y);
|
draw_beam(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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
terminal.c
16
terminal.c
|
|
@ -600,12 +600,12 @@ err_sem_destroy:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
pt_or_px_as_pixels(const struct terminal *term,
|
term_pt_or_px_as_pixels(const struct terminal *term,
|
||||||
const struct pt_or_px *pt_or_px)
|
const struct pt_or_px *pt_or_px)
|
||||||
{
|
{
|
||||||
return pt_or_px->px == 0
|
return pt_or_px->px == 0
|
||||||
? pt_or_px->pt * term->font_dpi / 72
|
? round(pt_or_px->pt * term->font_dpi / 72)
|
||||||
: pt_or_px->px;
|
: pt_or_px->px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -636,15 +636,15 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
|
||||||
(term->fonts[0]->space_advance.x > 0
|
(term->fonts[0]->space_advance.x > 0
|
||||||
? term->fonts[0]->space_advance.x
|
? term->fonts[0]->space_advance.x
|
||||||
: term->fonts[0]->max_advance.x)
|
: term->fonts[0]->max_advance.x)
|
||||||
+ pt_or_px_as_pixels(term, &conf->letter_spacing);
|
+ term_pt_or_px_as_pixels(term, &conf->letter_spacing);
|
||||||
|
|
||||||
term->cell_height = term->font_line_height.px >= 0
|
term->cell_height = term->font_line_height.px >= 0
|
||||||
? pt_or_px_as_pixels(term, &term->font_line_height)
|
? term_pt_or_px_as_pixels(term, &term->font_line_height)
|
||||||
: max(term->fonts[0]->height,
|
: max(term->fonts[0]->height,
|
||||||
term->fonts[0]->ascent + term->fonts[0]->descent);
|
term->fonts[0]->ascent + term->fonts[0]->descent);
|
||||||
|
|
||||||
term->font_x_ofs = pt_or_px_as_pixels(term, &conf->horizontal_letter_offset);
|
term->font_x_ofs = term_pt_or_px_as_pixels(term, &conf->horizontal_letter_offset);
|
||||||
term->font_y_ofs = pt_or_px_as_pixels(term, &conf->vertical_letter_offset);
|
term->font_y_ofs = term_pt_or_px_as_pixels(term, &conf->vertical_letter_offset);
|
||||||
|
|
||||||
LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height);
|
LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ enum mouse_reporting {
|
||||||
MOUSE_URXVT, /* ?1015h */
|
MOUSE_URXVT, /* ?1015h */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR };
|
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BEAM };
|
||||||
|
|
||||||
enum selection_kind {
|
enum selection_kind {
|
||||||
SELECTION_NONE,
|
SELECTION_NONE,
|
||||||
|
|
@ -615,6 +615,9 @@ bool term_font_size_decrease(struct terminal *term);
|
||||||
bool term_font_size_reset(struct terminal *term);
|
bool term_font_size_reset(struct terminal *term);
|
||||||
bool term_font_dpi_changed(struct terminal *term);
|
bool term_font_dpi_changed(struct terminal *term);
|
||||||
void term_font_subpixel_changed(struct terminal *term);
|
void term_font_subpixel_changed(struct terminal *term);
|
||||||
|
int term_pt_or_px_as_pixels(
|
||||||
|
const struct terminal *term, const struct pt_or_px *pt_or_px);
|
||||||
|
|
||||||
|
|
||||||
void term_window_configured(struct terminal *term);
|
void term_window_configured(struct terminal *term);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue