Compare commits
9 Commits
feat/scrol
...
feat/under
Author | SHA1 | Date | |
---|---|---|---|
9e7f107c1f | |||
0749fc4857 | |||
539dfd0bac | |||
af62c87aa8 | |||
aa9d16a41b | |||
71d1f725b3 | |||
fb7383d52f | |||
3a32e68b82 | |||
a8d62fe07b |
5
Makefile
5
Makefile
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = st.c x.c hb.c
|
SRC = st.c x.c
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
all: options st
|
all: options st
|
||||||
@ -22,8 +22,7 @@ config.h:
|
|||||||
$(CC) $(STCFLAGS) -c $<
|
$(CC) $(STCFLAGS) -c $<
|
||||||
|
|
||||||
st.o: config.h st.h win.h
|
st.o: config.h st.h win.h
|
||||||
x.o: arg.h config.h st.h win.h hb.h
|
x.o: arg.h config.h st.h win.h
|
||||||
hb.o: st.h
|
|
||||||
|
|
||||||
$(OBJ): config.h config.mk
|
$(OBJ): config.h config.mk
|
||||||
|
|
||||||
|
81
config.def.h
81
config.def.h
@ -56,6 +56,12 @@ int allowwindowops = 0;
|
|||||||
static double minlatency = 8;
|
static double minlatency = 8;
|
||||||
static double maxlatency = 33;
|
static double maxlatency = 33;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Synchronized-Update timeout in ms
|
||||||
|
* https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec
|
||||||
|
*/
|
||||||
|
static uint su_timeout = 200;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
||||||
* attribute.
|
* attribute.
|
||||||
@ -93,35 +99,30 @@ char *termname = "st-256color";
|
|||||||
*/
|
*/
|
||||||
unsigned int tabspaces = 8;
|
unsigned int tabspaces = 8;
|
||||||
|
|
||||||
|
/* bg opacity */
|
||||||
|
float alpha = 0.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 */
|
||||||
"black",
|
[0] = "#282828", /* hard contrast: #1d2021 / soft contrast: #32302f */
|
||||||
"red3",
|
[1] = "#cc241d", /* red */
|
||||||
"green3",
|
[2] = "#98971a", /* green */
|
||||||
"yellow3",
|
[3] = "#d79921", /* yellow */
|
||||||
"blue2",
|
[4] = "#458588", /* blue */
|
||||||
"magenta3",
|
[5] = "#b16286", /* magenta */
|
||||||
"cyan3",
|
[6] = "#689d6a", /* cyan */
|
||||||
"gray90",
|
[7] = "#a89984", /* white */
|
||||||
|
|
||||||
/* 8 bright colors */
|
/* 8 bright colors */
|
||||||
"gray50",
|
[8] = "#928374", /* black */
|
||||||
"red",
|
[9] = "#fb4934", /* red */
|
||||||
"green",
|
[10] = "#b8bb26", /* green */
|
||||||
"yellow",
|
[11] = "#fabd2f", /* yellow */
|
||||||
"#5c5cff",
|
[12] = "#83a598", /* blue */
|
||||||
"magenta",
|
[13] = "#d3869b", /* magenta */
|
||||||
"cyan",
|
[14] = "#8ec07c", /* cyan */
|
||||||
"white",
|
[15] = "#ebdbb2", /* white */
|
||||||
|
|
||||||
[255] = 0,
|
|
||||||
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
|
||||||
"#cccccc",
|
|
||||||
"#555555",
|
|
||||||
"gray90", /* default foreground colour */
|
|
||||||
"black", /* default background colour */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -129,9 +130,9 @@ static const char *colorname[] = {
|
|||||||
* 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 = 15;
|
||||||
unsigned int defaultbg = 259;
|
unsigned int defaultbg = 0;
|
||||||
unsigned int defaultcs = 256;
|
unsigned int defaultcs = 15;
|
||||||
static unsigned int defaultrcs = 257;
|
static unsigned int defaultrcs = 257;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -201,8 +202,6 @@ 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} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -474,3 +473,27 @@ static char ascii_printable[] =
|
|||||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undercurl style. Set UNDERCURL_STYLE to one of the available styles.
|
||||||
|
*
|
||||||
|
* Curly: Dunno how to draw it *shrug*
|
||||||
|
* _ _ _ _
|
||||||
|
* ( ) ( ) ( ) ( )
|
||||||
|
* (_) (_) (_) (_)
|
||||||
|
*
|
||||||
|
* Spiky:
|
||||||
|
* /\ /\ /\ /\
|
||||||
|
* \/ \/ \/
|
||||||
|
*
|
||||||
|
* Capped:
|
||||||
|
* _ _ _
|
||||||
|
* / \ / \ / \
|
||||||
|
* \_/ \_/
|
||||||
|
*/
|
||||||
|
// Available styles
|
||||||
|
#define UNDERCURL_CURLY 0
|
||||||
|
#define UNDERCURL_SPIKY 1
|
||||||
|
#define UNDERCURL_CAPPED 2
|
||||||
|
// Active style
|
||||||
|
#define UNDERCURL_STYLE UNDERCURL_SPIKY
|
||||||
|
@ -15,12 +15,10 @@ PKG_CONFIG = pkg-config
|
|||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I$(X11INC) \
|
INCS = -I$(X11INC) \
|
||||||
`$(PKG_CONFIG) --cflags fontconfig` \
|
`$(PKG_CONFIG) --cflags fontconfig` \
|
||||||
`$(PKG_CONFIG) --cflags freetype2` \
|
`$(PKG_CONFIG) --cflags freetype2`
|
||||||
`$(PKG_CONFIG) --cflags harfbuzz`
|
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
|
||||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
|
||||||
`$(PKG_CONFIG) --libs fontconfig` \
|
`$(PKG_CONFIG) --libs fontconfig` \
|
||||||
`$(PKG_CONFIG) --libs freetype2` \
|
`$(PKG_CONFIG) --libs freetype2`
|
||||||
`$(PKG_CONFIG) --cflags harfbuzz`
|
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
||||||
|
124
hb.c
124
hb.c
@ -1,124 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <X11/Xft/Xft.h>
|
|
||||||
#include <X11/cursorfont.h>
|
|
||||||
#include <hb.h>
|
|
||||||
#include <hb-ft.h>
|
|
||||||
|
|
||||||
#include "st.h"
|
|
||||||
#include "hb.h"
|
|
||||||
|
|
||||||
#define FEATURE(c1,c2,c3,c4) { .tag = HB_TAG(c1,c2,c3,c4), .value = 1, .start = HB_FEATURE_GLOBAL_START, .end = HB_FEATURE_GLOBAL_END }
|
|
||||||
#define BUFFER_STEP 256
|
|
||||||
|
|
||||||
hb_font_t *hbfindfont(XftFont *match);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
XftFont *match;
|
|
||||||
hb_font_t *font;
|
|
||||||
} HbFontMatch;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
size_t capacity;
|
|
||||||
HbFontMatch *fonts;
|
|
||||||
} HbFontCache;
|
|
||||||
|
|
||||||
static HbFontCache hbfontcache = { 0, NULL };
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
size_t capacity;
|
|
||||||
Rune *runes;
|
|
||||||
} RuneBuffer;
|
|
||||||
|
|
||||||
static RuneBuffer hbrunebuffer = { 0, NULL };
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Poplulate the array with a list of font features, wrapped in FEATURE macro,
|
|
||||||
* e. g.
|
|
||||||
* FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
|
|
||||||
*/
|
|
||||||
hb_feature_t features[] = { };
|
|
||||||
|
|
||||||
void
|
|
||||||
hbunloadfonts()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < hbfontcache.capacity; i++) {
|
|
||||||
hb_font_destroy(hbfontcache.fonts[i].font);
|
|
||||||
XftUnlockFace(hbfontcache.fonts[i].match);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hbfontcache.fonts != NULL) {
|
|
||||||
free(hbfontcache.fonts);
|
|
||||||
hbfontcache.fonts = NULL;
|
|
||||||
}
|
|
||||||
hbfontcache.capacity = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
hb_font_t *
|
|
||||||
hbfindfont(XftFont *match)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < hbfontcache.capacity; i++) {
|
|
||||||
if (hbfontcache.fonts[i].match == match)
|
|
||||||
return hbfontcache.fonts[i].font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Font not found in cache, caching it now. */
|
|
||||||
hbfontcache.fonts = realloc(hbfontcache.fonts, sizeof(HbFontMatch) * (hbfontcache.capacity + 1));
|
|
||||||
FT_Face face = XftLockFace(match);
|
|
||||||
hb_font_t *font = hb_ft_font_create(face, NULL);
|
|
||||||
if (font == NULL)
|
|
||||||
die("Failed to load Harfbuzz font.");
|
|
||||||
|
|
||||||
hbfontcache.fonts[hbfontcache.capacity].match = match;
|
|
||||||
hbfontcache.fonts[hbfontcache.capacity].font = font;
|
|
||||||
hbfontcache.capacity += 1;
|
|
||||||
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hbtransform(HbTransformData *data, XftFont *xfont, const Glyph *glyphs, int start, int length) {
|
|
||||||
ushort mode = USHRT_MAX;
|
|
||||||
unsigned int glyph_count;
|
|
||||||
int rune_idx, glyph_idx, end = start + length;
|
|
||||||
|
|
||||||
hb_font_t *font = hbfindfont(xfont);
|
|
||||||
if (font == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hb_buffer_t *buffer = hb_buffer_create();
|
|
||||||
hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
|
|
||||||
|
|
||||||
/* Resize the buffer if required length is larger. */
|
|
||||||
if (hbrunebuffer.capacity < length) {
|
|
||||||
hbrunebuffer.capacity = (length / BUFFER_STEP + 1) * BUFFER_STEP;
|
|
||||||
hbrunebuffer.runes = realloc(hbrunebuffer.runes, hbrunebuffer.capacity * sizeof(Rune));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill buffer with codepoints. */
|
|
||||||
for (rune_idx = 0, glyph_idx = start; glyph_idx < end; glyph_idx++, rune_idx++) {
|
|
||||||
hbrunebuffer.runes[rune_idx] = glyphs[glyph_idx].u;
|
|
||||||
mode = glyphs[glyph_idx].mode;
|
|
||||||
if (mode & ATTR_WDUMMY)
|
|
||||||
hbrunebuffer.runes[rune_idx] = 0x0020;
|
|
||||||
}
|
|
||||||
hb_buffer_add_codepoints(buffer, hbrunebuffer.runes, length, 0, length);
|
|
||||||
|
|
||||||
/* Shape the segment. */
|
|
||||||
hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
|
|
||||||
|
|
||||||
/* Get new glyph info. */
|
|
||||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, &glyph_count);
|
|
||||||
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions(buffer, &glyph_count);
|
|
||||||
|
|
||||||
/* Fill the output. */
|
|
||||||
data->buffer = buffer;
|
|
||||||
data->glyphs = info;
|
|
||||||
data->positions = pos;
|
|
||||||
data->count = glyph_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hbcleanup(HbTransformData *data) {
|
|
||||||
hb_buffer_destroy(data->buffer);
|
|
||||||
memset(data, 0, sizeof(HbTransformData));
|
|
||||||
}
|
|
14
hb.h
14
hb.h
@ -1,14 +0,0 @@
|
|||||||
#include <X11/Xft/Xft.h>
|
|
||||||
#include <hb.h>
|
|
||||||
#include <hb-ft.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
hb_buffer_t *buffer;
|
|
||||||
hb_glyph_info_t *glyphs;
|
|
||||||
hb_glyph_position_t *positions;
|
|
||||||
unsigned int count;
|
|
||||||
} HbTransformData;
|
|
||||||
|
|
||||||
void hbunloadfonts();
|
|
||||||
void hbtransform(HbTransformData *, XftFont *, const Glyph *, int, int);
|
|
||||||
void hbcleanup(HbTransformData *);
|
|
34
st.h
34
st.h
@ -11,8 +11,7 @@
|
|||||||
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
|
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
|
||||||
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
|
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
|
||||||
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
|
#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)) || \
|
#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
|
||||||
(a).fg != (b).fg || \
|
|
||||||
(a).bg != (b).bg)
|
(a).bg != (b).bg)
|
||||||
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
|
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
|
||||||
(t1.tv_nsec-t2.tv_nsec)/1E6)
|
(t1.tv_nsec-t2.tv_nsec)/1E6)
|
||||||
@ -23,20 +22,19 @@
|
|||||||
|
|
||||||
enum glyph_attribute {
|
enum glyph_attribute {
|
||||||
ATTR_NULL = 0,
|
ATTR_NULL = 0,
|
||||||
ATTR_SET = 1 << 0,
|
ATTR_BOLD = 1 << 0,
|
||||||
ATTR_BOLD = 1 << 1,
|
ATTR_FAINT = 1 << 1,
|
||||||
ATTR_FAINT = 1 << 2,
|
ATTR_ITALIC = 1 << 2,
|
||||||
ATTR_ITALIC = 1 << 3,
|
ATTR_UNDERLINE = 1 << 3,
|
||||||
ATTR_UNDERLINE = 1 << 4,
|
ATTR_BLINK = 1 << 4,
|
||||||
ATTR_BLINK = 1 << 5,
|
ATTR_REVERSE = 1 << 5,
|
||||||
ATTR_REVERSE = 1 << 6,
|
ATTR_INVISIBLE = 1 << 6,
|
||||||
ATTR_INVISIBLE = 1 << 7,
|
ATTR_STRUCK = 1 << 7,
|
||||||
ATTR_STRUCK = 1 << 8,
|
ATTR_WRAP = 1 << 8,
|
||||||
ATTR_WRAP = 1 << 9,
|
ATTR_WIDE = 1 << 9,
|
||||||
ATTR_WIDE = 1 << 10,
|
ATTR_WDUMMY = 1 << 10,
|
||||||
ATTR_WDUMMY = 1 << 11,
|
|
||||||
ATTR_SELECTED = 1 << 12,
|
|
||||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||||
|
ATTR_DIRTYUNDERLINE = 1 << 15,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum selection_mode {
|
enum selection_mode {
|
||||||
@ -68,6 +66,8 @@ typedef struct {
|
|||||||
ushort mode; /* attribute flags */
|
ushort mode; /* attribute flags */
|
||||||
uint32_t fg; /* foreground */
|
uint32_t fg; /* foreground */
|
||||||
uint32_t bg; /* background */
|
uint32_t bg; /* background */
|
||||||
|
int ustyle; /* underline style */
|
||||||
|
int ucolor[3]; /* underline color */
|
||||||
} Glyph;
|
} Glyph;
|
||||||
|
|
||||||
typedef Glyph *Line;
|
typedef Glyph *Line;
|
||||||
@ -84,8 +84,6 @@ void die(const char *, ...);
|
|||||||
void redraw(void);
|
void redraw(void);
|
||||||
void draw(void);
|
void draw(void);
|
||||||
|
|
||||||
void kscrolldown(const Arg *);
|
|
||||||
void kscrollup(const Arg *);
|
|
||||||
void printscreen(const Arg *);
|
void printscreen(const Arg *);
|
||||||
void printsel(const Arg *);
|
void printsel(const Arg *);
|
||||||
void sendbreak(const Arg *);
|
void sendbreak(const Arg *);
|
||||||
@ -93,7 +91,6 @@ void toggleprinter(const Arg *);
|
|||||||
|
|
||||||
int tattrset(int);
|
int tattrset(int);
|
||||||
void tnew(int, int);
|
void tnew(int, int);
|
||||||
int tisaltscreen(void);
|
|
||||||
void tresize(int, int);
|
void tresize(int, int);
|
||||||
void tsetdirtattr(int);
|
void tsetdirtattr(int);
|
||||||
void ttyhangup(void);
|
void ttyhangup(void);
|
||||||
@ -130,3 +127,4 @@ extern unsigned int tabspaces;
|
|||||||
extern unsigned int defaultfg;
|
extern unsigned int defaultfg;
|
||||||
extern unsigned int defaultbg;
|
extern unsigned int defaultbg;
|
||||||
extern unsigned int defaultcs;
|
extern unsigned int defaultcs;
|
||||||
|
extern float alpha;
|
||||||
|
2
st.info
2
st.info
@ -1,4 +1,5 @@
|
|||||||
st-mono| simpleterm monocolor,
|
st-mono| simpleterm monocolor,
|
||||||
|
Su,
|
||||||
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
||||||
am,
|
am,
|
||||||
bce,
|
bce,
|
||||||
@ -191,6 +192,7 @@ st-mono| simpleterm monocolor,
|
|||||||
Ms=\E]52;%p1%s;%p2%s\007,
|
Ms=\E]52;%p1%s;%p2%s\007,
|
||||||
Se=\E[2 q,
|
Se=\E[2 q,
|
||||||
Ss=\E[%p1%d q,
|
Ss=\E[%p1%d q,
|
||||||
|
Sync=\EP=%p1%ds\E\\,
|
||||||
|
|
||||||
st| simpleterm,
|
st| simpleterm,
|
||||||
use=st-mono,
|
use=st-mono,
|
||||||
|
2
win.h
2
win.h
@ -25,7 +25,7 @@ enum win_mode {
|
|||||||
|
|
||||||
void xbell(void);
|
void xbell(void);
|
||||||
void xclipcopy(void);
|
void xclipcopy(void);
|
||||||
void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int);
|
void xdrawcursor(int, int, Glyph, int, int, Glyph);
|
||||||
void xdrawline(Line, int, int, int);
|
void xdrawline(Line, int, int, int);
|
||||||
void xfinishdraw(void);
|
void xfinishdraw(void);
|
||||||
void xloadcols(void);
|
void xloadcols(void);
|
||||||
|
Reference in New Issue
Block a user