Compare commits

..

4 Commits

Author SHA1 Message Date
9c551bcdd4 colorschemes: 1 nord dark, 2 nord light; font: Iosevka NFM Light 2023-07-29 10:53:03 +02:00
wael
4471327341 add glyph wide support patch 2023-07-29 10:53:03 +02:00
Timo Röhling
d22a197ff3 Terminal scrollback with ring buffer
This patch adds a ring buffer for scrollback to the terminal.  The
advantage of using a ring buffer is that the common case, scrolling with
no static screen content, can be achieved very efficiently by
incrementing and decrementing the starting line (modulo buffer size).

The scrollback buffer is limited to HISTSIZE lines in order to bound
memory usage. As the lines are allocated on demand, it is possible to
implement unlimited scrollback with few changes.  If the terminal is
reset, the scroll back buffer is reset, too.

(apply st-scrollback-ringbuffer-0.8.5.diff on top of colorscheme)
2023-07-29 10:41:30 +02:00
Max Schillinger
77a40fa93a Add multiple color schemes and key bindings to change them
This commits adds these color schemes:

- the default (dark) st color scheme
- the default (dark) alacritty color scheme
- One Half (dark & light)
- Solarized (dark & light)
- Gruvbox (dark & light)

Select one with Alt+1..8.
Select the next one with Alt+0.
Select the previous one with Ctrl+Alt+0.
2023-07-29 00:51:40 +02:00
3 changed files with 32 additions and 49 deletions

View File

@ -5,7 +5,7 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "FiraCode Nerd Font Ret:size=10";
static char *font = "Iosevka NFM Light:size=12";
static int borderpx = 2;
/*
@ -106,19 +106,19 @@ typedef struct {
* foreground, background, cursor, reverse cursor
*/
static const ColorScheme schemes[] = {
// tokyonight-storm
{{"#1d202f", "#f7768e", "#9ece6a", "#e0af68",
"#7aa2f7", "#bb9af7", "#7dcfff", "#a9b1d6",
"#414868", "#f7768e", "#9ece6a", "#e0af68",
"#7aa2f7", "#bb9af7", "#7dcfff", "#c0caf5",
[256]="#81A1C1", "#555555", "#c0caf5", "#24283b"}, 258, 259, 256, 257},
// onenord (dark)
{{"#3B4252", "#E06C75", "#9EC183", "#EBCB8B",
"#81A1C1", "#B988B0", "#88C0D0", "#E5E9F0",
"#4C566A", "#E06C75", "#9EC183", "#EBCB8B",
"#81A1C1", "#B988B0", "#8FBCBB", "#ECEFF4",
[256]="#81A1C1", "#555555", "#E5E9F0", "#2E3440"}, 258, 259, 256, 257},
// tokyonight-day
{{"#e9e9ed", "#f52a65", "#587539", "#8c6c3e",
"#2e7de9", "#9854f1", "#007197", "#6172b0",
"#a1a6c5", "#f52a65", "#587539", "#8c6c3e",
"#2e7de9", "#9854f1", "#007197", "#3760bf",
[256]="#3879C5", "#555555", "#3760bf", "#e1e2e7"}, 258, 259, 256, 257},
// onenord (light)
{{"#2E3440", "#CB4F53", "#48A53D", "#EE5E25",
"#3879C5", "#9F4ACA", "#3EA1AD", "#E5E9F0",
"#646A76", "#D16366", "#5F9E9D", "#BA793E",
"#1B40A6", "#9665AF", "#8FBCBB", "#ECEFF4",
[256]="#3879C5", "#555555", "#2E3440", "#F7F8FA"}, 258, 259, 256, 257},
// One Half dark
{{"#282c34", "#e06c75", "#98c379", "#e5c07b",
@ -249,17 +249,17 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
{ MODKEY, XK_F1, selectscheme, {.i = 0} },
{ MODKEY, XK_F2, selectscheme, {.i = 1} },
{ MODKEY, XK_F3, selectscheme, {.i = 2} },
{ MODKEY, XK_F4, selectscheme, {.i = 3} },
{ MODKEY, XK_F5, selectscheme, {.i = 4} },
{ MODKEY, XK_F6, selectscheme, {.i = 5} },
{ MODKEY, XK_F7, selectscheme, {.i = 6} },
{ MODKEY, XK_F8, selectscheme, {.i = 7} },
{ MODKEY, XK_F9, selectscheme, {.i = 8} },
{ MODKEY, XK_F10, nextscheme, {.i = +1} },
{ MODKEY|ControlMask, XK_F10, nextscheme, {.i = -1} },
{ MODKEY, XK_1, selectscheme, {.i = 0} },
{ MODKEY, XK_2, selectscheme, {.i = 1} },
{ MODKEY, XK_3, selectscheme, {.i = 2} },
{ MODKEY, XK_4, selectscheme, {.i = 3} },
{ MODKEY, XK_5, selectscheme, {.i = 4} },
{ MODKEY, XK_6, selectscheme, {.i = 5} },
{ MODKEY, XK_7, selectscheme, {.i = 6} },
{ MODKEY, XK_8, selectscheme, {.i = 7} },
{ MODKEY, XK_9, selectscheme, {.i = 8} },
{ MODKEY, XK_0, nextscheme, {.i = +1} },
{ MODKEY|ControlMask, XK_0, nextscheme, {.i = -1} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
};

22
st.c
View File

@ -1862,18 +1862,11 @@ csihandle(void)
case 'm': /* SGR -- Terminal attribute (color) */
tsetattr(csiescseq.arg, csiescseq.narg);
break;
case 'n': /* DSR -- Device Status Report */
switch (csiescseq.arg[0]) {
case 5: /* Status Report "OK" `0n` */
ttywrite("\033[0n", sizeof("\033[0n") - 1, 0);
break;
case 6: /* Report Cursor Position (CPR) "<row>;<column>R" */
case 'n': /* DSR Device Status Report (cursor position) */
if (csiescseq.arg[0] == 6) {
len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
term.c.y+1, term.c.x+1);
ttywrite(buf, len, 0);
break;
default:
goto unknown;
}
break;
case 'r': /* DECSTBM -- Set Scrolling Region */
@ -2032,10 +2025,8 @@ strhandle(void)
if (p && !strcmp(p, "?")) {
osc_color_response(j, 0, 1);
} else if (xsetcolorname(j, p)) {
if (par == 104 && narg <= 1) {
xloadcols();
if (par == 104 && narg <= 1)
return; /* color reset without parameter */
}
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
j, p ? p : "(null)");
} else {
@ -2537,9 +2528,6 @@ check_control_code:
* they must not cause conflicts with sequences.
*/
if (control) {
/* in UTF-8 mode ignore handling C1 control characters */
if (IS_SET(MODE_UTF8) && ISCONTROLC1(u))
return;
tcontrolcode(u);
/*
* control codes are not shown ever
@ -2586,10 +2574,8 @@ check_control_code:
gp = &TLINE(term.c.y)[term.c.x];
}
if (IS_SET(MODE_INSERT) && term.c.x+width < term.col) {
if (IS_SET(MODE_INSERT) && term.c.x+width < term.col)
memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph));
gp->mode &= ~ATTR_WIDE;
}
if (term.c.x+width > term.col) {
tnewline(1);

9
x.c
View File

@ -1838,7 +1838,7 @@ void
kpress(XEvent *ev)
{
XKeyEvent *e = &ev->xkey;
KeySym ksym = NoSymbol;
KeySym ksym;
char buf[64], *customkey;
int len;
Rune c;
@ -1848,13 +1848,10 @@ kpress(XEvent *ev)
if (IS_SET(MODE_KBDLOCK))
return;
if (xw.ime.xic) {
if (xw.ime.xic)
len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
if (status == XBufferOverflow)
return;
} else {
else
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
}
/* 1. shortcuts */
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
if (ksym == bp->keysym && match(bp->mod, e->state)) {