Skip to content

Commit

Permalink
st-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Jidro.Z committed Mar 15, 2022
1 parent 189a301 commit 9f7bb9e
Show file tree
Hide file tree
Showing 28 changed files with 2,183 additions and 1,042 deletions.
57 changes: 57 additions & 0 deletions st/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

*.rej
*.orig
*.save
st
2 changes: 1 addition & 1 deletion st/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT/X Consortium License

© 2014-2020 Hiltjo Posthuma <hiltjo at codemadness dot org>
© 2014-2022 Hiltjo Posthuma <hiltjo at codemadness dot org>
© 2018 Devin J. Pohly <djpohly at gmail dot com>
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
Expand Down
8 changes: 5 additions & 3 deletions st/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ dist: clean
install: st
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f st $(DESTDIR)$(PREFIX)/bin
cp -f st-copyout $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-copyout
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)$(PREFIX)/share/applications
cp -f st.desktop $(DESTDIR)$(PREFIX)/share/applications
cp -f st.desktop /usr/share/applications

uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/st
rm -f $(DESTDIR)$(PREFIX)/bin/st-copyout
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
rm -f $(DESTDIR)$(PREFIX)/share/applications/st.desktop
rm -f /usr/share/applications/st.desktop

.PHONY: all options clean dist install uninstall
34 changes: 34 additions & 0 deletions st/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
st - simple terminal
--------------------
st is a simple terminal emulator for X which sucks less.


Requirements
------------
In order to build st you need the Xlib header files.


Installation
------------
Edit config.mk to match your local setup (st is installed into
the /usr/local namespace by default).

Afterwards enter the following command to build and install st (if
necessary as root):

make clean install


Running st
----------
If you did not install st with make clean install, you must compile
the st terminfo entry with the following command:

tic -sx st.info

See the man page for additional details.

Credits
-------
Based on Aurélien APTEL <aurelien dot aptel at gmail dot com> bt source code.

153 changes: 65 additions & 88 deletions st/config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "DejaVu Sans Mono:pixelsize=12:antialias=true:autohint=true";
/* Spare fonts */
static char *font2[] = {
/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */
/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */
};

static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static int borderpx = 2;

/*
Expand Down Expand Up @@ -100,47 +94,37 @@ char *termname = "st-256color";
unsigned int tabspaces = 8;

/* bg opacity */
float alpha = 0.8, alphaUnfocused = 0.6;
float alpha = 0.8;

/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
/* 8 normal colors */
[0] = "#282a2e", /* black */
[1] = "#b11717", /* red */
[2] = "#18b117", /* green */
[3] = "#ffc004", /* yellow */
[4] = "#1817b1", /* blue */
[5] = "#ec0047", /* magenta */
[6] = "#29a7e7", /* cyan */
[7] = "#f1f1f1", /* white */

/* 8 bright colors */
[8] = "#373b41", /* black */
[9] = "#ff5353", /* red */
[10] = "#00cd00", /* green */
[11] = "#f0c674", /* yellow */
[12] = "#1e90ff", /* blue */
[13] = "#6c71c4", /* magenta */
[14] = "#93a1a1", /* cyan */
[15] = "#c5c8c6", /* white */

/* special colors */
[256] = "#252525", /* background */
[257] = "#00ff00", /* foreground */

/* more colors can be added after 255 to use with DefaultXX */
/* "black", */
"#080808",
"gray90", /* default foreground colour */
"black", /* default background colour */
"#3d3d3d",
"#252525",
"#000000",
"#166413",
"#A9CBFF",
"#FCE4E3",
"#FAAD1A",

/* 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 */
};


Expand All @@ -151,28 +135,20 @@ static const char *colorname[] = {
unsigned int defaultfg = 258;
unsigned int defaultbg = 259;
unsigned int defaultcs = 256;
//static unsigned int defaultcs = 257;
static unsigned int defaultrcs = 257;
unsigned int bg = 17, bgUnfocused = 16;

/*
* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-charact$
* Colors used, when the specific fg == defaultfg. So in reverse mode this
* will reverse too. Another logic would only make the simple feature too
* complex.
*/
unsigned int defaultitalic = 7;
unsigned int defaultunderline = 7;

/*
* Default shape of cursor
* 2: Block ("█")
* 4: Underline ("_")
* 6: Bar ("|")
* 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: Snowman ("☃")
*/

static unsigned int cursorshape = 2;
*/
static unsigned int cursorstyle = 1;

/*
Expand Down Expand Up @@ -206,44 +182,45 @@ static uint forcemousemod = ShiftMask;
* Internal mouse shortcuts.
* Beware that overloading Button1 will disable the selection.
*/
const unsigned int mousescrollincrement = 1;
static MouseShortcut mshortcuts[] = {
/* mask button function argument release */
{ XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 },
{ XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -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"} },
{ ShiftMask, Button4, kscrollup, {.i = 1} },
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
};

/* Internal keyboard shortcuts. */
#define MODKEY Mod4Mask
#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} },
{ TERMMOD, XK_Prior, zoom, {.f = +1} },
{ TERMMOD, XK_Next, zoom, {.f = -1} },
{ TERMMOD, XK_Home, zoomreset, {.f = 0} },
{ 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_Page_Up, kscrollup, {.i = 1} },
{ ControlMask, XK_Page_Down, kscrolldown, {.i = 1} },
{ ControlMask|ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ControlMask|ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
{ MODKEY, XK_l, copyurl, {.i = 0} },
// from @LukeSmithxyz
static char *openurlcmd[] = { "/bin/sh", "-c",
"sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)'| uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -i -p 'Follow which url?' -l 10 | xargs -r xdg-open",
"externalpipe", NULL };
static char *copyurlcmd[] = { "/bin/sh", "-c",
"sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)' | uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard",
"externalpipe", NULL };
static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL };

static Shortcut shortcuts[] = {
/* mask keysym function argument */
{ Mod1Mask|ControlMask, XK_l, externalpipe, {.v = openurlcmd } },
{ Mod1Mask, XK_y, externalpipe, {.v = copyurlcmd } },
{ Mod1Mask, XK_o, externalpipe, {.v = copyoutput } },
{ 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} },
{ TERMMOD, XK_Prior, zoom, {.f = +1} },
{ TERMMOD, XK_Next, zoom, {.f = -1} },
{ TERMMOD, XK_Home, zoomreset, {.f = 0} },
{ 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} },
};

/*
Expand Down
Loading

0 comments on commit 9f7bb9e

Please sign in to comment.