Compare commits
7 Commits
68d1ad9b54
...
81b3a33562
Author | SHA1 | Date | |
---|---|---|---|
81b3a33562 | |||
|
a27b7a66fe | ||
|
3a6d6d7401 | ||
|
211964d56e | ||
|
f17abd25b3 | ||
|
7e8050cc62 | ||
|
e5e959835b |
121
config.def.h
121
config.def.h
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||||
*/
|
*/
|
||||||
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
|
static char *font = "Iosevka NFM Light:size=12";
|
||||||
static int borderpx = 2;
|
static int borderpx = 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -93,46 +93,94 @@ char *termname = "st-256color";
|
|||||||
*/
|
*/
|
||||||
unsigned int tabspaces = 8;
|
unsigned int tabspaces = 8;
|
||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
typedef struct {
|
||||||
static const char *colorname[] = {
|
const char* const colors[260]; /* terminal colors */
|
||||||
/* 8 normal colors */
|
unsigned int fg; /* foreground */
|
||||||
"black",
|
unsigned int bg; /* background */
|
||||||
"red3",
|
unsigned int cs; /* cursor */
|
||||||
"green3",
|
unsigned int rcs; /* reverse cursor */
|
||||||
"yellow3",
|
} ColorScheme;
|
||||||
"blue2",
|
/*
|
||||||
"magenta3",
|
* Terminal colors (16 first used in escape sequence,
|
||||||
"cyan3",
|
* 2 last for custom cursor color),
|
||||||
"gray90",
|
* foreground, background, cursor, reverse cursor
|
||||||
|
*/
|
||||||
|
static const ColorScheme schemes[] = {
|
||||||
|
// 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},
|
||||||
|
|
||||||
/* 8 bright colors */
|
// onenord (light)
|
||||||
"gray50",
|
{{"#2E3440", "#CB4F53", "#48A53D", "#EE5E25",
|
||||||
"red",
|
"#3879C5", "#9F4ACA", "#3EA1AD", "#E5E9F0",
|
||||||
"green",
|
"#646A76", "#D16366", "#5F9E9D", "#BA793E",
|
||||||
"yellow",
|
"#1B40A6", "#9665AF", "#8FBCBB", "#ECEFF4",
|
||||||
"#5c5cff",
|
[256]="#3879C5", "#555555", "#2E3440", "#F7F8FA"}, 258, 259, 256, 257},
|
||||||
"magenta",
|
|
||||||
"cyan",
|
|
||||||
"white",
|
|
||||||
|
|
||||||
[255] = 0,
|
// One Half dark
|
||||||
|
{{"#282c34", "#e06c75", "#98c379", "#e5c07b",
|
||||||
|
"#61afef", "#c678dd", "#56b6c2", "#dcdfe4",
|
||||||
|
"#282c34", "#e06c75", "#98c379", "#e5c07b",
|
||||||
|
"#61afef", "#c678dd", "#56b6c2", "#dcdfe4",
|
||||||
|
[256]="#cccccc", "#555555", "black", "black"}, 7, 0, 256, 257},
|
||||||
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
// One Half light
|
||||||
"#cccccc",
|
{{"#fafafa", "#e45649", "#50a14f", "#c18401",
|
||||||
"#555555",
|
"#0184bc", "#a626a4", "#0997b3", "#383a42",
|
||||||
"gray90", /* default foreground colour */
|
"#fafafa", "#e45649", "#50a14f", "#c18401",
|
||||||
"black", /* default background colour */
|
"#0184bc", "#a626a4", "#0997b3", "#383a42",
|
||||||
|
[256]="#cccccc", "#555555", "black", "black"}, 7, 0, 256, 257},
|
||||||
|
|
||||||
|
// Solarized dark
|
||||||
|
{{"#073642", "#dc322f", "#859900", "#b58900",
|
||||||
|
"#268bd2", "#d33682", "#2aa198", "#eee8d5",
|
||||||
|
"#002b36", "#cb4b16", "#586e75", "#657b83",
|
||||||
|
"#839496", "#6c71c4", "#93a1a1", "#fdf6e3",
|
||||||
|
[256]="#93a1a1", "#fdf6e3", "black", "black"}, 12, 8, 256, 257},
|
||||||
|
|
||||||
|
// Solarized light
|
||||||
|
{{"#eee8d5", "#dc322f", "#859900", "#b58900",
|
||||||
|
"#268bd2", "#d33682", "#2aa198", "#073642",
|
||||||
|
"#fdf6e3", "#cb4b16", "#93a1a1", "#839496",
|
||||||
|
"#657b83", "#6c71c4", "#586e75", "#002b36",
|
||||||
|
[256]="#586e75", "#002b36", "black", "black"}, 12, 8, 256, 257},
|
||||||
|
|
||||||
|
// Gruvbox dark
|
||||||
|
{{"#282828", "#cc241d", "#98971a", "#d79921",
|
||||||
|
"#458588", "#b16286", "#689d6a", "#a89984",
|
||||||
|
"#928374", "#fb4934", "#b8bb26", "#fabd2f",
|
||||||
|
"#83a598", "#d3869b", "#8ec07c", "#ebdbb2",
|
||||||
|
[256]="#ebdbb2", "#555555", "black", "black"}, 15, 0, 256, 257},
|
||||||
|
|
||||||
|
// Gruvbox light
|
||||||
|
{{"#fbf1c7", "#cc241d", "#98971a", "#d79921",
|
||||||
|
"#458588", "#b16286", "#689d6a", "#7c6f64",
|
||||||
|
"#928374", "#9d0006", "#79740e", "#b57614",
|
||||||
|
"#076678", "#8f3f71", "#427b58", "#3c3836",
|
||||||
|
[256]="#3c3836", "#555555", "black", "black"}, 15, 0, 256, 257},
|
||||||
|
|
||||||
|
// st (dark)
|
||||||
|
{{"black", "red3", "green3", "yellow3",
|
||||||
|
"blue2", "magenta3", "cyan3", "gray90",
|
||||||
|
"gray50", "red", "green", "yellow",
|
||||||
|
"#5c5cff", "magenta", "cyan", "white",
|
||||||
|
[256]="#cccccc", "#555555", "black", "black"}, 7, 0, 256, 257},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char * const * colorname;
|
||||||
|
int colorscheme = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default colors (colorname index)
|
* Default colors (colorname index)
|
||||||
* foreground, background, cursor, reverse cursor
|
* foreground, background, cursor, reverse cursor
|
||||||
*/
|
*/
|
||||||
unsigned int defaultfg = 258;
|
unsigned int defaultfg;
|
||||||
unsigned int defaultbg = 259;
|
unsigned int defaultbg;
|
||||||
unsigned int defaultcs = 256;
|
unsigned int defaultcs;
|
||||||
static unsigned int defaultrcs = 257;
|
static unsigned int defaultrcs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default shape of cursor
|
* Default shape of cursor
|
||||||
@ -201,6 +249,17 @@ static Shortcut shortcuts[] = {
|
|||||||
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
||||||
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
||||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
||||||
|
{ 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} },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
46
st.c
46
st.c
@ -1769,11 +1769,18 @@ csihandle(void)
|
|||||||
case 'm': /* SGR -- Terminal attribute (color) */
|
case 'm': /* SGR -- Terminal attribute (color) */
|
||||||
tsetattr(csiescseq.arg, csiescseq.narg);
|
tsetattr(csiescseq.arg, csiescseq.narg);
|
||||||
break;
|
break;
|
||||||
case 'n': /* DSR – Device Status Report (cursor position) */
|
case 'n': /* DSR -- Device Status Report */
|
||||||
if (csiescseq.arg[0] == 6) {
|
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" */
|
||||||
len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
|
len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
|
||||||
term.c.y+1, term.c.x+1);
|
term.c.y+1, term.c.x+1);
|
||||||
ttywrite(buf, len, 0);
|
ttywrite(buf, len, 0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto unknown;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'r': /* DECSTBM -- Set Scrolling Region */
|
case 'r': /* DECSTBM -- Set Scrolling Region */
|
||||||
@ -1932,8 +1939,10 @@ strhandle(void)
|
|||||||
if (p && !strcmp(p, "?")) {
|
if (p && !strcmp(p, "?")) {
|
||||||
osc_color_response(j, 0, 1);
|
osc_color_response(j, 0, 1);
|
||||||
} else if (xsetcolorname(j, p)) {
|
} else if (xsetcolorname(j, p)) {
|
||||||
if (par == 104 && narg <= 1)
|
if (par == 104 && narg <= 1) {
|
||||||
|
xloadcols();
|
||||||
return; /* color reset without parameter */
|
return; /* color reset without parameter */
|
||||||
|
}
|
||||||
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
|
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
|
||||||
j, p ? p : "(null)");
|
j, p ? p : "(null)");
|
||||||
} else {
|
} else {
|
||||||
@ -2162,6 +2171,28 @@ tstrsequence(uchar c)
|
|||||||
term.esc |= ESC_STR;
|
term.esc |= ESC_STR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tupdatebgcolor(int oldbg, int newbg)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < term.row; y++) {
|
||||||
|
for (int x = 0; x < term.col; x++) {
|
||||||
|
if (term.line[y][x].bg == oldbg)
|
||||||
|
term.line[y][x].bg = newbg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tupdatefgcolor(int oldfg, int newfg)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < term.row; y++) {
|
||||||
|
for (int x = 0; x < term.col; x++) {
|
||||||
|
if (term.line[y][x].fg == oldfg)
|
||||||
|
term.line[y][x].fg = newfg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tcontrolcode(uchar ascii)
|
tcontrolcode(uchar ascii)
|
||||||
{
|
{
|
||||||
@ -2413,6 +2444,9 @@ check_control_code:
|
|||||||
* they must not cause conflicts with sequences.
|
* they must not cause conflicts with sequences.
|
||||||
*/
|
*/
|
||||||
if (control) {
|
if (control) {
|
||||||
|
/* in UTF-8 mode ignore handling C1 control characters */
|
||||||
|
if (IS_SET(MODE_UTF8) && ISCONTROLC1(u))
|
||||||
|
return;
|
||||||
tcontrolcode(u);
|
tcontrolcode(u);
|
||||||
/*
|
/*
|
||||||
* control codes are not shown ever
|
* control codes are not shown ever
|
||||||
@ -2459,8 +2493,10 @@ check_control_code:
|
|||||||
gp = &term.line[term.c.y][term.c.x];
|
gp = &term.line[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));
|
memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph));
|
||||||
|
gp->mode &= ~ATTR_WIDE;
|
||||||
|
}
|
||||||
|
|
||||||
if (term.c.x+width > term.col) {
|
if (term.c.x+width > term.col) {
|
||||||
tnewline(1);
|
tnewline(1);
|
||||||
|
2
st.h
2
st.h
@ -90,6 +90,8 @@ int tattrset(int);
|
|||||||
void tnew(int, int);
|
void tnew(int, int);
|
||||||
void tresize(int, int);
|
void tresize(int, int);
|
||||||
void tsetdirtattr(int);
|
void tsetdirtattr(int);
|
||||||
|
void tupdatebgcolor(int, int);
|
||||||
|
void tupdatefgcolor(int, int);
|
||||||
void ttyhangup(void);
|
void ttyhangup(void);
|
||||||
int ttynew(const char *, char *, const char *, char **);
|
int ttynew(const char *, char *, const char *, char **);
|
||||||
size_t ttyread(void);
|
size_t ttyread(void);
|
||||||
|
61
x.c
61
x.c
@ -59,6 +59,8 @@ static void zoom(const Arg *);
|
|||||||
static void zoomabs(const Arg *);
|
static void zoomabs(const Arg *);
|
||||||
static void zoomreset(const Arg *);
|
static void zoomreset(const Arg *);
|
||||||
static void ttysend(const Arg *);
|
static void ttysend(const Arg *);
|
||||||
|
static void nextscheme(const Arg *);
|
||||||
|
static void selectscheme(const Arg *);
|
||||||
|
|
||||||
/* config.h for applying patches and the configuration. */
|
/* config.h for applying patches and the configuration. */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -185,6 +187,7 @@ static void mousesel(XEvent *, int);
|
|||||||
static void mousereport(XEvent *);
|
static void mousereport(XEvent *);
|
||||||
static char *kmap(KeySym, uint);
|
static char *kmap(KeySym, uint);
|
||||||
static int match(uint, uint);
|
static int match(uint, uint);
|
||||||
|
static void updatescheme(void);
|
||||||
|
|
||||||
static void run(void);
|
static void run(void);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
@ -801,7 +804,7 @@ xloadcols(void)
|
|||||||
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
|
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
|
||||||
XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
|
XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
|
||||||
} else {
|
} else {
|
||||||
dc.collen = MAX(LEN(colorname), 256);
|
dc.collen = 260;
|
||||||
dc.col = xmalloc(dc.collen * sizeof(Color));
|
dc.col = xmalloc(dc.collen * sizeof(Color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1833,7 +1836,7 @@ void
|
|||||||
kpress(XEvent *ev)
|
kpress(XEvent *ev)
|
||||||
{
|
{
|
||||||
XKeyEvent *e = &ev->xkey;
|
XKeyEvent *e = &ev->xkey;
|
||||||
KeySym ksym;
|
KeySym ksym = NoSymbol;
|
||||||
char buf[64], *customkey;
|
char buf[64], *customkey;
|
||||||
int len;
|
int len;
|
||||||
Rune c;
|
Rune c;
|
||||||
@ -1843,10 +1846,13 @@ kpress(XEvent *ev)
|
|||||||
if (IS_SET(MODE_KBDLOCK))
|
if (IS_SET(MODE_KBDLOCK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (xw.ime.xic)
|
if (xw.ime.xic) {
|
||||||
len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
|
len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
|
||||||
else
|
if (status == XBufferOverflow)
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
|
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
|
||||||
|
}
|
||||||
/* 1. shortcuts */
|
/* 1. shortcuts */
|
||||||
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
||||||
if (ksym == bp->keysym && match(bp->mod, e->state)) {
|
if (ksym == bp->keysym && match(bp->mod, e->state)) {
|
||||||
@ -2024,6 +2030,47 @@ usage(void)
|
|||||||
" [stty_args ...]\n", argv0, argv0);
|
" [stty_args ...]\n", argv0, argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nextscheme(const Arg *arg)
|
||||||
|
{
|
||||||
|
colorscheme += arg->i;
|
||||||
|
if (colorscheme >= (int)LEN(schemes))
|
||||||
|
colorscheme = 0;
|
||||||
|
else if (colorscheme < 0)
|
||||||
|
colorscheme = LEN(schemes) - 1;
|
||||||
|
updatescheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
selectscheme(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (BETWEEN(arg->i, 0, LEN(schemes)-1)) {
|
||||||
|
colorscheme = arg->i;
|
||||||
|
updatescheme();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
updatescheme(void)
|
||||||
|
{
|
||||||
|
int oldbg, oldfg;
|
||||||
|
|
||||||
|
oldbg = defaultbg;
|
||||||
|
oldfg = defaultfg;
|
||||||
|
colorname = schemes[colorscheme].colors;
|
||||||
|
defaultbg = schemes[colorscheme].bg;
|
||||||
|
defaultfg = schemes[colorscheme].fg;
|
||||||
|
defaultcs = schemes[colorscheme].cs;
|
||||||
|
defaultrcs = schemes[colorscheme].rcs;
|
||||||
|
xloadcols();
|
||||||
|
if (defaultbg != oldbg)
|
||||||
|
tupdatebgcolor(oldbg, defaultbg);
|
||||||
|
if (defaultfg != oldfg)
|
||||||
|
tupdatefgcolor(oldfg, defaultfg);
|
||||||
|
cresize(win.w, win.h);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -2076,6 +2123,12 @@ main(int argc, char *argv[])
|
|||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
run:
|
run:
|
||||||
|
colorname = schemes[colorscheme].colors;
|
||||||
|
defaultbg = schemes[colorscheme].bg;
|
||||||
|
defaultfg = schemes[colorscheme].fg;
|
||||||
|
defaultcs = schemes[colorscheme].cs;
|
||||||
|
defaultrcs = schemes[colorscheme].rcs;
|
||||||
|
|
||||||
if (argc > 0) /* eat all remaining arguments */
|
if (argc > 0) /* eat all remaining arguments */
|
||||||
opt_cmd = argv;
|
opt_cmd = argv;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user