This commit is contained in:
WanderingPenwing 2024-07-29 12:54:38 +02:00
parent 73f6a950ad
commit dd0b463434
6 changed files with 64 additions and 86 deletions

View file

@ -1,14 +1,12 @@
/* See LICENSE file for copyright and license details. */
void clearhistory(const Arg *arg);
/*
* appearance
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "DejaVu Sans Mono:pixelsize=16:antialias=true:autohint=true";
static int borderpx = 2;
static char *font = "Mononoki Nerd Font:pixelsize=20:antialias=true:autohint=true";
static int borderpx = 16;
/*
* What program is execed by st depends of these precedence rules:
@ -100,30 +98,30 @@ static const int alpha = 0xff;
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
/* 8 normal colors */
"#3B4252", /* nord1 */
"#BF616A", /* nord11 */
"#A3BE8C", /* nord14 */
"#EBCB8B", /* nord13 */
"#81A1C1", /* nord9 */
"#B48EAD", /* nord15 */
"#88C0D0", /* nord8 */
"#E5E9F0", /* nord5 */
"#222222",
"#FF5555",
"#5FD38D",
"#FF9955",
"#3771C8",
"#BC5FD3",
"#5FD3BC",
"#999999",
/* 8 bright colors */
"#4C566A", /* nord3 */
"#D08770", /* nord12 */
"#8FBCBB", /* nord7 */
"#EBCB8B", /* nord13 */
"#5E81AC", /* nord10 */
"#B48EAD", /* nord15 (same as normal magenta) */
"#88C0D0", /* nord8 (same as normal cyan) */
"#ECEFF4", /* nord6 */
"#666666",
"#FF8080",
"#87DEAA",
"#FFB380",
"#5F8DD3",
"#CD87DE",
"#87DECD",
"#CCCCCC",
[255] = 0,
/* more colors can be added after 255 to use with DefaultXX */
"#D8DEE9", /* nord4 (default foreground colour) */
"#2E3440", /* nord0 (default background colour) */
"#CCCCCC", /* nord4 (default foreground colour) */
"#222222", /* nord0 (default background colour) */
};
@ -201,9 +199,7 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
{ TERMMOD, XK_V, clippaste, {.i = 0} },
{ 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,8 +225,6 @@ 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;
@ -241,23 +239,6 @@ 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.

87
x.c
View file

@ -41,13 +41,13 @@ typedef struct {
uint mask;
char *s;
/* three-valued logic variables: 0 indifferent, 1 on, -1 off */
signed char appkey; /* application keypad */
signed char appkey; /* application keypad */
signed char appcursor; /* application cursor */
} Key;
/* X modifiers */
#define XK_ANY_MOD UINT_MAX
#define XK_NO_MOD 0
#define XK_ANY_MOD UINT_MAX
#define XK_NO_MOD 0
#define XK_SWITCH_MOD (1<<13|1<<14)
/* function definitions used in config.h */
@ -247,7 +247,7 @@ static char *opt_class = NULL;
static char **opt_cmd = NULL;
static char *opt_embed = NULL;
static char *opt_font = NULL;
static char *opt_io = NULL;
static char *opt_io = NULL;
static char *opt_line = NULL;
static char *opt_name = NULL;
static char *opt_title = NULL;
@ -273,6 +273,7 @@ void
clippaste(const Arg *dummy)
{
Atom clipboard;
printf("test");
clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard,
@ -415,8 +416,8 @@ mousereport(XEvent *e)
if (!IS_SET(MODE_MOUSEX10)) {
code += ((state & ShiftMask ) ? 4 : 0)
+ ((state & Mod1Mask ) ? 8 : 0) /* meta key: alt */
+ ((state & ControlMask) ? 16 : 0);
+ ((state & Mod1Mask ) ? 8 : 0) /* meta key: alt */
+ ((state & ControlMask) ? 16 : 0);
}
if (IS_SET(MODE_MOUSESGR)) {
@ -437,11 +438,11 @@ uint
buttonmask(uint button)
{
return button == Button1 ? Button1Mask
: button == Button2 ? Button2Mask
: button == Button3 ? Button3Mask
: button == Button4 ? Button4Mask
: button == Button5 ? Button5Mask
: 0;
: button == Button2 ? Button2Mask
: button == Button3 ? Button3Mask
: button == Button4 ? Button4Mask
: button == Button5 ? Button5Mask
: 0;
}
int
@ -454,9 +455,9 @@ mouseaction(XEvent *e, uint release)
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
if (ms->release == release &&
ms->button == e->xbutton.button &&
(match(ms->mod, state) || /* exact or forced */
match(ms->mod, state & ~forcemousemod))) {
ms->button == e->xbutton.button &&
(match(ms->mod, state) || /* exact or forced */
match(ms->mod, state & ~forcemousemod))) {
ms->func(&(ms->arg));
return 1;
}
@ -782,7 +783,7 @@ xloadcolor(int i, const char *name, Color *ncolor)
color.green = color.blue = color.red;
}
return XftColorAllocValue(xw.dpy, xw.vis,
xw.cmap, &color, ncolor);
xw.cmap, &color, ncolor);
} else
name = colorname[i];
}
@ -860,7 +861,7 @@ void
xhints(void)
{
XClassHint class = {opt_name ? opt_name : termname,
opt_class ? opt_class : termname};
opt_class ? opt_class : termname};
XWMHints wm = {.flags = InputHint, .input = 1};
XSizeHints *sizeh;
@ -941,22 +942,22 @@ xloadfont(Font *f, FcPattern *pattern)
}
if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) ==
XftResultMatch)) {
XftResultMatch)) {
/*
* Check if xft was unable to find a font with the appropriate
* slant but gave us one anyway. Try to mitigate.
*/
if ((XftPatternGetInteger(f->match->pattern, "slant", 0,
&haveattr) != XftResultMatch) || haveattr < wantattr) {
&haveattr) != XftResultMatch) || haveattr < wantattr) {
f->badslant = 1;
fputs("font slant does not match\n", stderr);
}
}
if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) ==
XftResultMatch)) {
XftResultMatch)) {
if ((XftPatternGetInteger(f->match->pattern, "weight", 0,
&haveattr) != XftResultMatch) || haveattr != wantattr) {
&haveattr) != XftResultMatch) || haveattr != wantattr) {
f->badweight = 1;
fputs("font weight does not match\n", stderr);
}
@ -1022,7 +1023,7 @@ xloadfonts(const char *fontstr, double fontsize)
if (usedfontsize < 0) {
FcPatternGetDouble(dc.font.match->pattern,
FC_PIXEL_SIZE, 0, &fontval);
FC_PIXEL_SIZE, 0, &fontval);
usedfontsize = fontval;
if (fontsize == 0)
defaultfontsize = fontval;
@ -1084,17 +1085,17 @@ ximopen(Display *dpy)
if (XSetIMValues(xw.ime.xim, XNDestroyCallback, &imdestroy, NULL))
fprintf(stderr, "XSetIMValues: "
"Could not set XNDestroyCallback.\n");
"Could not set XNDestroyCallback.\n");
xw.ime.spotlist = XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot,
NULL);
NULL);
if (xw.ime.xic == NULL) {
xw.ime.xic = XCreateIC(xw.ime.xim, XNInputStyle,
XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, xw.win,
XNDestroyCallback, &icdestroy,
NULL);
XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, xw.win,
XNDestroyCallback, &icdestroy,
NULL);
}
if (xw.ime.xic == NULL)
fprintf(stderr, "XCreateIC: Could not create input context.\n");
@ -1107,7 +1108,7 @@ ximinstantiate(Display *dpy, XPointer client, XPointer call)
{
if (ximopen(dpy))
XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL);
ximinstantiate, NULL);
}
void
@ -1115,7 +1116,7 @@ ximdestroy(XIM xim, XPointer client, XPointer call)
{
xw.ime.xim = NULL;
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL);
ximinstantiate, NULL);
XFree(xw.ime.spotlist);
}
@ -1193,7 +1194,7 @@ xinit(int cols, int rows)
/* input methods */
if (!ximopen(xw.dpy)) {
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL);
ximinstantiate, NULL);
}
/* white cursor, black outline */
@ -1312,7 +1313,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
if (f >= frclen) {
if (!font->set)
font->set = FcFontSort(0, font->pattern,
1, 0, &fcres);
1, 0, &fcres);
fcsets[0] = font->set;
/*
@ -1376,7 +1377,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
{
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
width = charlen * win.cw;
width = charlen * win.cw;
Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
XRenderColor colfg, colbg;
XRectangle r;
@ -1386,7 +1387,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
if (dc.ibfont.badslant || dc.ibfont.badweight)
base.fg = defaultattr;
} else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) ||
(base.mode & ATTR_BOLD && dc.bfont.badweight)) {
(base.mode & ATTR_BOLD && dc.bfont.badweight)) {
base.fg = defaultattr;
}
@ -1621,7 +1622,7 @@ xseticontitle(char *p)
p = opt_title;
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop) != Success)
&prop) != Success)
return;
XSetWMIconName(xw.dpy, xw.win, &prop);
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
@ -1638,7 +1639,7 @@ xsettitle(char *p)
p = opt_title;
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop) != Success)
&prop) != Success)
return;
XSetWMName(xw.dpy, xw.win, &prop);
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
@ -1995,7 +1996,7 @@ run(void)
drawing = 1;
}
timeout = (maxlatency - TIMEDIFF(now, trigger)) \
/ maxlatency * minlatency;
/ maxlatency * minlatency;
if (timeout > 0)
continue; /* we have time, try to find idle */
}
@ -2024,13 +2025,13 @@ void
usage(void)
{
die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]"
" [-n name] [-o file]\n"
" [-T title] [-t title] [-w windowid]"
" [[-e] command [args ...]]\n"
" %s [-aiv] [-c class] [-f font] [-g geometry]"
" [-n name] [-o file]\n"
" [-T title] [-t title] [-w windowid] -l line"
" [stty_args ...]\n", argv0, argv0);
" [-n name] [-o file]\n"
" [-T title] [-t title] [-w windowid]"
" [[-e] command [args ...]]\n"
" %s [-aiv] [-c class] [-f font] [-g geometry]"
" [-n name] [-o file]\n"
" [-T title] [-t title] [-w windowid] -l line"
" [stty_args ...]\n", argv0, argv0);
}
int

BIN
x.o

Binary file not shown.