diff --git a/Makefile b/Makefile index 13f3e91..0dcafb1 100644 --- a/Makefile +++ b/Makefile @@ -15,18 +15,15 @@ options: @echo "LDFLAGS = $(STLDFLAGS)" @echo "CC = $(CC)" -config.h: - cp config.def.h config.h - .c.o: $(CC) $(STCFLAGS) -c $< -st.o: config.h st.h win.h -x.o: arg.h config.h st.h win.h hb.h +st.o: options.h st.h win.h +x.o: arg.h options.h st.h win.h hb.h hb.o: st.h -boxdraw.o: config.h st.h boxdraw_data.h +boxdraw.o: options.h st.h boxdraw_data.h -$(OBJ): config.h config.mk +$(OBJ): options.h config.mk st: $(OBJ) $(CC) -o $@ $(OBJ) $(STLDFLAGS) @@ -35,31 +32,28 @@ clean: rm -f st $(OBJ) st-$(VERSION).tar.gz dist: clean - mkdir -p st-$(VERSION) - cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\ - config.def.h st.info st.1 arg.h st.h win.h st.png st.desktop $(SRC)\ - st-$(VERSION) - tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz - rm -rf st-$(VERSION) + mkdir -p st-spde-$(VERSION) + cp -R LICENSE Makefile *.mk *.info *.h *.png *.desktop *.ttf $(SRC)\ + st-spde-$(VERSION) + tar -cf - st-spde-$(VERSION) | gzip > st-spde-$(VERSION).tar.gz + rm -rf st-spde-$(VERSION) install: st mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f st $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/st - mkdir -p $(DESTDIR)$(MANPREFIX)/man1 - sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1 - chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1 tic -sx st.info @echo Please see the README file regarding the terminfo entry of st. mkdir -p $(DESTDIR)$(ICONPREFIX) [ -f $(ICONNAME) ] && cp -f $(ICONNAME) $(DESTDIR)$(ICONPREFIX) || : mkdir -p $(DESTDIR)$(APPPREFIX) cp -f st.desktop $(DESTDIR)$(APPPREFIX) + rm -f ./st + rm -f *.o uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/st rm -f $(DESTDIR)$(APPPREFIX)/st.desktop - rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1 rm -f $(DESTDIR)$(ICONPREFIX)/$(ICONNAME) .PHONY: all options clean dist install uninstall diff --git a/config.def.h b/array.h similarity index 82% rename from config.def.h rename to array.h index 7f89ece..967012f 100644 --- a/config.def.h +++ b/array.h @@ -1,388 +1,5 @@ -/* See LICENSE file for copyright and license details. */ - -/* - * appearance - * - * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html - */ -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; -static char *font2[] = { - "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", - "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", -}; - -static int borderpx = 2; - -/* - * What program is execed by st depends of these precedence rules: - * 1: program passed with -e - * 2: scroll and/or utmp - * 3: SHELL environment variable - * 4: value of shell in /etc/passwd - * 5: value of shell in config.h - */ -static char *shell = "/bin/sh"; -char *utmp = NULL; -/* scroll program: to enable use a string like "scroll" */ -char *scroll = NULL; -char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400"; - -/* identification sequence returned in DA and DECID */ -char *vtiden = "\033[?6c"; - -/* Kerning / character bounding-box multipliers */ -static float cwscale = 1.0; -static float chscale = 1.0; - -/* - * word delimiter string - * - * More advanced example: L" `'\"()[]{}" - */ -wchar_t *worddelimiters = L" "; - -/* selection timeouts (in milliseconds) */ -static unsigned int doubleclicktimeout = 300; -static unsigned int tripleclicktimeout = 600; - -/* alt screens */ -int allowaltscreen = 1; - -/* allow certain non-interactive (insecure) window operations such as: - setting the clipboard text */ -int allowwindowops = 0; - -/* - * draw latency range in ms - from new content/keypress/etc until drawing. - * within this range, st draws when content stops arriving (idle). mostly it's - * near minlatency, but it waits longer for slow updates to avoid partial draw. - * low minlatency will tear/flicker more, as it can "detect" idle too early. - */ -static double minlatency = 8; -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 - * attribute. - */ -static unsigned int blinktimeout = 800; - -/* - * thickness of underline and bar cursors - */ -static unsigned int cursorthickness = 2; - -/* - * 1: render most of the lines/blocks characters without using the font for - * perfect alignment between cells (U2500 - U259F except dashes/diagonals). - * Bold affects lines thickness if boxdraw_bold is not 0. Italic is ignored. - * 0: disable (render all U25XX glyphs normally from the font). - */ -const int boxdraw = 1; -const int boxdraw_bold = 0; - -/* braille (U28XX): 1: render as adjacent "pixels", 0: use font */ -const int boxdraw_braille = 0; - -/* - * bell volume. It must be a value between -100 and 100. Use 0 for disabling - * it - */ -static int bellvolume = 0; - -/* default TERM value */ -char *termname = "xterm-256color"; - -/* - * spaces per tab - * - * When you are changing this value, don't forget to adapt the »it« value in - * the st.info and appropriately install the st.info in the environment where - * you use this st version. - * - * it#$tabspaces, - * - * Secondly make sure your kernel is not expanding tabs. When running `stty - * -a` »tab0« should appear. You can tell the terminal to not expand tabs by - * running following command: - * - * stty tabs - */ -unsigned int tabspaces = 8; - -/* bg opacity */ -float alpha = 0.8; - -/* Terminal colors (16 first used in escape sequence) */ -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "gray90", /* default foreground colour */ - "black", /* default background colour */ -}; - - -/* - * Default colors (colorname index) - * foreground, background, cursor, reverse cursor - */ -unsigned int defaultfg = 258; -unsigned int defaultbg = 259; -unsigned int defaultcs = 256; -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 - * Default style of cursor - * 0: blinking block - * 1: blinking block (default) - * 2: steady block ("█") - * 3: blinking underline - * 4: steady underline ("_") - * 5: blinking bar - * 6: steady bar ("|") - * 7: blinking st cursor - * 8: steady st cursor - */ -static unsigned int cursorstyle = 1; -static Rune stcursor = 0x2603; /* snowman ("☃") */ - -/* - * Default columns and rows numbers - */ - -static unsigned int cols = 80; -static unsigned int rows = 24; - -/* - * Default colour and shape of the mouse cursor - */ -static unsigned int mouseshape = XC_xterm; -static unsigned int mousefg = 7; -static unsigned int mousebg = 0; - -/* - * Color used to display font attributes when fontconfig selected a font which - * doesn't match the ones requested. - */ -static unsigned int defaultattr = 11; - -/* - * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set). - * Note that if you want to use ShiftMask with selmasks, set this to an other - * modifier, set to 0 to not use it. - */ -static uint forcemousemod = ShiftMask; - -/* - * Xresources preferences to load at startup - */ -ResourcePref resources[] = { - { "font", STRING, &font }, - { "color0", STRING, &colorname[0] }, - { "color1", STRING, &colorname[1] }, - { "color2", STRING, &colorname[2] }, - { "color3", STRING, &colorname[3] }, - { "color4", STRING, &colorname[4] }, - { "color5", STRING, &colorname[5] }, - { "color6", STRING, &colorname[6] }, - { "color7", STRING, &colorname[7] }, - { "color8", STRING, &colorname[8] }, - { "color9", STRING, &colorname[9] }, - { "color10", STRING, &colorname[10] }, - { "color11", STRING, &colorname[11] }, - { "color12", STRING, &colorname[12] }, - { "color13", STRING, &colorname[13] }, - { "color14", STRING, &colorname[14] }, - { "color15", STRING, &colorname[15] }, - { "background", STRING, &colorname[256] }, - { "foreground", STRING, &colorname[257] }, - { "cursorColor", STRING, &colorname[258] }, - { "termname", STRING, &termname }, - { "shell", STRING, &shell }, - { "minlatency", INTEGER, &minlatency }, - { "maxlatency", INTEGER, &maxlatency }, - { "blinktimeout", INTEGER, &blinktimeout }, - { "bellvolume", INTEGER, &bellvolume }, - { "tabspaces", INTEGER, &tabspaces }, - { "borderpx", INTEGER, &borderpx }, - { "cwscale", FLOAT, &cwscale }, - { "chscale", FLOAT, &chscale }, -}; - -/* - * Internal mouse shortcuts. - * Beware that overloading Button1 will disable the selection. - */ -static MouseShortcut mshortcuts[] = { - /* mask button function argument release */ - { XK_NO_MOD, Button4, kscrollup, {.i = 1} }, - { XK_NO_MOD, Button5, kscrolldown, {.i = 1} }, - { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, - { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, - { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, - { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, - { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} }, -}; - -/* Internal keyboard shortcuts. */ -#define MODKEY Mod1Mask -#define TERMMOD (ControlMask|ShiftMask) - -static Shortcut shortcuts[] = { - /* mask keysym function argument */ - { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, - { ControlMask, XK_Print, toggleprinter, {.i = 0} }, - { ShiftMask, XK_Print, printscreen, {.i = 0} }, - { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, - { ControlMask, XK_equal, zoom, {.f = +1} }, - { ControlMask, XK_minus, zoom, {.f = -1} }, - { ControlMask, XK_0, zoomreset, {.f = 0} }, - { ControlMask, XK_y, clipcopy, {.i = 0} }, - { ControlMask, XK_p, clippaste, {.i = 0} }, - { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, - { ControlMask, XK_k, kscrollup, {.i = +1} }, - { ControlMask, XK_j, kscrolldown, {.i = +1} }, -}; - -/* - * Special keys (change & recompile st.info accordingly) - * - * Mask value: - * * Use XK_ANY_MOD to match the key no matter modifiers state - * * Use XK_NO_MOD to match the key alone (no modifiers) - * appkey value: - * * 0: no value - * * > 0: keypad application mode enabled - * * = 2: term.numlock = 1 - * * < 0: keypad application mode disabled - * appcursor value: - * * 0: no value - * * > 0: cursor application mode enabled - * * < 0: cursor application mode disabled - * - * Be careful with the order of the definitions because st searches in - * this table sequentially, so any XK_ANY_MOD must be in the last - * position for a key. - */ - -/* - * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF) - * to be mapped below, add them to this array. - */ -static KeySym mappedkeys[] = { - XK_space, - XK_m, - XK_i, - XK_A, - XK_B, - XK_C, - XK_D, - XK_E, - XK_F, - XK_G, - XK_H, - XK_I, - XK_K, - XK_J, - XK_L, - XK_M, - XK_N, - XK_O, - XK_P, - XK_Q, - XK_R, - XK_S, - XK_T, - XK_U, - XK_V, - XK_W, - XK_X, - XK_Y, - XK_Z, - XK_Z, - XK_0, - XK_1, - XK_2, - XK_3, - XK_4, - XK_5, - XK_6, - XK_7, - XK_8, - XK_9, - XK_exclam, - XK_quotedbl, - XK_numbersign, - XK_dollar, - XK_percent, - XK_ampersand, - XK_apostrophe, - XK_parenleft, - XK_parenright, - XK_asterisk, - XK_plus, - XK_comma, - XK_minus, - XK_period, - XK_slash, - XK_colon, - XK_semicolon, - XK_less, - XK_equal, - XK_greater, - XK_question, - XK_at, - XK_bracketleft, - XK_backslash, - XK_bracketright, - XK_asciicircum, - XK_underscore, - XK_grave, - XK_braceleft, - XK_bar, - XK_braceright, - XK_asciitilde, -}; - -/* - * State bits to ignore when matching key or button events. By default, - * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored. - */ -static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; - -/* - * This is the huge key array which defines all compatibility to the Linux - * world. Please decide about changes wisely. + /* This is the huge key array which defines all compatibility to the GNU/Linux + * world. Please decide about changes wisely. */ static Key key[] = { /* keysym mask string appkey appcursor */ @@ -872,8 +489,8 @@ static Key key[] = { { XK_space, Mod1Mask, "\033[32;3u", 0, 0}, { XK_space, Mod1Mask|ControlMask, "\033[32;7u", 0, 0}, { XK_space, Mod1Mask|ControlMask|ShiftMask, "\033[32;8u", 0, 0}, - { XK_space, Mod1Mask|ShiftMask, "\033[32;4u", 0, 0}, - { XK_space, ShiftMask, "\033[32;2u", 0, 0}, + //{ XK_space, Mod1Mask|ShiftMask, "\033[32;4u", 0, 0}, + //{ XK_space, ShiftMask, "\033[32;2u", 0, 0}, { XK_0, ControlMask, "\033[48;5u", 0, 0}, { XK_A, ControlMask|ShiftMask, "\033[65;6u", 0, 0}, { XK_B, ControlMask|ShiftMask, "\033[66;6u", 0, 0}, @@ -1114,26 +731,3 @@ static Key key[] = { { XK_underscore, Mod1Mask|ControlMask|ShiftMask, "\033[95;8u", 0, 0}, { XK_underscore, Mod1Mask|ShiftMask, "\033[95;4u", 0, 0}, }; - -/* - * Selection types' masks. - * Use the same masks as usual. - * Button1Mask is always unset, to make masks match between ButtonPress. - * ButtonRelease and MotionNotify. - * If no match is found, regular selection is used. - */ -static uint selmasks[] = { - [SEL_RECTANGULAR] = Mod1Mask, -}; - -/* - * Printable characters in ASCII, used to estimate the advance width - * of single wide characters. - */ -static char ascii_printable[] = - " !\"#$%&'()*+,-./0123456789:;<=>?" - "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" - "`abcdefghijklmnopqrstuvwxyz{|}~"; - -/* URL Opener */ -static char *url_opener = "xdg-open"; diff --git a/char.h b/char.h new file mode 100644 index 0000000..743e5b0 --- /dev/null +++ b/char.h @@ -0,0 +1,15 @@ +/* This header contains options most people probably don't want to change + * + * It is therefore hidden to keep the configuration file easy and clean to read. + */ +char *utmp = NULL; +char *scroll = NULL; +char *vtiden = "\033[?6c"; +/* More advanced example: L" `'\"()[]{}" */ +wchar_t *worddelimiters = L" "; +static uint selmasks[] = { [SEL_RECTANGULAR] = Mod1Mask }; +static char ascii_printable[] = { + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~" +}; diff --git a/docs/bindlist b/docs/bindlist new file mode 100644 index 0000000..bcc4e0b --- /dev/null +++ b/docs/bindlist @@ -0,0 +1 @@ +bind list, not complete yet. diff --git a/docs/example.Xresources b/docs/example.Xresources new file mode 100644 index 0000000..b3c465f --- /dev/null +++ b/docs/example.Xresources @@ -0,0 +1,7 @@ +! This is an example .Xresources file for speedie.gq's build of st. +! +! Copy the values here to your .Xresources file by running: +! 'cat example.Xresources >> ~/.Xresources # This assumes your .Xresources is in $HOME and you're in the docs directory.' +! +! Then to load these values, add 'xrdb /path/to/.Xresources' to a script which autostarts. +! If you use Pywal then this will already be done for you. diff --git a/docs/patchlist b/docs/patchlist new file mode 100644 index 0000000..1f40960 --- /dev/null +++ b/docs/patchlist @@ -0,0 +1 @@ +patchlist, not complete yet diff --git a/font.ttf b/font.ttf new file mode 100644 index 0000000..3a6261a Binary files /dev/null and b/font.ttf differ diff --git a/keybinds.h b/keybinds.h new file mode 100644 index 0000000..f817ad9 --- /dev/null +++ b/keybinds.h @@ -0,0 +1,19 @@ +/* This header file contains the keybinds available to the user. + * This is not a complete list, the rest can be changed in array.h and mouse.h respectively. + */ + +static Shortcut shortcuts[] = { + /* mask keysym function argument */ + { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, + { ControlMask, XK_Print, toggleprinter, {.i = 0} }, + { ShiftMask, XK_Print, printscreen, {.i = 0} }, + { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, + { ControlMask, XK_equal, zoom, {.f = +1} }, + { ControlMask, XK_minus, zoom, {.f = -1} }, + { ControlMask, XK_0, zoomreset, {.f = 0} }, + { ControlMask, XK_y, clipcopy, {.i = 0} }, + { ControlMask, XK_p, clippaste, {.i = 0} }, + { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + { ControlMask, XK_k, kscrollup, {.i = +1} }, + { ControlMask, XK_j, kscrolldown, {.i = +1} }, +}; diff --git a/mapped.h b/mapped.h new file mode 100644 index 0000000..25dcfe9 --- /dev/null +++ b/mapped.h @@ -0,0 +1,78 @@ +/* + * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF) + * to be mapped below, add them to this array. + */ +static KeySym mappedkeys[] = { + XK_space, + XK_m, + XK_i, + XK_A, + XK_B, + XK_C, + XK_D, + XK_E, + XK_F, + XK_G, + XK_H, + XK_I, + XK_K, + XK_J, + XK_L, + XK_M, + XK_N, + XK_O, + XK_P, + XK_Q, + XK_R, + XK_S, + XK_T, + XK_U, + XK_V, + XK_W, + XK_X, + XK_Y, + XK_Z, + XK_Z, + XK_0, + XK_1, + XK_2, + XK_3, + XK_4, + XK_5, + XK_6, + XK_7, + XK_8, + XK_9, + XK_exclam, + XK_quotedbl, + XK_numbersign, + XK_dollar, + XK_percent, + XK_ampersand, + XK_apostrophe, + XK_parenleft, + XK_parenright, + XK_asterisk, + XK_plus, + XK_comma, + XK_minus, + XK_period, + XK_slash, + XK_colon, + XK_semicolon, + XK_less, + XK_equal, + XK_greater, + XK_question, + XK_at, + XK_bracketleft, + XK_backslash, + XK_bracketright, + XK_asciicircum, + XK_underscore, + XK_grave, + XK_braceleft, + XK_bar, + XK_braceright, + XK_asciitilde, +}; diff --git a/mouse.h b/mouse.h new file mode 100644 index 0000000..1574ee8 --- /dev/null +++ b/mouse.h @@ -0,0 +1,19 @@ +/* This header file is for Mouse keybinds. + * + * Make sure you don't overload Button1 (Left click). + * + * Mouse1 | Left Click + * Mouse2 | Middle Click + */ + +static MouseShortcut mshortcuts[] = { + /* mask button function argument release */ + { XK_NO_MOD, Button4, kscrollup, {.i = 1} }, + { XK_NO_MOD, Button5, kscrolldown, {.i = 1} }, + { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, + { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, + { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, + { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, + { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} }, +}; + diff --git a/options.h b/options.h new file mode 100644 index 0000000..17583a3 --- /dev/null +++ b/options.h @@ -0,0 +1,216 @@ +/* speedie.gq's build of suckless.org's simple terminal (st). + * + * This is a fork of suckless's st, a minimal in design, just works terminal emulator that by default does nothing more. + * Note that this terminal has a list of fonts (See 'Font options') that must be changed before installing. + * + * Additionally, if you use OpenBSD or FreeBSD, you must edit 'config.mk'. + * If you use GNU/Linux, you should be able to recompile st. + * + * To find out what to enter in the font and font2 chars, run 'fc-list | grep '. + */ + +/* Options + * + * This configuration file (options.h) contains the many options you can change about this terminal. + * It is configured in C syntax and needs to be recompiled after a change has been made. + * + * You can also configure st using .Xresources. + * In order to do this, create a .Xresources file somewhere. + * + * If you prefer, you can copy 'docs/example.Xresources' somewhere and add 'xrdb /path/to/.Xresources' to a script that auto starts such as .xinitrc. + * If you use Pywal, it should "just work" out of the box without any additional configuration necessary. + * + * Recompiling is done by running the command 'make clean install' when in the source code directory. + * + * If recompiling fails, check config.mk. + */ + +/* Modifier key options */ +#define MODKEY Mod1Mask +#define TERMMOD (ControlMask|ShiftMask) + +static uint forcemousemod = ShiftMask; /* Force mouse select/shortcuts while mask is active when MODE_MOUSE is set. */ +static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; + +/* Font options + */ +static char *font = "DejaVuSansMonoForPowerline Nerd Font:style=Book:antialias=true:autohint=true"; /* Main font to use */ +/* This font should be bundled with st. Install it manually or with fontctrl (available here: https://codeberg.org/speedie/fontctrl) + * If it is not available, you may need to 'fontctrl install --global'. + */ + +/* Secondary fonts + * + * These will be picked if the *font does not exist, or doesn't contain the glyphs necessary. + * You can add multiple fonts if you wish. + * + * For best compatibility, have one Emoji font, one regular font, one Powerline font and one Nerd font. + * If you don't need these, you can of course omit them. + */ +static char *font2[] = { "DejaVu Sans Mono:pixelsize=12:antialias=true:autohint=true", + "Noto Emoji:pixelsize=12:antialias=true:autohint=true", + "JoyPixels:pixelsize=12:antialias=true:autohint=true", + "fontawesome:pixelsize=12:antialias=true:autohint=true", +}; + +/* Appearance + * + * This is where most appearance related options can be found and changed. + */ + +/* Window options */ +static int borderpx = 0; /* Size of a small border around the text. */ +int allowaltscreen = 1; /* Allow alt screen (1) */ +int allowwindowops = 0; /* Allow (insecure) window operations such as setting the clipboard text */ + +/* Cursor options */ + +/* List of cursor styles: + * + * 0: blinking block + * 1: blinking block (default) + * 2: steady block ("█") + * 3: blinking underline + * 4: steady underline ("_") + * 5: blinking bar + * 6: steady bar ("|") + * 7: blinking st cursor + * 8: steady st cursor + */ +static Rune stcursor = 0x2603; /* snowman ("☃") */ +static unsigned int cursorstyle = 1; +static unsigned int mouseshape = XC_xterm; /* Shape of the mouse cursor */ +static unsigned int mousefg = 7; +static unsigned int mousebg = 0; +static unsigned int blinktimeout = 800; /* Blink timeout for the cursor in milliseconds */ +static unsigned int cursorthickness = 2; /* Thickness of the cursor in pixels. */ +static unsigned int dctimeout = 300; /* Double click timeout in milliseconds */ +static unsigned int tctimeout = 600; /* Triple click timeout in milliseconds */ +static unsigned int defaultattr = 11; + +/* Text rendering options */ +static float cwscale = 1.0; +static float chscale = 1.0; +static double minlatency = 8; /* Minimum draw latency in milliseconds */ +static double maxlatency = 33; /* Max draw latency in milliseconds */ +static uint su_timeout = 200; /* Synchronized timeout in milliseconds */ + +/* URL options + * + * This build of st allows you to click on links with your mouse. + * These will then be opened in whatever you define below. + * + * This could be a web browser or a clipboard if you prefer to copy the link. + * + * 'xdg-open' is the default but this could be set to 'firefox' or 'chrome'. + */ +static char *url_opener = "xdg-open"; + +/* Color options */ +static const char *colorname[] = { + /* Normal colors */ + "#5c5c5c", /* black */ + "#e57373", /* red3 */ + "#02982e", /* green3 */ + "#fac863", /* yellow3 */ + "#6699cc", /* blue2 */ + "#a36ac7", /* magenta3 */ + "#5fb3b3", /* cyan3 */ + "#c0c5ce", /* gray90 */ + + /* Bright colors */ + "#00ffaa", /* gray50 */ + "#e57373", /* red */ + "#a6bc69", /* green */ + "#fac863", /* yellow */ + "#6699cc", /* #5c5cff */ + "#c594c5", /* magenta */ + "#5fb3b3", /* cyan */ + "#ffffff", /* white */ + [255] = 0, + "#cccccc", + "#555555", + "#c0c5ce", + "#696969", +}; + +/* Default foreground/background colors */ +unsigned int defaultfg = 258; /* Default foreground (text) color */ +unsigned int defaultbg = 232; /* Default background (bg) color */ +unsigned int defaultcs = 256; +static unsigned int defaultrcs = 257; + +/* Alpha options */ +float alpha = 0.8; /* Background opacity (0 is transparent, 1 is opaque, 0.8 is default) */ + +/* Boxdraw options + * + * 1: render most of the lines/blocks characters without using the font for + * perfect alignment between cells (U2500 - U259F except dashes/diagonals). + * Bold affects lines thickness if boxdraw_bold is not 0. Italic is ignored. + * 0: disable (render all U25XX glyphs normally from the font). + * + * Boxdraw can cause some compatibility issues so do not enable this unless you want to use it. + */ +const int boxdraw = 0; /* Enable (1) or disable boxdraw (0) */ +const int boxdraw_bold = 0; /* Enable (1) or disable bold boxdraw (0) */ +const int boxdraw_braille = 0; /* Render as adjacent "pixels" (1) or use the fonts (0) */ + +/* Undercurl options + * + * Undercurl allows your terminal and TUI software to draw undercurl instead of an underline. + * This looks nice to a lot of people. + * + * Curly: + * _ _ _ _ + * ( ) ( ) ( ) ( ) + * (_) (_) (_) (_) + * + * To use Curly: + * Set undercurl to 1 + * + * Spiky: + * /\ /\ /\ /\ + * \/ \/ \/ + * + * To use Spiky: + * Set undercurl to 2 + * + * Capped: + * _ _ _ + * / \ / \ / \ + * \_/ \_/ + * + * To use Capped: + * Set undercurl to 3 + * + * To use the default (underline), set undercurl to 0. + */ + +static char *understyle = "1"; /* Undercurl style to use */ + +/* Default column and row options */ +static unsigned int cols = 80; /* Number of columns to have by default */ +static unsigned int rows = 24; /* Number of rows to have by default */ + +/* Bell options */ +static int bellvolume = 0; /* Bell volume. It must be a value between -100 and 100. 0 will disable it. */ + +/* Shell options + * + * This is where most options related to the Shell can be found and changed. + */ +static char *shell = "/bin/sh"; +char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400"; + +/* $TERM options + * Some software uses the TERM export variable to determine what features the terminal supports. + * 'st-256color' is the default and will work for most but if you're having compatibility issues + * try setting it to 'xterm-256color'. + * + * You can also set it to 'st-mono' if you want to disable colors completely. + */ +char *termname = "st-256color"; /* $TERM value */ + +/* Tab space options */ +unsigned int tabspaces = 8; diff --git a/st b/st deleted file mode 100755 index 671c191..0000000 Binary files a/st and /dev/null differ diff --git a/st.1 b/st.1 deleted file mode 100644 index 39120b4..0000000 --- a/st.1 +++ /dev/null @@ -1,177 +0,0 @@ -.TH ST 1 st\-VERSION -.SH NAME -st \- simple terminal -.SH SYNOPSIS -.B st -.RB [ \-aiv ] -.RB [ \-c -.IR class ] -.RB [ \-f -.IR font ] -.RB [ \-g -.IR geometry ] -.RB [ \-n -.IR name ] -.RB [ \-o -.IR iofile ] -.RB [ \-T -.IR title ] -.RB [ \-t -.IR title ] -.RB [ \-l -.IR line ] -.RB [ \-w -.IR windowid ] -.RB [[ \-e ] -.IR command -.RI [ arguments ...]] -.PP -.B st -.RB [ \-aiv ] -.RB [ \-c -.IR class ] -.RB [ \-f -.IR font ] -.RB [ \-g -.IR geometry ] -.RB [ \-n -.IR name ] -.RB [ \-o -.IR iofile ] -.RB [ \-T -.IR title ] -.RB [ \-t -.IR title ] -.RB [ \-w -.IR windowid ] -.RB \-l -.IR line -.RI [ stty_args ...] -.SH DESCRIPTION -.B st -is a simple terminal emulator. -.SH OPTIONS -.TP -.B \-a -disable alternate screens in terminal -.TP -.BI \-c " class" -defines the window class (default $TERM). -.TP -.BI \-f " font" -defines the -.I font -to use when st is run. -.TP -.BI \-g " geometry" -defines the X11 geometry string. -The form is [=][{xX}][{+-}{+-}]. See -.BR XParseGeometry (3) -for further details. -.TP -.B \-i -will fixate the position given with the -g option. -.TP -.BI \-n " name" -defines the window instance name (default $TERM). -.TP -.BI \-o " iofile" -writes all the I/O to -.I iofile. -This feature is useful when recording st sessions. A value of "-" means -standard output. -.TP -.BI \-T " title" -defines the window title (default 'st'). -.TP -.BI \-t " title" -defines the window title (default 'st'). -.TP -.BI \-w " windowid" -embeds st within the window identified by -.I windowid -.TP -.BI \-l " line" -use a tty -.I line -instead of a pseudo terminal. -.I line -should be a (pseudo-)serial device (e.g. /dev/ttyS0 on Linux for serial port -0). -When this flag is given -remaining arguments are used as flags for -.BR stty(1). -By default st initializes the serial line to 8 bits, no parity, 1 stop bit -and a 38400 baud rate. The speed is set by appending it as last argument -(e.g. 'st -l /dev/ttyS0 115200'). Arguments before the last one are -.BR stty(1) -flags. If you want to set odd parity on 115200 baud use for example 'st -l -/dev/ttyS0 parenb parodd 115200'. Set the number of bits by using for -example 'st -l /dev/ttyS0 cs7 115200'. See -.BR stty(1) -for more arguments and cases. -.TP -.B \-v -prints version information to stderr, then exits. -.TP -.BI \-e " command " [ " arguments " "... ]" -st executes -.I command -instead of the shell. If this is used it -.B must be the last option -on the command line, as in xterm / rxvt. -This option is only intended for compatibility, -and all the remaining arguments are used as a command -even without it. -.SH SHORTCUTS -.TP -.B Break -Send a break in the serial line. -Break key is obtained in PC keyboards -pressing at the same time control and pause. -.TP -.B Ctrl-Print Screen -Toggle if st should print to the -.I iofile. -.TP -.B Shift-Print Screen -Print the full screen to the -.I iofile. -.TP -.B Print Screen -Print the selection to the -.I iofile. -.TP -.B Ctrl-Shift-Page Up -Increase font size. -.TP -.B Ctrl-Shift-Page Down -Decrease font size. -.TP -.B Ctrl-Shift-Home -Reset to default font size. -.TP -.B Ctrl-Shift-y -Paste from primary selection (middle mouse button). -.TP -.B Ctrl-Shift-c -Copy the selected text to the clipboard selection. -.TP -.B Ctrl-Shift-v -Paste from the clipboard selection. -.SH CUSTOMIZATION -.B st -can be customized by creating a custom config.h and (re)compiling the source -code. This keeps it fast, secure and simple. -.SH AUTHORS -See the LICENSE file for the authors. -.SH LICENSE -See the LICENSE file for the terms of redistribution. -.SH SEE ALSO -.BR tabbed (1), -.BR utmp (1), -.BR stty (1), -.BR scroll (1) -.SH BUGS -See the TODO file in the distribution. - diff --git a/st.info b/st.info index 7df13e8..2806591 100644 --- a/st.info +++ b/st.info @@ -162,7 +162,7 @@ st-mono| simpleterm monocolor, rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E(B, - rmcup=\E[?1049l, + rmcup=\E[?1049l\E[23;0;0t, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, @@ -204,6 +204,7 @@ st| simpleterm, sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, st-256color| simpleterm with 256 colors, + Su, use=st, ccc, colors#256, @@ -213,6 +214,8 @@ st-256color| simpleterm with 256 colors, initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m, + Smulx=\E[4:%p1%dm, + st-meta| simpleterm with meta key, use=st, diff --git a/x.c b/x.c index 92212b1..13b06eb 100644 --- a/x.c +++ b/x.c @@ -85,8 +85,18 @@ static void zoomabs(const Arg *); static void zoomreset(const Arg *); static void ttysend(const Arg *); -/* config.h for applying patches and the configuration. */ -#include "config.h" +/* define undercurl values to use later */ +#define UNDERCURL_CURLY 0 +#define UNDERCURL_SPIKY 1 +#define UNDERCURL_CAPPED 2 + +#include "options.h" /* include user configuration */ +#include "char.h" /* include misc chars */ +#include "keybinds.h" /* include keybinds */ +#include "mouse.h" /* include mouse binds */ +#include "mapped.h" /* include list of mapped keys */ +#include "xresources.h" /* include .xresources/xrdb options */ +#include "array.h" /* include key array */ /* XEMBED messages */ #define XEMBED_FOCUS_IN 4 @@ -520,9 +530,9 @@ bpress(XEvent *e) * snapping behaviour is exposed. */ clock_gettime(CLOCK_MONOTONIC, &now); - if (TIMEDIFF(now, xsel.tclick2) <= tripleclicktimeout) { + if (TIMEDIFF(now, xsel.tclick2) <= tctimeout) { snap = SNAP_LINE; - } else if (TIMEDIFF(now, xsel.tclick1) <= doubleclicktimeout) { + } else if (TIMEDIFF(now, xsel.tclick1) <= dctimeout) { snap = SNAP_WORD; } else { snap = 0; @@ -1631,6 +1641,20 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i XRenderColor colfg, colbg; XRectangle r; + /* + if (understyle = "1") { + #define UNDERCURL_STYLE UNDERCURL_CURLY + } + + if (understyle = "2") { + #define UNDERCURL_STYLE UNDERCURL_SPIKY + } + + if (understyle = "3") { + #define UNDERCURL_STYLE UNDERCURL_CAPPED + } + */ + /* Fallback on color display for attributes not supported by the font */ if (base.mode & ATTR_ITALIC && base.mode & ATTR_BOLD) { if (dc.ibfont.badslant || dc.ibfont.badweight) @@ -1799,7 +1823,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i int wx = winx; int wy = winy + win.ch - dc.font.descent; -#if UNDERCURL_STYLE == UNDERCURL_CURLY + if (understyle = "1") { // Draw waves int narcs = charlen * 2 + 1; XArc *arcs = xmalloc(sizeof(XArc) * narcs); @@ -1837,7 +1861,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i XDrawArcs(xw.dpy, XftDrawDrawable(xw.draw), ugc, arcs, narcs); free(arcs); -#elif UNDERCURL_STYLE == UNDERCURL_SPIKY + } else if (understyle = "2") { // Make the underline corridor larger /* wy -= wh; @@ -1937,7 +1961,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i // Free resources free(points); } -#else // UNDERCURL_CAPPED + } else if (understyle = "3") { // Cap is half of wave width float capRatio = 0.5f; @@ -2096,7 +2120,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i // Free resources free(points); } -#endif + } } XFreeGC(xw.dpy, ugc); diff --git a/xresources.h b/xresources.h new file mode 100644 index 0000000..7598b9e --- /dev/null +++ b/xresources.h @@ -0,0 +1,39 @@ +/* This header contains .Xresources/xrdb options that st can load and use. + * If available, these will be used instead of the compiled in options meaning you can change options without recompiling st. + * + * A full list of all options as well as an example .Xresources file can be found in 'docs/example.Xresources'. + */ + +ResourcePref resources[] = { + { "font", STRING, &font }, + { "color0", STRING, &colorname[0] }, + { "color1", STRING, &colorname[1] }, + { "color2", STRING, &colorname[2] }, + { "color3", STRING, &colorname[3] }, + { "color4", STRING, &colorname[4] }, + { "color5", STRING, &colorname[5] }, + { "color6", STRING, &colorname[6] }, + { "color7", STRING, &colorname[7] }, + { "color8", STRING, &colorname[8] }, + { "color9", STRING, &colorname[9] }, + { "color10", STRING, &colorname[10] }, + { "color11", STRING, &colorname[11] }, + { "color12", STRING, &colorname[12] }, + { "color13", STRING, &colorname[13] }, + { "color14", STRING, &colorname[14] }, + { "color15", STRING, &colorname[15] }, + { "background", STRING, &colorname[256] }, + { "foreground", STRING, &colorname[257] }, + { "cursorColor", STRING, &colorname[258] }, + { "termname", STRING, &termname }, + { "shell", STRING, &shell }, + { "minlatency", INTEGER, &minlatency }, + { "maxlatency", INTEGER, &maxlatency }, + { "blinktimeout", INTEGER, &blinktimeout }, + { "bellvolume", INTEGER, &bellvolume }, + { "tabspaces", INTEGER, &tabspaces }, + { "borderpx", INTEGER, &borderpx }, + { "cwscale", FLOAT, &cwscale }, + { "chscale", FLOAT, &chscale }, +}; +