~sircmpwn/visurf-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] Implement backwards word deletion in exline

Details
Message ID
<20210914133445.2799-1-leonhenrik.plickat@stud.uni-goettingen.de>
DKIM signature
missing
Download raw message
Patch: +41 -9
---
Works just as v1 did.
 frontends/visurf/window.c | 50 ++++++++++++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/frontends/visurf/window.c b/frontends/visurf/window.c
index 7d36deb3e..7978909b3 100644
--- a/frontends/visurf/window.c
+++ b/frontends/visurf/window.c
@@ -865,6 +865,41 @@ nsvi_window_handle_normal_key(struct nsvi_window *win,
	browser_window_key_press(win->tabs[win->tab]->bw, key);
}

static size_t
exline_next_word_start_backward(struct exline_state *exline)
{
	if (exline->index == 0 || exline->index == 1) {
		return 0;
	}

	size_t index = exline->index;
	while (index != 0 && isspace(exline->cmd[index - 1])) {
		--index;
	}
	while (index != 0 && !isspace(exline->cmd[index - 1])) {
		--index;
	}

	return index;
}

static void
exline_delete_backward(struct exline_state *exline, size_t size)
{
	if (exline->index == 0) {
		return;
	}
	if (size > exline->index) {
		size = exline->index;
	}

	memmove(&exline->cmd[exline->index - size],
		&exline->cmd[exline->index],
		(exline->cmdln - exline->index) + size);
	exline->index -= size;
	exline->cmdln -= size;
}

static void
nsvi_window_handle_exline_key(struct nsvi_window *win,
		xkb_keycode_t keycode, bool pressed)
@@ -927,14 +962,8 @@ nsvi_window_handle_exline_key(struct nsvi_window *win,
			}
			return;
		case XKB_KEY_BackSpace:
			if (exline->index != 0) {
				memmove(&exline->cmd[exline->index - 1],
					&exline->cmd[exline->index],
					(exline->cmdln - exline->index) + 1);
				--exline->index;
				--exline->cmdln;
				request_frame(win);
			}
			exline_delete_backward(exline, 1);
			request_frame(win);
			return;
		default:
			break;
@@ -949,7 +978,10 @@ nsvi_window_handle_exline_key(struct nsvi_window *win,
		case XKB_KEY_BackSpace:
		case XKB_KEY_Delete:
		case XKB_KEY_w:
			// TODO: Delete word
			exline_delete_backward(exline, exline->index -
				exline_next_word_start_backward(exline));
			request_frame(win);
			return;
		case XKB_KEY_a:
			exline->index = 0;
			request_frame(win);
-- 
2.33.0
Details
Message ID
<CE9O3D2X0U52.36AO4UB9EHAO@taiga>
In-Reply-To
<20210914133445.2799-1-leonhenrik.plickat@stud.uni-goettingen.de> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Thanks!

To git@git.sr.ht:~sircmpwn/visurf
   45a0ee63d..ac9392f74  master -> master

On Tue Sep 14, 2021 at 3:34 PM CEST, Leon Henrik Plickat wrote:
> ---
> Works just as v1 did.

You mean it works just as v1 didn't ;)
Reply to thread Export thread (mbox)