Compare commits

..
1 Commits
Author SHA1 Message Date
doryan 3285ec77ca first commit: new st config 2024-09-14 22:44:52 +04:00
12 changed files with 465 additions and 5513 deletions

No files matched your search

-3
View File
@@ -1,3 +0,0 @@
*.o
*.diff
+36 -31
View File
@@ -5,12 +5,8 @@
* *
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/ */
static char *font = static char *font = "FiraCode Nerd Font Propo:pixelsize=13";
"JetBrainsMono NFP:pixelsize=15:antialias=true:autohint=true"; static int borderpx = 5;
static char *font2[] = {
"Noto Color Emoji:pixelsize=15:antialias=true:autohint=true",
};
static int borderpx = 2;
/* /*
* What program is execed by st depends of these precedence rules: * What program is execed by st depends of these precedence rules:
@@ -20,7 +16,7 @@ static int borderpx = 2;
* 4: value of shell in /etc/passwd * 4: value of shell in /etc/passwd
* 5: value of shell in config.h * 5: value of shell in config.h
*/ */
static char *shell = "/bin/bash"; static char *shell = "/bin/sh";
char *utmp = NULL; char *utmp = NULL;
/* scroll program: to enable use a string like "scroll" */ /* scroll program: to enable use a string like "scroll" */
char *scroll = NULL; char *scroll = NULL;
@@ -100,31 +96,37 @@ unsigned int tabspaces = 8;
/* Terminal colors (16 first used in escape sequence) */ /* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = { static const char *colorname[] = {
/* 8 normal colors */ /* 8 normal colors */
[0] = "#282828", /* hard contrast: #1d2021 / soft contrast: #32302f */ "#323437",
[1] = "#cc241d", /* red */ "#ff5454",
[2] = "#98971a", /* green */ "#8cc85f",
[3] = "#d79921", /* yellow */ "#e3c78a",
[4] = "#458588", /* blue */ "#80a0ff",
[5] = "#b16286", /* magenta */ "#d183e8",
[6] = "#689d6a", /* cyan */ "#79dac8",
[7] = "#a89984", /* white */ "#a1aab8",
[8] = "#928374", /* black */ "#7c8f8f",
[9] = "#fb4934", /* red */ "#ff5189",
[10] = "#b8bb26", /* green */ "#36c692",
[11] = "#fabd2f", /* yellow */ "#bfbf97",
[12] = "#83a598", /* blue */ "#74b2ff",
[13] = "#d3869b", /* magenta */ "#ae81ff",
[14] = "#8ec07c", /* cyan */ "#85dc85",
[15] = "#ebdbb2", /* white */ "#e2637f",
[255] = 0, [255] = 0,
/* more colors can be added after 255 to use with DefaultXX */
"#272727",
"#f8f8f2",
"#080808",
"#eeeeee",
}; };
/* /*
* Default colors (colorname index) * Default colors (colorname index)
* foreground, background, cursor, reverse cursor * foreground, background, cursor, reverse cursor
*/ */
unsigned int defaultfg = 15; unsigned int defaultfg = 259;
unsigned int defaultbg = 0; unsigned int defaultbg = 256;
unsigned int defaultcs = 15; unsigned int defaultcs = 257;
static unsigned int defaultrcs = 257; static unsigned int defaultrcs = 257;
/* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81 /* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
@@ -173,10 +175,9 @@ static uint forcemousemod = ShiftMask;
* Beware that overloading Button1 will disable the selection. * Beware that overloading Button1 will disable the selection.
*/ */
static MouseShortcut mshortcuts[] = { static MouseShortcut mshortcuts[] = {
/* mask button function argument release */ /* mask button function argument release alt */
{XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1}, { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, -1 },
{ShiftMask, Button4, kscrollup, {.i = 1}}, { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, -1 },
{ShiftMask, Button5, kscrolldown, {.i = 1}},
}; };
/* Internal keyboard shortcuts. */ /* Internal keyboard shortcuts. */
@@ -197,8 +198,11 @@ 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} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
}; };
/* /*
* Special keys (change & recompile st.info accordingly) * Special keys (change & recompile st.info accordingly)
* *
@@ -464,6 +468,7 @@ static uint selmasks[] = {
* Printable characters in ASCII, used to estimate the advance width * Printable characters in ASCII, used to estimate the advance width
* of single wide characters. * of single wide characters.
*/ */
static char ascii_printable[] = " !\"#$%&'()*+,-./0123456789:;<=>?" static char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~"; "`abcdefghijklmnopqrstuvwxyz{|}~";
+36 -31
View File
@@ -5,12 +5,8 @@
* *
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/ */
static char *font = static char *font = "FiraCode Nerd Font Propo:pixelsize=13";
"JetBrainsMono NFP:pixelsize=15:antialias=true:autohint=true"; static int borderpx = 5;
static char *font2[] = {
"Noto Color Emoji:pixelsize=15:antialias=true:autohint=true",
};
static int borderpx = 2;
/* /*
* What program is execed by st depends of these precedence rules: * What program is execed by st depends of these precedence rules:
@@ -20,7 +16,7 @@ static int borderpx = 2;
* 4: value of shell in /etc/passwd * 4: value of shell in /etc/passwd
* 5: value of shell in config.h * 5: value of shell in config.h
*/ */
static char *shell = "/bin/bash"; static char *shell = "/bin/sh";
char *utmp = NULL; char *utmp = NULL;
/* scroll program: to enable use a string like "scroll" */ /* scroll program: to enable use a string like "scroll" */
char *scroll = NULL; char *scroll = NULL;
@@ -100,31 +96,37 @@ unsigned int tabspaces = 8;
/* Terminal colors (16 first used in escape sequence) */ /* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = { static const char *colorname[] = {
/* 8 normal colors */ /* 8 normal colors */
[0] = "#282828", /* hard contrast: #1d2021 / soft contrast: #32302f */ "#323437",
[1] = "#cc241d", /* red */ "#ff5454",
[2] = "#98971a", /* green */ "#8cc85f",
[3] = "#d79921", /* yellow */ "#e3c78a",
[4] = "#458588", /* blue */ "#80a0ff",
[5] = "#b16286", /* magenta */ "#d183e8",
[6] = "#689d6a", /* cyan */ "#79dac8",
[7] = "#a89984", /* white */ "#a1aab8",
[8] = "#928374", /* black */ "#7c8f8f",
[9] = "#fb4934", /* red */ "#ff5189",
[10] = "#b8bb26", /* green */ "#36c692",
[11] = "#fabd2f", /* yellow */ "#bfbf97",
[12] = "#83a598", /* blue */ "#74b2ff",
[13] = "#d3869b", /* magenta */ "#ae81ff",
[14] = "#8ec07c", /* cyan */ "#85dc85",
[15] = "#ebdbb2", /* white */ "#e2637f",
[255] = 0, [255] = 0,
/* more colors can be added after 255 to use with DefaultXX */
"#272727",
"#f8f8f2",
"#080808",
"#eeeeee",
}; };
/* /*
* Default colors (colorname index) * Default colors (colorname index)
* foreground, background, cursor, reverse cursor * foreground, background, cursor, reverse cursor
*/ */
unsigned int defaultfg = 15; unsigned int defaultfg = 259;
unsigned int defaultbg = 0; unsigned int defaultbg = 256;
unsigned int defaultcs = 15; unsigned int defaultcs = 257;
static unsigned int defaultrcs = 257; static unsigned int defaultrcs = 257;
/* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81 /* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
@@ -173,10 +175,9 @@ static uint forcemousemod = ShiftMask;
* Beware that overloading Button1 will disable the selection. * Beware that overloading Button1 will disable the selection.
*/ */
static MouseShortcut mshortcuts[] = { static MouseShortcut mshortcuts[] = {
/* mask button function argument release */ /* mask button function argument release alt */
{XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1}, { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, -1 },
{ShiftMask, Button4, kscrollup, {.i = 1}}, { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, -1 },
{ShiftMask, Button5, kscrolldown, {.i = 1}},
}; };
/* Internal keyboard shortcuts. */ /* Internal keyboard shortcuts. */
@@ -197,8 +198,11 @@ 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} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
}; };
/* /*
* Special keys (change & recompile st.info accordingly) * Special keys (change & recompile st.info accordingly)
* *
@@ -464,6 +468,7 @@ static uint selmasks[] = {
* Printable characters in ASCII, used to estimate the advance width * Printable characters in ASCII, used to estimate the advance width
* of single wide characters. * of single wide characters.
*/ */
static char ascii_printable[] = " !\"#$%&'()*+,-./0123456789:;<=>?" static char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~"; "`abcdefghijklmnopqrstuvwxyz{|}~";
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+391 -176
View File
File diff suppressed because it is too large. Load diff
-2749
View File
File diff suppressed because it is too large. Load diff
-129
View File
@@ -1,129 +0,0 @@
/* See LICENSE for license details. */
#include <stdint.h>
#include <sys/types.h>
/* macros */
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a) / sizeof(a)[0])
#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
#define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP)) != ((b).mode & (~ATTR_WRAP)) || \
(a).fg != (b).fg || \
(a).bg != (b).bg)
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
(t1.tv_nsec-t2.tv_nsec)/1E6)
#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
#define IS_TRUECOL(x) (1 << 24 & (x))
enum glyph_attribute {
ATTR_NULL = 0,
ATTR_BOLD = 1 << 0,
ATTR_FAINT = 1 << 1,
ATTR_ITALIC = 1 << 2,
ATTR_UNDERLINE = 1 << 3,
ATTR_BLINK = 1 << 4,
ATTR_REVERSE = 1 << 5,
ATTR_INVISIBLE = 1 << 6,
ATTR_STRUCK = 1 << 7,
ATTR_WRAP = 1 << 8,
ATTR_WIDE = 1 << 9,
ATTR_WDUMMY = 1 << 10,
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
};
enum selection_mode {
SEL_IDLE = 0,
SEL_EMPTY = 1,
SEL_READY = 2
};
enum selection_type {
SEL_REGULAR = 1,
SEL_RECTANGULAR = 2
};
enum selection_snap {
SNAP_WORD = 1,
SNAP_LINE = 2
};
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned short ushort;
typedef uint_least32_t Rune;
#define Glyph Glyph_
typedef struct {
Rune u; /* character code */
ushort mode; /* attribute flags */
uint32_t fg; /* foreground */
uint32_t bg; /* background */
} Glyph;
typedef Glyph *Line;
typedef union {
int i;
uint ui;
float f;
const void *v;
const char *s;
} Arg;
void die(const char *, ...);
void redraw(void);
void draw(void);
void kscrolldown(const Arg *);
void kscrollup(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);
void toggleprinter(const Arg *);
int tattrset(int);
void tnew(int, int);
void tresize(int, int);
void tsetdirtattr(int);
void ttyhangup(void);
int ttynew(const char *, char *, const char *, char **);
size_t ttyread(void);
void ttyresize(int, int);
void ttywrite(const char *, size_t, int);
void resettitle(void);
void selclear(void);
void selinit(void);
void selstart(int, int, int);
void selextend(int, int, int, int);
int selected(int, int);
char *getsel(void);
size_t utf8encode(Rune, char *);
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(const char *);
/* config.h globals */
extern char *utmp;
extern char *scroll;
extern char *stty_args;
extern char *vtiden;
extern wchar_t *worddelimiters;
extern int allowaltscreen;
extern int allowwindowops;
extern char *termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
extern unsigned int defaultbg;
extern unsigned int defaultcs;
BIN
View File
Binary file not shown.
+2 -110
View File
@@ -4,7 +4,6 @@
#include <limits.h> #include <limits.h>
#include <locale.h> #include <locale.h>
#include <signal.h> #include <signal.h>
#include <stdlib.h>
#include <sys/select.h> #include <sys/select.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@@ -160,8 +159,6 @@ static void xhints(void);
static int xloadcolor(int, const char *, Color *); static int xloadcolor(int, const char *, Color *);
static int xloadfont(Font *, FcPattern *); static int xloadfont(Font *, FcPattern *);
static void xloadfonts(const char *, double); static void xloadfonts(const char *, double);
static int xloadsparefont(FcPattern *, int);
static void xloadsparefonts(void);
static void xunloadfont(Font *); static void xunloadfont(Font *);
static void xunloadfonts(void); static void xunloadfonts(void);
static void xsetenv(void); static void xsetenv(void);
@@ -312,7 +309,6 @@ zoomabs(const Arg *arg)
{ {
xunloadfonts(); xunloadfonts();
xloadfonts(usedfont, arg->f); xloadfonts(usedfont, arg->f);
xloadsparefonts();
cresize(0, 0); cresize(0, 0);
redraw(); redraw();
xhints(); xhints();
@@ -1057,101 +1053,6 @@ xloadfonts(const char *fontstr, double fontsize)
FcPatternDestroy(pattern); FcPatternDestroy(pattern);
} }
int
xloadsparefont(FcPattern *pattern, int flags)
{
FcPattern *match;
FcResult result;
match = FcFontMatch(NULL, pattern, &result);
if (!match) {
return 1;
}
if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) {
FcPatternDestroy(match);
return 1;
}
frc[frclen].flags = flags;
/* Believe U+0000 glyph will present in each default font */
frc[frclen].unicodep = 0;
frclen++;
return 0;
}
void
xloadsparefonts(void)
{
FcPattern *pattern;
double sizeshift, fontval;
int fc;
char **fp;
if (frclen != 0)
die("can't embed spare fonts. cache isn't empty");
/* Calculate count of spare fonts */
fc = sizeof(font2) / sizeof(*font2);
if (fc == 0)
return;
/* Allocate memory for cache entries. */
if (frccap < 4 * fc) {
frccap += 4 * fc - frccap;
frc = xrealloc(frc, frccap * sizeof(Fontcache));
}
for (fp = font2; fp - font2 < fc; ++fp) {
if (**fp == '-')
pattern = XftXlfdParse(*fp, False, False);
else
pattern = FcNameParse((FcChar8 *)*fp);
if (!pattern)
die("can't open spare font %s\n", *fp);
if (defaultfontsize > 0) {
sizeshift = usedfontsize - defaultfontsize;
if (sizeshift != 0 &&
FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
FcResultMatch) {
fontval += sizeshift;
FcPatternDel(pattern, FC_PIXEL_SIZE);
FcPatternDel(pattern, FC_SIZE);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval);
}
}
FcPatternAddBool(pattern, FC_SCALABLE, 1);
FcConfigSubstitute(NULL, pattern, FcMatchPattern);
XftDefaultSubstitute(xw.dpy, xw.scr, pattern);
if (xloadsparefont(pattern, FRC_NORMAL))
die("can't open spare font %s\n", *fp);
FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
if (xloadsparefont(pattern, FRC_ITALIC))
die("can't open spare font %s\n", *fp);
FcPatternDel(pattern, FC_WEIGHT);
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
if (xloadsparefont(pattern, FRC_ITALICBOLD))
die("can't open spare font %s\n", *fp);
FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
if (xloadsparefont(pattern, FRC_BOLD))
die("can't open spare font %s\n", *fp);
FcPatternDestroy(pattern);
}
}
void void
xunloadfont(Font *f) xunloadfont(Font *f)
{ {
@@ -1250,11 +1151,7 @@ xinit(int cols, int rows)
die("could not init fontconfig.\n"); die("could not init fontconfig.\n");
usedfont = (opt_font == NULL)? font : opt_font; usedfont = (opt_font == NULL)? font : opt_font;
xloadfonts(usedfont, 0);
xloadfonts(usedfont, defaultfontsize);
/* spare fonts */
xloadsparefonts();
/* colors */ /* colors */
xw.cmap = XDefaultColormap(xw.dpy, xw.scr); xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
@@ -1752,7 +1649,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
break; break;
/* FALLTHROUGH */ /* FALLTHROUGH */
case 8: /* steady st cursor */ case 8: /* steady st cursor */
g.u = (unsigned int) xsetcursor; g.u = xsetcursor;
xdrawglyph(g, cx, cy); xdrawglyph(g, cx, cy);
break; break;
} }
@@ -2261,11 +2158,6 @@ main(int argc, char *argv[])
case 'v': case 'v':
die("%s " VERSION "\n", argv0); die("%s " VERSION "\n", argv0);
break; break;
case 'z':
defaultfontsize = strtod(EARGF(usage()), NULL);
if (!(defaultfontsize > 0))
usage();
break;
default: default:
usage(); usage();
} ARGEND; } ARGEND;
-2284
View File
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.