Merge branch 'master' into diagonal-dpi

This commit is contained in:
Daniel Eklöf 2020-07-28 20:01:56 +02:00
commit 295083059c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
19 changed files with 423 additions and 68 deletions

View file

@ -1,7 +1,8 @@
# Changelog
* [Unreleased](#unreleased)
* [1.4.2](#1.4.2)
* [1.4.3](#1-4-3)
* [1.4.2](#1-4-2)
* [1.4.1](#1-4-1)
* [1.4.0](#1-4-0)
* [1.3.0](#1-3-0)
@ -12,12 +13,39 @@
## Unreleased
### Added
### Deprecated
### Removed
### Changed
* Renamed man page for `footrc` from **foot**(5) to **footrc**(5).
* Mouse cursor is now always a `left_ptr` when inside the margins, to
indicate it is not possible to start a selection.
* Scrollback position indicator. This feature is optional and
controlled by the **scrollback-indicator-position** and
**scrollback-indicator-format** options in `footrc`
(https://codeberg.org/dnkl/foot/issues/42).
### Fixed
* Crash when starting a selection inside the margins.
* Handle trailing comments in `footrc`
### Security
### Contributors
## 1.4.3
### Added
* Section to [README.md](README.md) describing how to programmatically
identify foot.
* [LICENSE](LICENSE), [README.md](README.md) and
[CHANGELOG.md](CHANGELOG.md) are now installed to
`${datadir}/doc/foot`.
* Support for escaping quotes in **pipe-visible** and
**pipe-scrollback** commands.
### Changed
@ -35,18 +63,20 @@
outside it.
* Scrollback search to focus match, that requires a viewport change,
roughly in the center of the screen.
* Extending a selection with the right mouse button now works while
dragging the mouse.
### Deprecated
### Removed
### Fixed
* Crash in scrollback search
* Crash in scrollback search.
* Crash when a **pipe-visible** or **pipe-scrollback** command
contained an unclosed quote
(https://codeberg.org/dnkl/foot/issues/49).
* Improved font size consistency across multiple monitors with
different DPI (https://codeberg.org/dnkl/foot/issues/47).
### Security
### Contributors
* [birger](https://codeberg.org/birger)

View file

@ -1,5 +1,5 @@
pkgname=('foot-git' 'foot-terminfo-git')
pkgver=1.4.2
pkgver=1.4.3
pkgrel=1
arch=('x86_64' 'aarch64')
url=https://codeberg.org/dnkl/foot

View file

@ -34,6 +34,8 @@ The fast, lightweight and minimalistic Wayland terminal emulator.
1. [Credits](#Credits)
1. [Bugs](#bugs)
1. [Mastodon](#mastodon)
1. [License](#license)
## Features
@ -55,11 +57,12 @@ The fast, lightweight and minimalistic Wayland terminal emulator.
## Configuration
**foot** can be configured by creating a file `$XDG_CONFIG_HOME/footrc` (defaulting to `~/.config/footrc`).
A template for that can usually be found in `/usr/share/foot/footrc` or
**foot** can be configured by creating a file
`$XDG_CONFIG_HOME/footrc` (defaulting to `~/.config/footrc`). A
template for that can usually be found in `/usr/share/foot/footrc` or
[here](https://codeberg.org/dnkl/foot/src/branch/master/footrc).
Further information can be found in foot's manpage `foot(5)`.
Further information can be found in foot's man page `footrc(5)`.
## Troubleshooting
@ -590,3 +593,8 @@ The report should contain the following:
Every now and then I post foot related updates on
[@dnkl@linuxrocks.online](https://linuxrocks.online/@dnkl)
# License
Foot is released under the [MIT](LICENSE).

View file

@ -288,7 +288,44 @@ parse_section_main(const char *key, const char *value, struct config *conf,
LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value);
return false;
}
conf->scrollback_lines = lines;
conf->scrollback.lines = lines;
}
else if (strcmp(key, "scrollback-indicator-position") == 0) {
if (strcmp(value, "none") == 0)
conf->scrollback.indicator.position = SCROLLBACK_INDICATOR_POSITION_NONE;
else if (strcmp(value, "fixed") == 0)
conf->scrollback.indicator.position = SCROLLBACK_INDICATOR_POSITION_FIXED;
else if (strcmp(value, "relative") == 0)
conf->scrollback.indicator.position = SCROLLBACK_INDICATOR_POSITION_RELATIVE;
else {
LOG_ERR("%s:%d: scrollback-indicator-position must be one of "
"'none', 'fixed' or 'moving'",
path, lineno);
return false;
}
}
else if (strcmp(key, "scrollback-indicator-format") == 0) {
if (strcmp(value, "percentage") == 0) {
conf->scrollback.indicator.format
= SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE;
} else if (strcmp(value, "line") == 0) {
conf->scrollback.indicator.format
= SCROLLBACK_INDICATOR_FORMAT_LINENO;
} else {
free(conf->scrollback.indicator.text);
conf->scrollback.indicator.text = NULL;
size_t len = mbstowcs(NULL, value, -1);
if (len < 0) {
LOG_ERRNO("%s:%d: invalid scrollback-indicator-format value", path, lineno);
return false;
}
conf->scrollback.indicator.text = calloc(len + 1, sizeof(wchar_t));
mbstowcs(conf->scrollback.indicator.text, value, len);
}
}
else {
@ -792,7 +829,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path)
break;
}
/* Strip whitespace */
/* Strip leading whitespace */
char *line = _line;
{
while (isspace(*line))
@ -809,11 +846,15 @@ parse_config_file(FILE *f, struct config *conf, const char *path)
if (line[0] == '\0' || line[0] == '#')
continue;
/* Split up into key/value pair + trailing comment */
char *key_value = strtok(line, "#");
char *comment __attribute__((unused)) = strtok(NULL, "\n");
/* Check for new section */
if (line[0] == '[') {
char *end = strchr(line, ']');
if (key_value[0] == '[') {
char *end = strchr(key_value, ']');
if (end == NULL) {
LOG_ERR("%s:%d: syntax error: %s", path, lineno, line);
LOG_ERR("%s:%d: syntax error: %s", path, lineno, key_value);
goto err;
}
@ -821,13 +862,13 @@ parse_config_file(FILE *f, struct config *conf, const char *path)
section = SECTION_COUNT;
for (enum section i = 0; i < SECTION_COUNT; i++) {
if (strcmp(&line[1], section_info[i].name) == 0) {
if (strcmp(&key_value[1], section_info[i].name) == 0) {
section = i;
}
}
if (section == SECTION_COUNT) {
LOG_ERR("%s:%d: invalid section name: %s", path, lineno, &line[1]);
LOG_ERR("%s:%d: invalid section name: %s", path, lineno, &key_value[1]);
goto err;
}
@ -835,11 +876,20 @@ parse_config_file(FILE *f, struct config *conf, const char *path)
continue;
}
char *key = strtok(line, "=");
char *key = strtok(key_value, "=");
if (key == NULL) {
LOG_ERR("%s:%d: syntax error: no key specified", path, lineno);
goto err;
}
char *value = strtok(NULL, "\n");
if (value == NULL) {
/* Empty value, i.e. "key=" */
value = key + strlen(key);
}
/* Strip trailing whitespace from key (leading stripped earlier) */
{
if (key[0] != '\0') {
assert(!isspace(*key));
char *end = key + strlen(key) - 1;
@ -850,25 +900,28 @@ parse_config_file(FILE *f, struct config *conf, const char *path)
if (value == NULL) {
if (key != NULL && strlen(key) > 0 && key[0] != '#') {
LOG_ERR("%s:%d: syntax error: %s", path, lineno, line);
LOG_ERR("%s:%d: syntax error: %s", path, lineno, key_value);
goto err;
}
continue;
}
/* Strip leading whitespace from value (trailing stripped earlier) */
/* Strip leading+trailing whitespace from value */
{
while (isspace(*value))
value++;
assert(!isspace(*(value + strlen(value) - 1)));
if (value[0] != '\0') {
char *end = value + strlen(value) - 1;
while (isspace(*end))
end--;
*(end + 1) = '\0';
}
}
if (key[0] == '#')
continue;
LOG_DBG("section=%s, key='%s', value='%s'",
section_names[section], key, value);
LOG_DBG("section=%s, key='%s', value='%s', comment='%s'",
section_info[section].name, key, value, comment);
parser_fun_t section_parser = section_info[section].fun;
assert(section_parser != NULL);
@ -917,8 +970,14 @@ config_load(struct config *conf, const char *conf_path)
.pad_y = 2,
.startup_mode = STARTUP_WINDOWED,
.fonts = tll_init(),
.scrollback_lines = 1000,
.scrollback = {
.lines = 1000,
.indicator = {
.position = SCROLLBACK_INDICATOR_POSITION_RELATIVE,
.format = SCROLLBACK_INDICATOR_FORMAT_TEXT,
.text = wcsdup(L""),
},
},
.colors = {
.fg = default_foreground,
.bg = default_background,
@ -1068,6 +1127,7 @@ config_free(struct config conf)
free(conf.shell);
free(conf.title);
free(conf.app_id);
free(conf.scrollback.indicator.text);
tll_foreach(conf.fonts, it)
config_font_destroy(&it->item);
tll_free(conf.fonts);

View file

@ -39,7 +39,25 @@ struct config {
tll(struct config_font) fonts;
int scrollback_lines;
struct {
int lines;
struct {
enum {
SCROLLBACK_INDICATOR_POSITION_NONE,
SCROLLBACK_INDICATOR_POSITION_FIXED,
SCROLLBACK_INDICATOR_POSITION_RELATIVE
} position;
enum {
SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE,
SCROLLBACK_INDICATOR_FORMAT_LINENO,
SCROLLBACK_INDICATOR_FORMAT_TEXT,
} format;
wchar_t *text;
} indicator;
} scrollback;
struct {
uint32_t fg;

View file

@ -119,7 +119,7 @@ The following keyboard shortcuts are available.
## NORMAL MODE
Note that these are just the defaults; they can be changed in the
*footrc*, see *foot*(5).
*footrc*, see *footrc*(5).
*shift*+*page up*/*page down*
Scroll up/down in history
@ -239,7 +239,7 @@ Finally, pressing *alt* will prefix the transmitted byte with ESC.
# CONFIGURATION
See *foot*(5)
See *footrc*(5)
# BUGS
@ -256,4 +256,4 @@ The report should contain the following:
# SEE ALSO
*foot*(5), *footclient*(1)
*footrc*(5), *footclient*(1)

View file

@ -1,7 +1,7 @@
foot(5)
footrc(5)
# NAME
foot - configuration file
footrc - configuration file
# DESCRIPTION
@ -68,6 +68,20 @@ in this order:
*scrollback*
Number of scrollback lines. Default: _1000_.
*scrollback-indicator-position*
Configures the style of the scrollback position indicator. One of
*none*, *fixed* or *relative*. *none* disables the indicator
completely. *fixed* always renders the indicator near the top at
the window, and *relative* renders the indicator at the position
corresponding to the current scrollback position. Default:
_relative_.
*scrollback-indicator-format*
Which format to use when displaying the scrollback position
indicator. Either _percentage_, _line_, or a custom fixed
string. This option is ignored if
*scrollback-indicator-position=none*. Default: _empty string_.
*workers*
Number of threads to use for rendering. Set to 0 to disable
multithreading. Default: the number of available logical CPUs
@ -176,7 +190,7 @@ This section lets you override the default key bindings.
The general format is _action=combo1...comboN_. That is, each action
may have one or more key combinations, space separated. Each
combination is on the form _mod1+mod2+key_. The names of the modifiers
and the key *must* be a valid XKB key name.
and the key *must* be valid XKB key names.
Note that if *Shift* is one of the modifiers, the _key_ *must* be in
upper case. For example, *Control+Shift+v* will never trigger -
@ -398,3 +412,7 @@ any of these options.
Note: this feature is always disabled in 32-bit.
Default: _512_. Maximum allowed: _2048_ (2GB).
# SEE ALSO
*foot*(1), *footclient*(1)

View file

@ -3,7 +3,7 @@ sh = find_program('sh', native: true)
scdoc = dependency('scdoc', native: true)
scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
foreach man_src : ['foot.1.scd', 'foot.5.scd', 'footclient.1.scd']
foreach man_src : ['foot.1.scd', 'footrc.5.scd', 'footclient.1.scd']
parts = man_src.split('.')
name = parts[-3]
section = parts[-2]

2
footrc
View file

@ -2,6 +2,8 @@
# font=monospace
# scrollback=1000
# scrollback-indicator-position=relative
# scrollback-indicator-format=
# geometry=700x500
# pad=2x2
# initial-window-mode=windowed

46
input.c
View file

@ -1023,13 +1023,19 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
int y = wl_fixed_to_int(surface_y) * term->scale;
switch ((term->active_surface = term_surface_kind(term, surface))) {
case TERM_SURF_GRID:
seat->mouse.col = x / term->cell_width;
seat->mouse.row = y / term->cell_height;
case TERM_SURF_GRID: {
int col = (x - term->margins.left) / term->cell_width;
int row = (y - term->margins.top) / term->cell_height;
seat->mouse.col = col >= 0 && col < term->cols ? col : -1;
seat->mouse.row = row >= 0 && row < term->rows ? row : -1;
term_xcursor_update(term);
break;
}
case TERM_SURF_SEARCH:
case TERM_SURF_SCROLLBACK_INDICATOR:
case TERM_SURF_TITLE:
render_xcursor_set(seat, term, XCURSOR_LEFT_PTR);
break;
@ -1107,6 +1113,7 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer,
case TERM_SURF_NONE:
case TERM_SURF_GRID:
case TERM_SURF_SEARCH:
case TERM_SURF_SCROLLBACK_INDICATOR:
case TERM_SURF_TITLE:
case TERM_SURF_BORDER_LEFT:
case TERM_SURF_BORDER_RIGHT:
@ -1141,6 +1148,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
switch (term->active_surface) {
case TERM_SURF_NONE:
case TERM_SURF_SEARCH:
case TERM_SURF_SCROLLBACK_INDICATOR:
case TERM_SURF_BUTTON_MINIMIZE:
case TERM_SURF_BUTTON_MAXIMIZE:
case TERM_SURF_BUTTON_CLOSE:
@ -1165,26 +1173,31 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
break;
case TERM_SURF_GRID: {
term_xcursor_update(term);
int col = (x - term->margins.left) / term->cell_width;
int row = (y - term->margins.top) / term->cell_height;
if (col < 0 || row < 0 || col >= term->cols || row >= term->rows)
return;
int old_col = seat->mouse.col;
int old_row = seat->mouse.row;
bool update_selection = seat->mouse.button == BTN_LEFT;
seat->mouse.col = col >= 0 && col < term->cols ? col : -1;
seat->mouse.row = row >= 0 && row < term->rows ? row : -1;
if (seat->mouse.col < 0 || seat->mouse.row < 0)
break;
bool update_selection = seat->mouse.button == BTN_LEFT || seat->mouse.button == BTN_RIGHT;
bool update_selection_early = term->selection.end.row == -1;
if (update_selection && update_selection_early)
selection_update(term, col, row);
selection_update(term, seat->mouse.col, seat->mouse.row);
if (col == seat->mouse.col && row == seat->mouse.row)
if (old_col == seat->mouse.col && old_row == seat->mouse.row)
break;
seat->mouse.col = col;
seat->mouse.row = row;
if (update_selection && !update_selection_early)
selection_update(term, col, row);
selection_update(term, seat->mouse.col, seat->mouse.row);
if (!term_mouse_grabbed(term, seat)) {
term_mouse_motion(
@ -1347,6 +1360,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
break;
case TERM_SURF_SEARCH:
case TERM_SURF_SCROLLBACK_INDICATOR:
break;
case TERM_SURF_GRID: {
@ -1360,9 +1374,11 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
if (selection_enabled(term, seat)) {
switch (seat->mouse.count) {
case 1:
selection_start(
term, seat->mouse.col, seat->mouse.row,
seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL);
if (seat->mouse.col >= 0 && seat->mouse.row >= 0) {
selection_start(
term, seat->mouse.col, seat->mouse.row,
seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL);
}
break;
case 2:

View file

@ -1,5 +1,5 @@
project('foot', 'c',
version: '1.4.2',
version: '1.4.3',
license: 'MIT',
meson_version: '>=0.53.0',
default_options: [

176
render.c
View file

@ -1287,6 +1287,178 @@ render_csd(struct terminal *term)
render_csd_title(term);
}
static void
render_scrollback_position(struct terminal *term)
{
if (term->conf->scrollback.indicator.position == SCROLLBACK_INDICATOR_POSITION_NONE)
return;
struct wayland *wayl = term->wl;
struct wl_window *win = term->window;
if (term->grid->view == term->grid->offset) {
if (win->scrollback_indicator_surface != NULL) {
wl_subsurface_destroy(win->scrollback_indicator_sub_surface);
wl_surface_destroy(win->scrollback_indicator_surface);
win->scrollback_indicator_surface = NULL;
win->scrollback_indicator_sub_surface = NULL;
}
return;
}
if (win->scrollback_indicator_surface == NULL) {
win->scrollback_indicator_surface
= wl_compositor_create_surface(wayl->compositor);
if (win->scrollback_indicator_surface == NULL) {
LOG_ERR("failed to create scrollback indicator surface");
return;
}
wl_surface_set_user_data(win->scrollback_indicator_surface, win);
term->window->scrollback_indicator_sub_surface
= wl_subcompositor_get_subsurface(
wayl->sub_compositor,
win->scrollback_indicator_surface,
win->surface);
if (win->scrollback_indicator_sub_surface == NULL) {
LOG_ERR("failed to create scrollback indicator sub-surface");
wl_surface_destroy(win->scrollback_indicator_surface);
win->scrollback_indicator_surface = NULL;
return;
}
wl_subsurface_set_sync(win->scrollback_indicator_sub_surface);
}
assert(win->scrollback_indicator_surface != NULL);
assert(win->scrollback_indicator_sub_surface != NULL);
/* Find absolute row number of the scrollback start */
int scrollback_start = term->grid->offset + term->rows;
while (term->grid->rows[scrollback_start & (term->grid->num_rows - 1)] == NULL)
scrollback_start++;
/* Rebase viewport against scrollback start (so that 0 is at
* the beginning of the scrollback) */
int rebased_view = term->grid->view - scrollback_start + term->grid->num_rows;
rebased_view &= term->grid->num_rows - 1;
/*
* How far down in the scrollback we are.
*
* 0% -> at the beginning of the scrollback
* 100% -> at the bottom, i.e. where new lines are inserted
*/
double percent =
rebased_view + term->rows == term->grid->num_rows
? 1.0
: (double)rebased_view / term->grid->num_rows;
wchar_t _text[64];
const wchar_t *text = _text;
int cell_count;
/* *What* to render */
switch (term->conf->scrollback.indicator.format) {
case SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE:
swprintf(_text, sizeof(_text) / sizeof(_text[0]), L"%u%%", (int)(100 * percent));
cell_count = 3;
break;
case SCROLLBACK_INDICATOR_FORMAT_LINENO:
swprintf(_text, sizeof(_text) / sizeof(_text[0]), L"%d", rebased_view + 1);
cell_count = 1 + (int)log10(term->grid->num_rows);
break;
case SCROLLBACK_INDICATOR_FORMAT_TEXT:
text = term->conf->scrollback.indicator.text;
cell_count = wcslen(text);
break;
}
const int scale = term->scale;
const int margin = 3 * scale;
const int width = 2 * margin + cell_count * term->cell_width;
const int height = 2 * margin + term->cell_height;
unsigned long cookie = shm_cookie_scrollback_indicator(term);
struct buffer *buf = shm_get_buffer(
term->wl->shm, width, height, cookie, false, 1);
pixman_color_t bg = color_hex_to_pixman(term->colors.table[8 + 4]);
pixman_image_fill_rectangles(
PIXMAN_OP_SRC, buf->pix[0], &bg, 1,
&(pixman_rectangle16_t){0, 0, width, height});
struct fcft_font *font = term->fonts[0];
pixman_color_t fg = color_hex_to_pixman(term->colors.table[0]);
/* Sub-surface relative coordinates */
unsigned x = width - margin - wcslen(text) * term->cell_width;
const unsigned y = margin;
for (size_t i = 0; i < wcslen(text); i++) {
const struct fcft_glyph *glyph = fcft_glyph_rasterize(
font, text[i], term->font_subpixel);
if (glyph == NULL)
continue;
pixman_image_t *src = pixman_image_create_solid_fill(&fg);
pixman_image_composite32(
PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0,
x + glyph->x, y + font_baseline(term) - glyph->y,
glyph->width, glyph->height);
pixman_image_unref(src);
x += term->cell_width;
}
/* *Where* to render - parent relative coordinates */
int surf_top = 0;
switch (term->conf->scrollback.indicator.position) {
case SCROLLBACK_INDICATOR_POSITION_NONE:
assert(false);
return;
case SCROLLBACK_INDICATOR_POSITION_FIXED:
surf_top = term->cell_height - margin;
break;
case SCROLLBACK_INDICATOR_POSITION_RELATIVE: {
int lines = term->rows - 3; /* Avoid using first and two last rows */
assert(lines > 0);
int pixels = lines * term->cell_height - height + 2 * margin;
surf_top = term->cell_height - margin + (int)(percent * pixels);
break;
}
}
quirk_weston_subsurface_desync_on(win->scrollback_indicator_sub_surface);
wl_subsurface_set_position(
win->scrollback_indicator_sub_surface,
(term->width - margin - width) / scale,
(term->margins.top + surf_top) / scale);
wl_surface_attach(win->scrollback_indicator_surface, buf->wl_buf, 0, 0);
wl_surface_damage_buffer(win->scrollback_indicator_surface, 0, 0, width, height);
wl_surface_set_buffer_scale(win->scrollback_indicator_surface, scale);
struct wl_region *region = wl_compositor_create_region(wayl->compositor);
if (region != NULL) {
wl_region_add(region, 0, 0, width, height);
wl_surface_set_opaque_region(win->scrollback_indicator_surface, region);
wl_region_destroy(region);
}
wl_surface_commit(win->scrollback_indicator_surface);
quirk_weston_subsurface_desync_off(win->scrollback_indicator_sub_surface);
}
static void frame_callback(
void *data, struct wl_callback *wl_callback, uint32_t callback_data);
@ -1498,6 +1670,8 @@ grid_render(struct terminal *term)
term->window->surface, 0, 0, term->width, term->height);
}
render_scrollback_position(term);
assert(term->grid->offset >= 0 && term->grid->offset < term->grid->num_rows);
assert(term->grid->view >= 0 && term->grid->view < term->grid->num_rows);
@ -1616,7 +1790,7 @@ render_search_box(struct terminal *term)
draw_bar(term, buf->pix[0], font, &fg, x, y);
const struct fcft_glyph *glyph = fcft_glyph_rasterize(
font, term->search.buf[i], true);
font, term->search.buf[i], term->font_subpixel);
if (glyph == NULL)
continue;

View file

@ -25,9 +25,10 @@ bool
selection_enabled(const struct terminal *term, struct seat *seat)
{
return
term->mouse_tracking == MOUSE_NONE ||
term_mouse_grabbed(term, seat) ||
term->is_searching;
seat->mouse.col >= 0 && seat->mouse.row >= 0 &&
(term->mouse_tracking == MOUSE_NONE ||
term_mouse_grabbed(term, seat) ||
term->is_searching);
}
bool
@ -372,8 +373,8 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
if (row < start->row || (row == start->row && col < start->col)) {
/* Extend selection to start *before* current start */
new_start = (struct coord){col, row};
new_end = *end;
new_start = *end;
new_end = (struct coord){col, row};
}
else if (row > end->row || (row == end->row && col > end->col)) {
@ -391,8 +392,8 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
abs(linear - (end->row * term->cols + end->col)))
{
/* Move start point */
new_start = (struct coord){col, row};
new_end = *end;
new_start = *end;
new_end = (struct coord){col, row};
}
else {
@ -440,13 +441,13 @@ selection_extend_block(struct terminal *term, int col, int row, uint32_t serial)
/* Move one of the top corners */
if (abs(col - top_left.col) < abs(col - top_right.col)) {
new_start = (struct coord){col, row};
new_end = bottom_right;
new_start = bottom_right;
new_end = (struct coord){col, row};
}
else {
new_start = (struct coord){col, row};
new_end = bottom_left;
new_start = bottom_left;
new_end = (struct coord){col, row};
}
}

3
shm.h
View file

@ -49,4 +49,5 @@ void shm_purge(struct wl_shm *shm, unsigned long cookie);
struct terminal;
static inline unsigned long shm_cookie_grid(const struct terminal *term) { return (unsigned long)((uintptr_t)term + 0); }
static inline unsigned long shm_cookie_search(const struct terminal *term) { return (unsigned long)((uintptr_t)term + 1); }
static inline unsigned long shm_cookie_csd(const struct terminal *term, int n) { return (unsigned long)((uintptr_t)term + 2 + (n)); }
static inline unsigned long shm_cookie_scrollback_indicator(const struct terminal *term) { return (unsigned long)(uintptr_t)term + 2; }
static inline unsigned long shm_cookie_csd(const struct terminal *term, int n) { return (unsigned long)((uintptr_t)term + 3 + (n)); }

View file

@ -909,7 +909,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.tab_stops = tll_init(),
.wl = wayl,
.render = {
.scrollback_lines = conf->scrollback_lines,
.scrollback_lines = conf->scrollback.lines,
.app_sync_updates.timer_fd = app_sync_updates_fd,
.workers = {
.count = conf->render_worker_count,
@ -2407,6 +2407,8 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface)
return TERM_SURF_GRID;
else if (surface == term->window->search_surface)
return TERM_SURF_SEARCH;
else if (surface == term->window->scrollback_indicator_surface)
return TERM_SURF_SCROLLBACK_INDICATOR;
else if (surface == term->window->csd.surface[CSD_SURF_TITLE])
return TERM_SURF_TITLE;
else if (surface == term->window->csd.surface[CSD_SURF_LEFT])

View file

@ -195,6 +195,7 @@ enum term_surface {
TERM_SURF_NONE,
TERM_SURF_GRID,
TERM_SURF_SEARCH,
TERM_SURF_SCROLLBACK_INDICATOR,
TERM_SURF_TITLE,
TERM_SURF_BORDER_LEFT,
TERM_SURF_BORDER_RIGHT,

View file

@ -38,14 +38,16 @@ tokenize_cmdline(char *cmdline, char ***argv)
char delim = first_token_is_quoted ? cmdline[0] : ' ';
char *p = first_token_is_quoted ? &cmdline[1] : &cmdline[0];
char *search_start = p;
size_t idx = 0;
while (*p != '\0') {
char *end = strchr(p, delim);
char *end = strchr(search_start, delim);
if (end == NULL) {
if (delim != ' ') {
LOG_ERR("unterminated %s quote\n", delim == '"' ? "double" : "single");
LOG_ERR("unterminated %s quote", delim == '"' ? "double" : "single");
free(*argv);
*argv = NULL;
return false;
}
@ -57,6 +59,15 @@ tokenize_cmdline(char *cmdline, char ***argv)
return true;
}
if (end > p && *(end - 1) == '\\') {
/* Escaped quote, remove one level of escaping and
* continue searching for "our" closing quote */
memmove(end - 1, end, strlen(end));
end[strlen(end) - 1] = '\0';
search_start = end;
continue;
}
*end = '\0';
if (!push_argv(argv, &argv_size, p, &idx))
@ -74,6 +85,7 @@ tokenize_cmdline(char *cmdline, char ***argv)
p++;
} else
delim = ' ';
search_start = p;
}
if (!push_argv(argv, &argv_size, NULL, &idx))

View file

@ -1212,6 +1212,11 @@ wayl_win_destroy(struct wl_window *win)
* nor mouse focus).
*/
if (win->scrollback_indicator_surface != NULL) {
wl_surface_attach(win->scrollback_indicator_surface, NULL, 0, 0);
wl_surface_commit(win->scrollback_indicator_surface);
}
/* Scrollback search */
if (win->search_surface != NULL) {
wl_surface_attach(win->search_surface, NULL, 0, 0);
@ -1236,6 +1241,10 @@ wayl_win_destroy(struct wl_window *win)
tll_free(win->on_outputs);
csd_destroy(win);
if (win->scrollback_indicator_sub_surface != NULL)
wl_subsurface_destroy(win->scrollback_indicator_sub_surface);
if (win->scrollback_indicator_surface != NULL)
wl_surface_destroy(win->scrollback_indicator_surface);
if (win->search_sub_surface != NULL)
wl_subsurface_destroy(win->search_sub_surface);
if (win->search_surface != NULL)

View file

@ -275,6 +275,9 @@ struct wl_window {
struct wl_surface *search_surface;
struct wl_subsurface *search_sub_surface;
struct wl_surface *scrollback_indicator_surface;
struct wl_subsurface *scrollback_indicator_sub_surface;
struct wl_callback *frame_callback;
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */