first clear shortcut

This commit is contained in:
WanderingPenwing 2024-07-29 10:41:37 +02:00
parent 5042946b62
commit 73f6a950ad
5 changed files with 335 additions and 313 deletions

View file

@ -1,5 +1,7 @@
/* See LICENSE file for copyright and license details. */
void clearhistory(const Arg *arg);
/*
* appearance
*
@ -201,6 +203,7 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
{ ControlMask, XK_L, clearhistory, {.i = 0} },
};
/*

BIN
st

Binary file not shown.

19
st.c
View file

@ -225,6 +225,8 @@ static char base64dec_getc(const char **);
static ssize_t xwrite(int, const char *, size_t);
void clearhistory(const Arg *arg);
/* Globals */
static Term term;
static Selection sel;
@ -239,6 +241,23 @@ static const uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
static const Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
static const Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
void
clearhistory(const Arg *arg) {
// Clear the visible screen
tclearregion(0, 0, term.col-1, term.row-1);
tsetdirt(0, term.row);
// Clear the scrollback buffer
term.scr = 0;
term.histi = 0;
for (int i = 0; i < HISTSIZE; i++) {
memset(term.hist[i], 0, term.col * sizeof(Line));
}
// Redraw to apply changes
tfulldirt();
}
ssize_t
xwrite(int fd, const char *s, size_t len)
{

BIN
st.o

Binary file not shown.

BIN
x.o

Binary file not shown.