Compare commits

...

491 Commits
0.5 ... master

Author SHA1 Message Date
Hiltjo Posthuma fa253f077f bump version to 0.8.4 2020-06-19 11:27:17 +02:00
Hiltjo Posthuma b27a383a3a config.mk: use PKG_CONFIG in commented OpenBSD section 2020-06-17 23:49:40 +02:00
Hiltjo Posthuma 81067c65ea LICENSE: bump years 2020-06-17 23:49:40 +02:00
Hiltjo Posthuma f74a9df6e1 remove sixel stub code
Remove stub code that was used for an experiment of adding sixel code to st
from the commit f7398434.
2020-06-17 23:49:22 +02:00
Hiltjo Posthuma 818ec746f4 fix unicode glitch in DCS strings, patch by Tim Allen
Reported on the mailinglist:

"
I discovered recently that if an application running inside st tries to
send a DCS string, subsequent Unicode characters get messed up. For
example, consider the following test-case:

    printf '\303\277\033P\033\\\303\277'

...where:

  - \303\277 is the UTF-8 encoding of U+00FF LATIN SMALL LETTER Y WITH
    DIAERESIS (ÿ).
  - \033P is ESC P, the token that begins a DCS string.
  - \033\\ is ESC \, a token that ends a DCS string.
  - \303\277 is the same ÿ character again.

If I run the above command in a VTE-based terminal, or xterm, or
QTerminal, or pterm (PuTTY), I get the output:

    ÿÿ

...which is to say, the empty DCS string is ignored. However, if I run
that command inside st (as of commit 9ba7ecf), I get:

    ÿÿ

...where those last two characters are \303\277 interpreted as ISO8859-1
characters, instead of UTF-8.

I spent some time tracing through the state machines in st.c, and so far
as I can tell, this is how it works currently:

  - ESC P sets the "ESC_DCS" and "ESC_STR" flags, indicating that
    incoming bytes should be collected into the strescseq buffer, rather
    than being interpreted.
  - ESC \ sets the "ESC_STR_END" flag (when ESC is received), and then
    calls strhandle() (when \ is received) to interpret the collected
    bytes.
  - If the collected bytes begin with 'P' (i.e. if this was a DCS
    string) strhandle() sets the "ESC_DCS" flag again, confusing the
    state machine.

If my understanding is correct, fixing the problem should be as easy as
removing the line that sets ESC_DCS from strhandle():

diff --git a/st.c b/st.c
index ef8abd5..b5b805a 100644
--- a/st.c
+++ b/st.c
@@ -1897,7 +1897,6 @@ strhandle(void)
		xsettitle(strescseq.args[0]);
		return;
	case 'P': /* DCS -- Device Control String */
-		term.mode |= ESC_DCS;
	case '_': /* APC -- Application Program Command */
	case '^': /* PM -- Privacy Message */
		return;

I've tried the above patch and it fixes my problem, but I don't know if
it introduces any others.
"
2020-06-17 21:35:39 +02:00
Hiltjo Posthuma 9ba7ecf7b1 FAQ: fix single-buffer patch
rebase against master
2020-06-01 14:09:46 +02:00
Hiltjo Posthuma a2a704492b config.def.h: add an option allowwindowops, by default off (secure)
Similar to the xterm AllowWindowOps option, this is an option to allow or
disallow certain (non-interactive) operations that can be insecure or
exploited.

NOTE: xsettitle() is not guarded by this because st does not support printing
the window title. Else this could be exploitable (arbitrary code execution).
Similar problems have been found in the past in other terminal emulators.

The sequence for base64-encoded clipboard copy is now guarded because it allows
a sequence written to the terminal to manipulate the clipboard of the running
user non-interactively, for example:

printf '\x1b]52;0;ZWNobyBoaQ0=\a'
2020-05-30 22:06:15 +02:00
Hiltjo Posthuma 0f8b40652b FAQ: add some details about the w3m img hack
... and an example patch to switch from double-buffering to a single buffer.
2020-05-30 22:05:17 +02:00
Hiltjo Posthuma e6e2c6199f tiny style fix 2020-05-30 22:05:17 +02:00
Hiltjo Posthuma 94b8ec0021 Partially add back in "support REP (repeat) escape sequence"
Add the functionality back in for xterm compatibility, but do not expose the
capability in st.info (yet).

Some notes:

It was reverted because it caused some issues with ncurses in some
configurations, namely when using BSD padding (--enable-bsdpad, BSD_TPUTS) in
ncurses it caused issues with repeating digits.

A fix has been upstreamed in ncurses since snapshot 20200523. The fix is also
backported to OpenBSD -current.
2020-05-30 22:04:28 +02:00
Steve Ward dec6b530a4 Call xsetcursor to set win.cursor in main
In xsetcursor, remove "DEFAULT(cursor, 1)" because 0 is a valid value.
Increase max allowed value of cursor from 6 to 7 (st extension).
2020-05-24 13:45:42 +02:00
Hiltjo Posthuma 475a0a36cb Revert "support REP (repeat) escape sequence"
This reverts commit e8392b282c.

There is currently a bug in older ncurses versions (like on OpenBSD) where a
fix for a bug with REP is not backported yet. Most likely in tty/tty_update.c:

Noticed while using lynx (which uses ncurses/curses).
To reproduce using lynx: echo "Z0000000" | lynx -stdin

or using the program:

int
main(void)
{
	WINDOW *win;
	win = initscr();

	printw("Z0000000");

	refresh();

	sleep(5);

	return 0;
}

This prints "ZZZZZZZ" (incorrectly).
2020-05-16 21:06:13 +02:00
Avi Halachmi (:avih) e8392b282c support REP (repeat) escape sequence
The sequence \e[Nb prints the last printed char N (more) times if it's
printable, and it's ignored after newline or other control chars.

This is Ecma-048/ANSI-X3.6 sequence and not DEC VT. It's supported by
xterm, and ncurses uses it when possible, e.g. when TERM is xterm* (and
with this commit also st*).

xterm supports only codepoints<=255, possibly due to internal limits.
We support any value/codepoint which was placed in a cell.

To test:
- tput rep 65 4 -> prints 'AAAA'
- printf "\342\225\246\033[4b" -> prints U+2566 1+4 times.
2020-05-16 14:08:10 +02:00
Roberto E. Vargas f8afebdfa0 Add rin terminfo capability
Tianlin Qu discovered that st is missing rin (scroll back #1 lines).
2020-05-16 14:07:31 +02:00
k0ga bda9c9ffa6 Make shift+wheel behaves as shift+Prev/Next
St uses a very good hack where mouse wheel genereates ^Y and ^E,
that are the same keys that less and vi uses for backward and
fordward scrolling. Scroll, as many terminal emulators, use
shift+Prev/Next for scrolling, but it is also using ^E and ^Y
for scroling, characters that are reserved in the POSIX shell
in emacs mode for end of line and yanking, making scroll unsable
in st.

This patch adds a new hack, making shift+wheel returning the
same sequences than shift+Prev/Next, meaning that scroll or
any other similar program will not be able to differentiate
between them.
2020-05-16 12:37:14 +02:00
Jakub Leszczak 045a0fab4f Fix selection: selscroll 2020-05-12 15:38:17 +02:00
Jakub Leszczak 9c30066e73 Fix selection: ignore ATTR_WRAP when rectangular selection in getsel 2020-05-12 15:38:02 +02:00
Jakub Leszczak 8304d4f059 Fix selection: selclear in tputc 2020-05-12 15:37:59 +02:00
Hiltjo Posthuma 914fb825df code-style: add fallthrough comment
Patch by Steve Ward, thanks.
2020-05-09 14:43:31 +02:00
Hiltjo Posthuma cde480c693 optimize column width calculation and utf-8 encode for ASCII
In particular on OpenBSD and on glibc wcwidth() is quite expensive.
On musl there is little difference.
2020-05-09 14:11:25 +02:00
Hiltjo Posthuma 8211e36d28 fix for incorrect (partial) written sequences when libc wcwidth() == -1
Fix an issue with incorrect (partial) written sequences when libc wcwidth() ==
-1. The sequence is updated to on wcwidth(u) == -1:

	c = "\357\277\275"

but len isn't.

A way to reproduce in practise:

* st -o dump.txt
* In the terminal: printf '\xcd\xb8'
- This is codepoint 888, on OpenBSD it reports wcwidth() == -1.
- Quit the terminal.
- Look in dump.txt (partial written sequence of "UTF_INVALID").

This was introduced in:

"	commit 11625c7166
	Author: czarkoff@gmail.com <czarkoff@gmail.com>
	Date:   Tue Oct 28 12:55:28 2014 +0100

	    Replace character with U+FFFD if wcwidth() is -1

	    Helpful when new Unicode codepoints are not recognized by libc."

Change:

Remove setting the sequence. If this happens to break something, another
solution could be setting len = 3 for the sequence.
2020-05-09 14:07:52 +02:00
Hiltjo Posthuma 87545c612e tiny code-style and typo-fix in comment 2020-05-09 14:05:04 +02:00
Avi Halachmi (:avih) 1d59091065 auto-sync: draw on idle to avoid flicker/tearing
st could easily tear/flicker with animation or other unattended
output. This commit eliminates most of the tear/flicker.

Before this commit, the display timing had two "modes":

- Interactively, st was waiting fixed `1000/xfps` ms after forwarding
  the kb/mouse event to the application and before drawing.

- Unattended, and specifically with animations, the draw frequency was
  throttled to `actionfps`. Animation at a higher rate would throttle
  and likely tear, and at lower rates it was tearing big frames
  (specifically, when one `read` didn't get a full "frame").

The interactive behavior was decent, but it was impossible to get good
unattended-draw behavior even with carefully chosen configuration.

This commit changes the behavior such that it draws on idle instead of
using fixed latency/frequency. This means that it tries to draw only
when it's very likely that the application has completed its output
(or after some duration without idle), so it mostly succeeds to avoid
tear, flicker, and partial drawing.

The config values minlatency/maxlatency replace xfps/actionfps and
define the range which the algorithm is allowed to wait from the
initial draw-trigger until the actual draw. The range enables the
flexibility to choose when to draw - when least likely to flicker.

It also unifies the interactive and unattended behavior and config
values, which makes the code simpler as well - without sacrificing
latency during interactive use, because typically interactively idle
arrives very quickly, so the wait is typically minlatency.

While it only slighly improves interactive behavior, for animations
and other unattended-drawing it improves greatly, as it effectively
adapts to any [animation] output rate without tearing, throttling,
redundant drawing, or unnecessary delays (sounds impossible, but it
works).
2020-05-09 13:53:50 +02:00
Jan Klemkow d6ea0a1a61 replace exit(3) by _exit(2) in signal handler sigchld()
exit(3) is not async-signal-safe but, _exit(2) is.
This change prevents st to crash and dump core.
2020-04-30 01:21:21 +02:00
Hiltjo Posthuma 43a395ae91 bump version to 0.8.3 2020-04-27 13:56:25 +02:00
Ivan Tham 72e3f6c7c0 Update XIM cursor position only if changed
Updating XIM cursor position is expensive, so only update it when cursor
position changed.
2020-04-19 19:39:48 +02:00
Hiltjo Posthuma 33a9a45664 just remove the EOF message 2020-04-11 15:45:06 +02:00
Roberto E. Vargas Caballero 771bc401f7 Add st-mono terminfo entry
This entry is intended for monocolor display and it is very
helpful for color haters.
2020-04-11 15:23:23 +02:00
Hiltjo Posthuma d66bd405c0 config.def.h: add a comment for the scroll variable 2020-04-11 15:23:23 +02:00
Hiltjo Posthuma e997303502 Fix small typos 2020-04-11 15:23:23 +02:00
Quentin Rameau c1145268f6 Launch scroll program with the default shell 2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero 0b73612c0d Update FAQ with the last modifications 2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero 019449a7e6 Add terminfo entries for backspace mode
St used to use backspace as BS until the commit 230d0c8, but due
to general lack of knowledge of lusers, we moved to the most common
configuration in linux to avoid answering the same question 3 times
per month. With the most common configuration we have a backspace
that returns a DEL, and we have a Delete key that doesn't return a
DEL character neither a BS.

When dealing with devices connected using a serial line (or even
with Plan9) it is more common Backspace as BS and Delete as DEL. For
this reason, st is not always the best tool when you talk with a
serial device.

This patch adds new terminfo entries for Backspace as BS and Delete
as DEL. A patch for confg.h is also added, to make easier switch
between both configurations.
2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero fbae700a3f Fix style issue 2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero e52319cc7d ttyread: test for EOF while reading tty
When a read operation returns 0 then it means that we arrived to the end of the
file, and new reads will return 0 unless you do some other operation such as
lseek(). This case happens with USB-232 adapters when they are unplugged.
2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero 21e0d6e8b8 Add support for scroll(1)
Scroll is a program that stores all the lines of its child and be used in st as
a way of implementing scrollback.

This solution is much better than implementing the scrollback in st itself
because having a different program allows to use it in any other program
without doing modifications to those programs.
2020-04-11 15:23:20 +02:00
Hiltjo Posthuma 5703aa0390 make argv0 not static, fixes a warning with tcc
Reported by Aajonus, thanks!
2020-04-10 12:12:43 +02:00
Avi Halachmi (:avih) 28ad288399 mouseshortcuts: fix custom modifier on release
This line didn't work at mshortcuts at config.h:

  /*  mask       button   function  arg       release */
    { ShiftMask, Button2, selpaste, {.i = 0}, 1 },

and now it does work.

The issue was that XButtonEvent.state is "the logical state ... just prior
to the event", which means that on release the state has the Button2Mask
bit set because button2 was down just before it was released.

The issue didn't manifest with the default shift + middle-click on release
(to override mouse mode) because its specified modifier is XK_ANY_MOD, at
which case match(...) ignores any specific bits and simply returns true.

The issue also doesn't manifest on press, because prior to the event
Button<N> was not down and its mask bit is not set.

Fix by filtering out the mask of the button which we're currently matching.

We could have said "well, that's how button events behave, you should
use ShiftMask|Button2Mask for release", but this both not obvious to
figure out, and specifically here always filtering does not prevent
configuring any useful modifiers combination. So it's a win-win.
2020-04-02 14:41:03 +02:00
Ivan Tham 51e19ea11d Remove explicit XNFocusWindow
XCreateIC ICValues default XNFocusWindow to XNClientWindow if not
specified, it can be omitted since it is the same.

From the documentation
https://www.x.org/releases/current/doc/libX11/libX11/libX11.html

> Focus Window
>
> The XNFocusWindow argument specifies the focus window. The primary
> purpose of the XNFocusWindow is to identify the window that will receive
> the key event when input is composed.
>
> When this XIC value is left unspecified, the input method will use the
> client window as the default focus window.
2020-02-19 00:46:20 +01:00
Quentin Rameau 26cdfebf31 x: fix XIM handling
Do not try to set specific IM method, let the user specify it with
XMODIFIERS.

If the requested method is not available or opening fails, fallback to
the default input handler and register a handler on the new IM server
availability signal.

Do the same when the input server is closed and (re)started.
2020-02-02 22:56:51 +01:00
Quentin Rameau cd785755f2 x: check we still have an XIC context before accessing it 2020-02-02 22:56:51 +01:00
Quentin Rameau 2cb539142b x: do not instantiate a new nested list on each cursor move 2020-02-02 22:56:51 +01:00
Quentin Rameau 99de333951 x: move IME variables into XWindow ime embedded struct 2020-02-02 22:56:51 +01:00
Ivan Tham 895e5b50a8 Increase XmbLookupString buffer
Current buffer is too short to input medium to long sentences from IME.
Input with longer text will show the wrong input, taking 64 instead of
32 bytes should be enough for most of the cases. Broken cases before,

Chinese (taken from song 也可以)
可不可以轻轻的松开自己

Japanese (taken from bootleggers rom quote)
あなたは家のように感じる
2020-01-18 14:21:50 +01:00
Hiltjo Posthuma 384830110b update FAQ
- add common question about the w3m image drawing hack.
- remove some bad advise about $TERM.
- change some links to https.
2019-11-17 20:04:52 +01:00
Avi Halachmi (:avih) 2e54a21b5a OSC 52 - copy to clipboard: don't limit to 382 bytes
Strings which an application sends to the terminal in OSC, DCS, etc
are typically small (title, colors, etc) but one exception is OSC 52
which copies text to the clipboard, and is used for instance by tmux.

Previously st cropped these strings at 512 bytes, which for OSC 52
limited the copied text to 382 bytes (remaining buffer space before
base64). This made it less useful than it can be.

Now it's a dynamic growing buffer. It remains allocated after use,
resets to 512 when a new string starts, or leaked on exit.

Resetting/deallocating the buffer right after use (at strhandle) is
possible with some more code, however, it doesn't always end up used,
and to cover those cases too will require even more code, so resetting
only on new string is good enough for now.
2019-11-10 22:45:54 +01:00
Hiltjo Posthuma 289c52b7aa CSIEscape, STREscape: use size_t for buffer length 2019-11-10 22:45:54 +01:00
Avi Halachmi (:avih) 7ceb3d1f72 STREscape: don't trim prematurely
STRescape holds strings in escape sequences such as OSC and DCS, and
its buffer is 512 bytes.

If the input is too big then trailing chars are ignored, but the test
was off-by-1 such that it took 510 chars instead of 511 (before a
terminating NULL is added).

Now the full size can be utilized.
2019-11-10 22:45:54 +01:00
Avi Halachmi (:avih) ea4d933ed9 base64dec: don't read out of bounds
Previously, base64dec checked terminating input '\0' every 4 calls to
base64dec_getc, where the latter progressed one or more chars on each
call, and could read past '\0' in the way it was used.

The input to base64dec currently comes only from OSC 52 escape seq
(copy to clipboard), and reading past '\0' or even past the buffer
boundary was easy to trigger.

Also, even if we could trust external input to be valid base64, there
are different base64 standards, and not all of them require padding
to 4 bytes blocks (using trailing '=' chars).

It didn't affect short OSC 52 strings because the buffer is initialized
to 0's, so typically it did stop within the buffer, but if the string
was trimmed to fit (the buffer is 512 bytes) then it did also read past
the end of the buffer, and the decoded suffix ended up arbitrary.

This patch makes base64dec_getc not progress past '\0', and instead
produce fake trailing padding of '='.

Additionally, at base64dec, if padding is detected at the first or
second byte of a quartet, then we identify it as invalid and abort
(a valid quartet has at least two leading non-padding bytes).
2019-11-10 22:45:54 +01:00
Sebastian J. Bronner 83866428de Fix tmux terminfo extensions Se and Ss
The tmux terminfo extensions Ss and Se are currently specified as
booleans in `st.info`. They should be strings. See
eeedb43ae8/tty-term.c
lines 254 and 265.

I have used the values from
https://invisible-island.net/ncurses/terminfo.src.html#toc-_S_I_M_P_L_E_T_E_R_M
for this patch.
2019-11-05 19:51:35 +01:00
Ingo Lohmar 1f09f0b0bb apply hints before initial mapping (ICCCM)
For WM_CLASS this is mentioned in the ICCCM docs
https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.5
(third sentence).

When changing the WM_CLASS from the command line, this is necessary for
window managers to pick it up before applying class-based rules.
2019-10-26 11:47:24 +02:00
Avi Halachmi (:avih) a2c479c4c8 mouse shortcuts: allow using forcemousemod (e.g. shift)
The recent mouse shurtcuts commits allow customization, but ignore
forcemousemod mask (default: shift) as a modifier, for no good reason
other than following the behavior of the KB shortcuts.

Allow using forcemousemod too, which now can be used to invoke
different shortcuts, though the automatic effect of forcemousemod will
be lost for buttons which use mask with forcemousemod.

E.g. the default is:

static uint forcemousemod = ShiftMask;
...
{ XK_ANY_MOD,           Button4, ttysend,        {.s = "\031"} },
...

where ttysend will be invoked for button4 with any mod when not in mouse
mode, and with shift when in mouse mode.

Now it's possible to do this:
{ ShiftMask,            Button4, ttysend,        {.s = "foo"} },
{ XK_ANY_MOD,           Button4, ttysend,        {.s = "\031"} },

Which will invoke ttysend("foo") while shift is held and ttysend("\031")
otherwise. Shift still overrides mouse mode, but will now send "foo".

Previously with this setup the second binding was always invoked
because the forceousemod mask was always removed from the event.

Buttons which don't use forcemousemod behave the same as before.

This is useful e.g. for the scrollback mouse patch, which wants to
configure shift+wheel for scrollback, while keeping the normal behavior
without shift.
2019-10-24 15:34:25 +02:00
Avi Halachmi (:avih) d2b75db8d7 mouse shortcuts: don't hardcode selpaste
Because selpaste is activated on release, a release flag was added to
mouse shortcuts which controls whether activation is on press/release,
and selpaste binding to button2 was moved to config.h .

button1 remains the only hardcoded mouse button - for selection + copy.
2019-10-13 21:46:31 +02:00
Avi Halachmi (:avih) b6d280de6d mouse shortcuts: allow override for all shortcuts
Allow forceselmod to override all mouse shortcuts rather than only
selection, and rename it to forcemousemod as it's now more appropriate.

This will affect mouse shortcuts which use mask other than XK_ANY_MOD.

This does not affect the default behavior because the default mouse
shortcuts (wheel) use XK_ANY_MOD, where forceselmod already activated
the override also before this change.

Previously, if a mouse shortcut was configured with a specific mod and
forceselmod was held, then the shortcut did not execute unless the
configured mod included forceselmod.
2019-10-13 21:46:31 +02:00
Avi Halachmi (:avih) ba7f4d69af mouse shortcuts: allow same functions as kb shortcuts
Previously mouse shortcuts supported only ttywrite.

This required adding an "Arg" function ttysend - which does what the
original mouse shortcuts did.
2019-10-13 21:46:31 +02:00
Hiltjo Posthuma 2b8333f553 config.def.h: remove crlf value section
this is not used anymore.

patch sent as an ed script using RFC2549 by k0ga.
2019-08-26 17:58:47 +02:00
Hiltjo Posthuma caa1d8fbea FAQ: add entry about color emoji Xft bug
This has been asked many times on IRC and the mailinglist. Make it easier to
find information about this particular Xft issue by adding it to the FAQ.
2019-05-17 13:00:10 +02:00
Avi Halachmi (:avih) f1546cf9c1 selection: fix view to match actual selection on first cell 2019-04-14 13:50:20 +02:00
Hiltjo Posthuma 21367a040f revert part of commit add0211522
"use iswspace()/iswpunct() to find word delimiters

    this inverts the configuration logic: you no longer provide a list of
    delimiters -- all space and punctuation characters are considered
    delimiters, unless listed in extrawordchars."

Feedback from IRC and personal preference.
2019-03-15 20:40:16 +01:00
Hiltjo Posthuma b650256044 dont print color warning on color reset OSC 104 without parameter
also print explicitly "(null)" when printf "%s" p=NULL.

noticed when exiting mutt: printf '\x1b]104\x07'
2019-03-15 14:47:08 +01:00
Hiltjo Posthuma 9acec468fb minor code-style, initialize var at the top of function 2019-03-15 14:42:50 +01:00
Hiltjo Posthuma 927621f6da config.def.h: tweak extra worddelimiters
This changes the selection more like xterm.
To test try: "find /" and select a path.
2019-03-15 12:31:54 +01:00
Lauri Tirkkonen add0211522 use iswspace()/iswpunct() to find word delimiters
this inverts the configuration logic: you no longer provide a list of
delimiters -- all space and punctuation characters are considered
delimiters, unless listed in extrawordchars.
2019-03-15 12:25:13 +01:00
Lauri Tirkkonen d5efd256aa replace utf8strchr with wcschr 2019-03-15 12:24:13 +01:00
Lauri Tirkkonen 75b4ba4b4b be silent about explicitly unhandled mouse modes 2019-03-13 17:51:58 +01:00
Hiltjo Posthuma ed68fe7dce simplify (greedy) font caching allocating a bit
POSIX says:
"If ptr is a null pointer, realloc() shall be equivalent to malloc() for the
 specified size."
2019-03-03 11:29:43 +01:00
Hiltjo Posthuma 4e0135afec style: remove double empty newlines 2019-03-03 11:23:54 +01:00
magras a8cb8e9454 fix use after free in font caching algorithm
Current font caching algorithm contains a use after free error. A font
removed from `frc` might be still listed in `wx.specbuf`. It will lead
to a crash inside `XftDrawGlyphFontSpec()`.

Steps to reproduce:
$ st -f 'Misc Tamsyn:scalable=false'
$ curl https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

Of course, result depends on fonts installed on a system and fontconfig.
In my case, I'm getting consistent segfaults with different fonts.

I replaced a fixed array with a simple unbounded buffer with a constant
growth rate. Cache starts with a capacity of 0, gets increments by 16,
and never shrinks. On my machine after `cat UTF-8-demo.txt` buffer
reaches a capacity of 192. During casual use capacity stays at 0.
2019-03-03 11:18:31 +01:00
Ivan Tham e85b6b6466 better Input Method Editor (IME) support
Features:

- Allow input methods swap with hotkey (E.g. left ctrl + left shift).
- Over-the-spot pre-editing style, pre-edit data placed over insertion point.
- Restart IME without segmentation fault.

TODO:

- Automatically pickup IME if st started before IME
2019-02-12 18:45:15 +01:00
Hiltjo Posthuma 75f92eb348 bump version to 0.8.2 2019-02-09 12:48:39 +01:00
Hiltjo Posthuma 3be4cf11d7 config: add Shift+Insert as selpaste() again
This was changed before in:
commit 20f713548d on Wed Jan 25 19:17:38 2017
2019-01-10 18:16:17 +01:00
Paride Legovini 16d98738e7 Let the user specify CPPFLAGS
This complements the work done in d4928ed, allowing the user to specify
the preprocessor flags with the CPPFLAGS environment variable. This is
useful for example to specify preprocessor macros with -D.

CFLAGS could be used instead, but CPPFLAGS is more correct and is expected
to be honored in some cases. For example, the helper scripts to build
Debian packages make use of CPPFLAGS, but the variable is currently
being ignored unless manually appended to CFLAGS.
2019-01-10 18:13:13 +01:00
Paride Legovini e23acb9188 Set the path of pkg-config in a variable instead of hardcoding it
In this way the path of pkg-config can be overridden from the command
line. This is useful for example when cross-compiling.
2019-01-04 16:00:54 +01:00
Hiltjo Posthuma 7e19e11676 Makefile: fix dependencies on config.h
patch by Younes Khoudli (changed slightly). Thanks
2019-01-04 12:33:01 +01:00
Lauri Tirkkonen 096b125db7 output child WEXITSTATUS/WTERMSIG on abnormal termination 2018-12-11 18:36:02 +01:00
Hiltjo Posthuma d7bf023b2f fix memory leak in xloadcols()
reported by Avi Halachmi (:avih)" <avihpit@yahoo.com>

patch slightly changed by me.
2018-11-04 14:35:07 +01:00
Hiltjo Posthuma b4d68d4daa st: small typofix in comment 2018-11-04 14:30:56 +01:00
Hiltjo Posthuma 30ec9a3dc3 small code-style fix 2018-09-11 19:06:35 +02:00
Quentin Rameau 67d0cb65d0 Remove the ISO 14755 feature
And move it to the patches section.
Keeping it would force to add an exec pledge on OpenBSD, and some
people think it's bloated, so bye!
2018-09-11 19:05:55 +02:00
Hiltjo Posthuma 4f4bccd162 Revert "Simplify cursor color handling"
This reverts commit 1911c9274d.
2018-07-17 20:01:58 +02:00
Hiltjo Posthuma 8ed7a4b3b7 Revert "Make cursor follow text color"
This reverts commit b51bcd5553.
2018-07-17 20:01:57 +02:00
Hiltjo Posthuma 732be223ee Revert "Fix crash when cursor color is truecolor"
This reverts commit 5535c1f04c.
2018-07-17 20:01:54 +02:00
Jules Maselbas 5535c1f04c Fix crash when cursor color is truecolor
Reported-by: Ivan Tham <pickfire@riseup.net>
2018-07-15 18:16:52 +02:00
Jules Maselbas b51bcd5553 Make cursor follow text color 2018-07-14 12:49:37 +02:00
Jules Maselbas 1911c9274d Simplify cursor color handling 2018-07-14 12:49:35 +02:00
Jules Maselbas 29f341da7c Fix crash on resize
Prevent to realloc xw.specbuc with a negative number of col.
Add proper hints for the minimal size, for one character.
2018-06-30 20:51:46 +02:00
Hiltjo Posthuma dc3b5babf1 config.mk: remove extra newline before EOF 2018-06-02 17:11:14 +02:00
Hiltjo Posthuma 235a783e03 code-style for pledge(2)
feedback from Klemens, thanks
2018-05-25 13:04:09 +02:00
Hiltjo Posthuma 30ce2cc002 Pledge on OpenBSD 2018-05-25 11:59:28 +02:00
Hiltjo Posthuma 041912a791 error message style and use strerror in a few places 2018-03-29 18:30:05 +02:00
Hiltjo Posthuma bd3f7fd842 st -v: remove years and copyright text 2018-03-29 18:18:30 +02:00
Daniel Tameling 74cff67bd7 set sel.alt in selstart instead of selextend 2018-03-29 18:15:29 +02:00
Hiltjo Posthuma 6f0f2b7ec3 bump version to 0.8.1 2018-03-20 21:29:10 +01:00
Hiltjo Posthuma f4020b2cc4 fix regression by selecting clipboard text
"restore the old behaviour that the primary doesn't get deleted by a simple
left click"

Patch by Daniel Tameling <tamelingdaniel@gmail.com>, thanks!
2018-03-20 21:25:30 +01:00
Hiltjo Posthuma a5a928bfc1 don't modify argv, use a counter
on some platforms (OpenBSD) this changes the exposed argv in tools using
the kvm_* interface, such as ps and pgrep.
2018-03-20 21:22:27 +01:00
Hiltjo Posthuma 6ac8c8aa50 selextend: clarify: !sel.mode == SEL_IDLE 2018-03-17 13:48:29 +01:00
Hiltjo Posthuma 5345db3c9b clipcopy: no need to check for free(NULL), set to NULL after free 2018-03-17 13:48:10 +01:00
Hiltjo Posthuma 7648697f71 minor code-style: whitespace fixes 2018-03-16 16:45:58 +01:00
Quentin Rameau 0b507bb731 Fix title initialization 2018-03-16 16:44:30 +01:00
Quentin Rameau e7ef3c4ce9 Fix regression from 69e32a6 when setting title. 2018-03-16 16:44:30 +01:00
Hiltjo Posthuma 8ab629031b LICENSE: fix a few years 2018-03-14 20:08:00 +01:00
Hiltjo Posthuma a712c2dd18 update LICENSE: major contributors 2018-03-14 20:00:35 +01:00
Hiltjo Posthuma 0f245dfeb9 Makefile: add all files to make dist 2018-03-14 19:54:50 +01:00
Hiltjo Posthuma 49a4f91fc5 bump version to 0.8 2018-03-14 19:50:37 +01:00
Hiltjo Posthuma c5ba9c025b use math.h for ceilf 2018-03-09 15:36:38 +01:00
Hiltjo Posthuma b81888ee7d xhints: no need to initialize sizeh 2018-03-09 15:36:25 +01:00
Hiltjo Posthuma 8b8255ac0e regression: include termios.h for tcsendbreak etc 2018-03-09 15:35:34 +01:00
Devin J. Pohly 20e0da7f14 General cleanup
Simplifies logic in a couple places and removes a redundant function
call.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly 403c57ebb5 Clean up #includes
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly e0215d5377 Reduce visibility wherever possible
When possible, declare functions/variables static and move struct
definitions out of headers.  In order to allow utf8decode to become
internal, use codepoint for DECSCUSR extension directly.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly 30683c70ab Limit usage of extern to config.h globals
Prefer passing arguments to declaring external global variables.  The
only remaining usage of extern is for config.h variables which are
needed in st.c instead of x.c (where it is now included).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly a3beb626d2 Remove x.c dependency on term
The xinit function only needs to the rows/cols, so pass those in rather
than accessing term directly.  With a bit of arithmetic, we are able to
avoid the need for term.row and term.col in x2col, y2row, and
xdrawglyphfontspecs as well, completing the removal.

Term is now fully internal to st.c.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly a5dc1b4697 Pull term references out of xdrawcursor
Gradually reducing x.c dependency on Term object.  Old and new cursor
glyph/position are passed to xdrawcursor.  (There may be an opportunity
to refactor further if we can unify "clear old cursor" and "draw new
cursor" functionality.)

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly 88d8293fb4 Move win-agnostic parts of draw/drawregion to st.c
Introduces three functions to encapsulate X-specific behavior:
 * xdrawline: draws a portion of a single line (used by drawregion)
 * xbegindraw: called to prepare for drawing (will be useful for e.g.
   Wayland) and returns true if drawing should happen
 * xfinishdraw: called to finish drawing (used by draw)

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly 05c66cb37d Split mode bits between Term and TermWindow
Moves the mode bits used by x.c from Term to TermWindow, absorbing
UI/input-related mode bits (visible/focused/numlock) along the way.

This is gradually reducing external references to Term.  Since
TermWindow is already internal to x.c, we add xsetmode() to allow st to
modify window bits in accordance with escape sequences.

IS_SET() is redefined accordingly (term.mode in st.c, win.mode in x.c).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly 33201ac65f Move CRLF input processing into ttywrite
This also allows us to remove the crlf field from the Key struct, since
the only difference it made was converting "\r" to "\r\n" (which is now
done automatically in ttywrite).  In addition, MODE_CRLF is no longer
referenced from x.c.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 52d6fb1ab1 Move terminal echo logic into st.c
The only thing differentiating ttywrite and ttysend was the potential
for echo; make this a parameter and remove ttysend.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly cfc7acdfd9 Move remaining selection mode logic into selextend
The "done" parameter indicates a change which finalizes the selection
(e.g. a mouse button release as opposed to motion).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly bcb5d3adbe Move terminal-related selection logic into st.c
The front-end determines information about mouse clicks and motion, and
the terminal handles the actual selection start/extend/dirty logic by
row and column.

While we're in the neighborhood, we'll also rename getbuttoninfo() to
mousesel() which is, at least, less wrong.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 5683b1f80c Move X-specific selection info into XSelection
Data about PRIMARY/CLIPBOARD and clicks are part of the front-end, not
the terminal.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 138caf294e Have selected() check whether selection exists
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly d84f3f4bd1 Rely on ttyresize to set tty size
This removes ttynew's dependency on cresize being called first, and then
allows us to absorb the ttyresize call into cresize (which always
precedes it).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 8b564c1a3f Remove X and fontconfig from st.c
None of the X-related includes are needed any longer.  In addition, move
the X modifier defines into x.c, as they are not used outside.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 3bb900cd6c Remove Time argument from xsetsel
This is an X type and should be internal to x.c.

The selcopy() function was a single line and only used in one place, so
it was inlined to reduce LOC.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 323d38da20 Make win variable internal to x.c
There was only a single reference to the `win` variable in st.c, so
exporting that to x.c allows us to rid ourselves of another extern.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 416dd25727 Move X-related config.h types into x.c
No need to expose Shortcut, MouseShortcut, and Key anymore.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 75c9a0ee1d Remove unneeded array-length variables
These were only used in x.c, which now has direct visibility of the
config.h arrays.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 428f01969a Inline clipboard functions
No need to keep a function that only calls another function in the same
file.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 65976c1a29 Move config.h include from st.c to x.c
config.h includes references to KeySyms and other X stuff.  Until we
come up with a cleaner way to separate configuration, it is simpler
(leads to more code removal) to have this here.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 32d3b1d00f Factor out equivalent code from ttyread/ttysend
The echo-to-terminal portions of ttyread and ttysend were actually doing
the same thing.  New function twrite() now handles this.  The parameter
show_ctrl determines whether control characters are shown as "^A".  This
was the only difference between tputc and techo, and techo is now unused
and removed.

(This commit should not change st's behaviour.)

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 69e32a61df Move opt_* into same file as main()/run()
This commit is purely about reducing externs and LOC.  If the main and
run functions ever move elsewhere (which will probably make sense
eventually), these should come along with them.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly ed132e1127 Move key-matching functions into x.c
Modifiers and keysyms are specific to X, and the functions match and
kmap are only used in x.c.  Needed to global-ize the key arrays and
lengths from config.h (for now).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly dbe8676d7d Pass new dimensions into ttyresize
This removes another reference to TermWindow from st.c.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly a8314643b1 Move window-manipulating functions into x.c
xresize is now internal to x.c

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly a09138afa5 Move font/fontspec variables into x.c and XWindow
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 626b0ae40c Move window urgency handling entirely into x.c
This allows us to make xseturgency internal.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly d5275012b4 Move zoom functions into x.c
This makes x(un)loadfonts internal to x.c.  Needed to reorder includes
and move a typedef to keep the compiler happy.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 3518dba2a5 Move usage() to be with run() in x.c
run/usage/xinit are now all internal to x.c

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly 3e44ee5569 Call xsetenv() in main process instead of child
This makes xsetenv internal to x.c, and allows iso14755's external
command to use $WINDOWID instead of having to snprintf it again.  (The
same benefit will apply to the externalpipe patch.)  The xwinid function
is no longer needed.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Benno Fünfstück 1f24bde82b Fix color with FAINT attribute
The alpha value needs to be initialized as well.
2017-12-26 22:54:44 +01:00
Benno Fünfstück e829e13bb1 Apply ATTR_REVERSE after ATTR_FAINT
An example where the new behaviour makes more sense:

Suppose some text is formatted with ATTR_FAINT for red for the foreground, so it
is rendered in a dark red. In that case, when selected with the mouse, the
intended behaviour is that foreground and background color are swapped: so the
selection should be rendered in dark red and the text in the default background
color.

Before this patch, what happened was that the selection would be in normal red
and the text in the darkened background color, making it almost unreadable.

For an example application that uses the FAINT attribute, try dmesg from
util-linux with color support, it uses FAINT for segfault messages.
2017-12-26 22:54:06 +01:00
George Ornbo c1d23afa9c Fix FAQ typo 2017-12-21 19:17:40 +01:00
Paride Legovini 0ac685fc01 Fix manpage typo
Signed-off-by: Paride Legovini <pl@ninthfloor.org>
2017-10-10 18:08:42 +02:00
Gary Allen Vollink b1338e91ed Add an error for XftFontOpenPattern failure. 2017-09-15 11:27:13 +02:00
Hiltjo Posthuma b2ac917753 Revert "Revert "fixed STLDFLAG order in broken st Makefile""
This reverts commit 274d46ace0.

Sorry, the original commit was correct after all. It allows has the
correct link order and supports static-linking also.

Just a reminder: it is important to give a (brief) rationale of the
patch intentions.
2017-09-15 11:16:37 +02:00
Suraj N. Kurapati ee5cc8e903 base64dec: skip non-printable characters like \r\n
Non-printable characters, such as line breaks, in a base64 encoded
string violate the "string length must be a multiple of four" rule.

This patch pads the result buffer by one extra unit of four bytes,
and skips over non-printable characters found in the input string.
2017-09-15 11:13:17 +02:00
Hiltjo Posthuma 274d46ace0 Revert "fixed STLDFLAG order in broken st Makefile"
This reverts commit 7f990328e4.

this was wrong as pointed out by k0ga:
"STLDFLAGS is about flags to the linker, for example -L
not about -l for that reason it must go before the object list".
2017-09-13 22:40:36 +02:00
Hiltjo Posthuma 9c61f29bb7 Revert "make clipboard patch obsolete"
This reverts commit 77c51c5a6b.

Having multiple clipboards are useful, for example for plumber scripts.
I've discussed this on IRC and it is useful to have.
2017-09-02 13:52:33 +02:00
Anselm R Garbe 77c51c5a6b make clipboard patch obsolete 2017-09-01 09:48:24 +02:00
Anselm R Garbe 7f990328e4 fixed STLDFLAG order in broken st Makefile 2017-07-23 11:17:26 +02:00
Quentin Rameau 8dacdfbab1 Revert "Add bold off SGR"
This reverts commit 6cb6d61525.
This wasn't a useful thing after all.
2017-07-12 13:29:31 +02:00
Quentin Rameau c0882f2ed1 Add dim/smxx/rmxx to terminfo, remove duplicate kich1 2017-07-12 13:29:30 +02:00
Quentin Rameau d4928edba0 Let the user specify C and LD FLAGS 2017-07-12 00:28:11 +02:00
Quentin Rameau fabd4602b3 Do not obfuscate what make is doing.
Change some styling too while we're at it.
2017-07-12 00:28:10 +02:00
Marc André Tanner b331da550b Add color change terminfo capabilities 2017-06-03 22:28:35 +02:00
Quentin Rameau 6cb6d61525 Add bold off SGR 2017-06-03 22:28:35 +02:00
greg.reagle@umbc.edu 5a10aca702 st.1: modify man page to accurately reflect default keybindings
Attached.

===> 2/ (text/x-patch) [file]
	cp /mail/fs/mbox/298/2/body /usr/k0ga/0001-st.1-modify-man-page-to-accurately-reflect-default-k.patch

From 265db94b1eca5850d484f86b7db4af8e57822cfe Mon Sep 17 00:00:00 2001
From: Greg Reagle <greg.reagle@umbc.edu>
Date: Sun, 9 Apr 2017 23:05:47 -0400
Subject: [PATCH] st.1: modify man page to accurately reflect default
 keybindings
2017-04-10 18:32:10 +02:00
Quentin Rameau 745c40f8b0 Simplify how we keep ATTRs under cursor
Thanks to tarug0 for the suggestion/patch.
2017-04-04 18:23:45 +02:00
Alexander Krotov 149c0d3aed Fix commented out code 2017-03-29 18:46:20 +02:00
Nils Reuße f2bfd513b1 keep some glyph modes for the cursor
st currently does not keep any mode for the cursor that was active
in the underlying glyph (e.g. italic text), the mode is always
ATTR_NULL [1].  At [2] you can find a screenshot that shows the
implications.  Other terminals (at least vte-based, such as
XFCE-terminal) keep some modes for the cursor.  I find the current
behaviour very disruptive, so here is a patch that keeps a few
(arbitrarily chosen) modes for the cursor.

[1] http://git.suckless.org/st/tree/st.c#n3963
[2] http://i.imgur.com/R2yCEaC.png
2017-03-29 18:39:21 +02:00
osandov@osandov.com e7ed326d2e Support xterm Ms feature to set clipboard
This is used by, e.g., tmux.
2017-03-19 20:32:22 +01:00
Roberto E. Vargas Caballero 20f713548d Change default keybindings
CTRL+SHIFT is an impossible combination in the terminal world
(0x20 | x & 0x1F), so it is perfect to be used for internals
shortcuts of terminals, and being a double combination
reduces the prossibility of having comflicts.
2017-01-25 19:17:38 +01:00
Michael Forney e2ee5ee611 Split X-specific code into x.c 2017-01-20 19:42:26 -08:00
fpqc c63a87cd93 Move column and row default numbers into config.h 2016-12-16 10:50:23 +01:00
Roberto E. Vargas Caballero e44832408b Revert "Initial font size issue."
This reverts commit 424202798b.
2016-11-24 20:21:19 +01:00
Spencer Phippen fa9a459972 Fixed 'missing glyph doesn't use fontconfig config substitutions' bug
XftFontMatch does display-specific font configuration (commit 528241a).
Nice. Unfortunately, when we switched from FcFontMatch, we also stopped
storing the post-Fc{Config,Default}Substitute FcPattern for future
lookups. The result is that if a glyph isn't found in the primary font,
secondary font lookups use the original FcPattern, not the configured
one. If you have custom fontconfig rules (like me), this can be
disappointing.

I basically just copied the guts out of XftFontMatch[1] and saved
the intermediate configured FcPattern. Could be related to the bug that
inspired commit 4242027.

[1]: https://cgit.freedesktop.org/xorg/lib/libXft/tree/src/xftfont.c
2016-11-24 20:20:45 +01:00
Manuel Tobias Schiller 740ada1447 make the various combinations of arrow keys and shift/control/meta work
When using st with screen, I've bound next, prev, new screen to
combinations like Ctrl-Alt-Right,Left,Down; xterm and (u)rxvt work fine
when this combination of modifiers is pressed, st does not seem to
transport all of them; a single modifier key is fine (e.g. Ctrl-Up,
Alt-Down etc., but combinations are not). While I'm not terribly
familiar with this, I have tried to hack config.h in a more or less
systematic way to generate the expected sequences.
2016-11-14 19:58:02 +01:00
ian@remmler.org 424202798b Initial font size issue.
Hi,

When I specify a font by point size (I'm using "Inconsolata:size=12"),
characters that are substituted from another font because they are not in the
main one appear too small.  Doing a zoom reset fixes it.  For example:

Before: http://i.imgur.com/G4Mfv4X.png
After:  http://i.imgur.com/PMDhfQA.png

I found that adding the pixel size (acquired from the initial font load) to the
pattern then reloading the font fixes the problem.  I'm not sure if this is a
proper fix, though.
2016-11-14 19:27:55 +01:00
pl@ninthfloor.org 3ca7249c86 tic -s -> tic -sx (Treat unknown capabilities as user-defined.) 2016-11-14 19:05:47 +01:00
pl@ninthfloor.org 06f8cf8ca8 Add tmux capabilities to st.info 2016-11-14 19:05:11 +01:00
pl@ninthfloor.org 902a392b90 Make strdump(), csidump(), print to stderr
The two functions strdump(), csidump() are called to show errors and
their output is introduced by a message printed to stderr. Thus, it it
more consistent to have them print to stderr.

Moreover stderr is unbuffered (at least on Linux), making problems
immediately visible.
2016-11-14 18:36:38 +01:00
Quentin Rameau 8c99915608 Do not use color when font attributes are supported
If fontconfig gives us a font without the attributes we asked for,
display an alternative color instead.
2016-10-23 17:56:46 +02:00
Quentin Rameau 7854fde1ff st.1: add an entry for ISO-14755 shortcut 2016-10-22 10:43:18 +02:00
Quentin Rameau 68bae9c7b1 Add support for iso14755
We launch dmenu for getting a codepoint, then convert it and send it to
the terminal.
2016-10-18 13:32:36 +02:00
Klemens Nanni 331033f1f6 Add missing device path to '-l' example
Also, it's ttyS0 not ttySO.
2016-10-13 17:25:17 +02:00
Roberto E. Vargas Caballero f7398434b8 Add parsing of DCS q sequences
These sequences are used to operate with sixels, but they are still
str sequences, so they are finished with \a, ST or with a C1 control
code. This patch also disables utf8 handling for the case of sixels.
2016-09-14 08:27:32 +02:00
Roberto E. Vargas Caballero f0e2d28732 Add support for enabling/disabling utf
There are some ocasions where we want to disable the enconding/decoding of utf8, mainly
because it adds an important overhead. This is partial patch for ESC % G and ESC % @,
where they modified the way that st reads and write from/to the serial line, but it does
not modifies how it interacts with the X window part.
2016-09-13 14:01:18 +02:00
Roberto E. Vargas Caballero 078337d745 Delete ncv capability from terminfo
We do not need to disable the previous ncv definition, because
there is not previous definition.
2016-09-09 13:11:06 +02:00
Quentin Rameau 5ce853a1c1 st.info: do not prevent st from displaying attributes
With ncv set to 3, we prevent st from displaying A_STANDOUT and
A_UNDERLINE with colors while our virtual terminal is capable of it.
2016-09-09 11:05:11 +02:00
Christoph Lohmann 023225ef40 Update the LICENSE.
This is for the next release.
2016-08-11 16:30:29 +02:00
Christoph Lohmann 6e79e8357e 0.7 release 2016-08-11 16:25:58 +02:00
Christoph Lohmann 308bfbf6be Change who's expanding tabs. 2016-07-20 13:56:15 +02:00
Christoph Lohmann c4f245eccd Add some hint to have the pseudo terminal in the right mode.
If you don't make sure that the terminal does not expand tabs to spaces, of
course such a setting won't work.
2016-07-20 13:52:31 +02:00
Christoph Lohmann 2251f6465a Add comment about tabspaces.
st.info needs to be changed too, when tabspaces are changed.
2016-07-20 13:00:43 +02:00
Alive 4ever 235b438e68 Consistent Alt+BackSpace behavior
The default config specifies BackSpace as "\177". The default behavior
should persist across modifier keys, commonly Mod1 (Alt or Meta) which
is widely used to delete a word on readline and text editors, notably
Emacs.

This will make Alt+BackSpace behaves as expected, i.e. sends "\033\177"
instead of "\033\010" as previous default behavior.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-07-12 15:25:08 +02:00
Christoph Lohmann 528241aa38 Use XftFontMatch in place of FcFontMatch.
git am -s didn't like your patch:

From: Mark Edgar <medgar123@gmail.com>

XftFontMatch calls XftDefaultSubstitute which configures various match
properties according to the user's configured Xft defaults (xrdb) as well as
according to the current display and screen. Most importantly, the screen DPI
is computed [1]. Without this, st uses a "default" DPI of 75 [2].

[1]: https://cgit.freedesktop.org/xorg/lib/libXft/tree/src/xftdpy.c?id=libXft-2.3.2#n535
[2]: https://cgit.freedesktop.org/fontconfig/tree/src/fcdefault.c?id=2.11.1#n255
2016-06-03 15:02:32 +02:00
v4hn 60aeb37edb delete clipboard properties after pasting them
https://tronche.com/gui/x/icccm/sec-2.html#s-2.4 specifies:
> Once all the data in the selection has been retrieved,
> the requestor should delete the property in the SelectionNotify request

Most Clipboard-Owners ignore whether or not the property is already set,
so this is mostly a cosmetic change to keep the windows property list clean.

However, at least synergy decides to wait for the requestor to delete
the properties if they are already set by a previous paste (from synergy).

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-06-03 14:55:25 +02:00
Roberto E. Vargas Caballero 66556d9670 Remove stupid assignation in memcpy() 2016-04-15 07:58:26 +02:00
Tor Andersson 39964614b7 st: Fix off-by-one error when calculating character width.
LEN(str) is one larger than strlen(str) because it also counts the zero
terminator. The original code would include the .notdef glyph (since it'll
try to encode character 0, which gets encoded to the .notdef glyph) when
measuring the average dimensions of printable ascii characters.

This causes problems with fonts like GNU Unifont where the .notdef glyph is
not the same width as the usual half-width characters.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-03-09 22:01:25 +01:00
Ton van den Heuvel 0e48a1995e Fix vertical character alignment in some cases
The y-position of a character found by asking fontconfig for a matching
font does not take the border pixels into account, resulting in a
slightly misaligned vertical position.

Signed-off-by: Ton van den Heuvel <tonvandenheuvel@gmail.com>
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-03-08 15:43:52 +01:00
Christoph Lohmann 6d8f85232e I like empty lines. 2016-03-08 13:55:22 +01:00
Ryusei Yamaguchi 034a5c8a09 Measure the single advance width with a heuristic method
This fix is needed to use dual-width fonts, which have double-width
glyphs (e.g. CJK unified ideographs).

Signed-off-by: Ryusei Yamaguchi <mandel59@gmail.com>
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-03-08 13:46:42 +01:00
Christoph Lohmann 30440295bc xtermclear() is now done by xdrawglyphfontspecs()
Thanks Ton van den Heuvel for the proposal!
2016-03-07 14:33:05 +01:00
Lucas Gabriel Vuotto 4fdba860c8 arg.h: fixed argv checks order
This prevents accessing to a potentially out-of-bounds memory section.

Signed-off-by: Lucas Gabriel Vuotto <l.vuotto92@gmail.com>
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-02-21 17:21:41 +01:00
Quentin Rameau 6d636beb22 Fix forgotten bracket and duplicate option in usage()
Scratch the preceding patch, this one is more correct
(don't forget to 'git am --scissors' ;))
-- >8 --

Also reformat the strings in a saner layout

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-02-01 18:14:27 +01:00
Quentin Rameau 6e70bb97d4 Extract ttyresize() out of cresize()
This way we can call cresize() to set the terminal size before creating
a tty or spawning a process, which will start with the correct size.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-01-30 18:40:13 +01:00
Christoph Lohmann 82335583eb Ok, no need for a separate version function.
This is just redundant metadata. Please add Java comment meta classes too.
2016-01-30 09:50:18 +01:00
Quentin Rameau 0cd5117a2c Add -n option for setting WM_CLASS instance name
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-01-30 09:45:23 +01:00
Quentin Rameau bd5fdbe64c Reformat usage and separate version from it
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-01-30 09:44:41 +01:00
Christoph Lohmann 504a165277 Enforce a terminal size to reduce race conditions in too efficient apps.
dvtm is too fast in starting up. It will then have a race condition in finding
the right. terminal size.
2016-01-28 18:09:11 +01:00
Christoph Lohmann 9031e228ce Height is height. 2016-01-14 23:19:03 +01:00
Christoph Lohmann 610723a58f Bump year. 2016-01-01 14:18:43 +01:00
Christoph Lohmann ff241199ed Fixing the XClassHint setting in st. 2015-12-20 01:43:32 +01:00
Roberto E. Vargas Caballero 375b28720f Avoid recursive call to ttywrite from ttyread
Ttyread() calls to ttywrite, so if we check for reading before
that for writing in ttywrite we can get a circular call sequence.
2015-11-21 18:21:03 +01:00
Quentin Rameau d836561b96 arg.h: remove unused macros
ARGUM isn't used and ARGNUMF uses estrtol() that isn't defined anywhere.
Those were probably copied from sbase arg.h.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-08 20:33:56 +01:00
Christoph Lohmann 00873e65ee Introduce lim in all ttywrite() checks. 2015-11-06 20:46:23 +01:00
Roberto E. Vargas Caballero 9f6d8845df Fix ttywrite()
ttywrite was assuming that if it could not write then it could
read, but this is not necessarily true, there are some situations
where you cannot read or write. The correct behaviour is to detect
if you can read or/and write.
2015-11-06 20:01:00 +01:00
Ivan Tham f0398db4d1 Now the mshortcuts are even more consistent.
Keep everyone happy

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-01 08:23:26 +01:00
Christoph Lohmann e2aa03e6b7 Now the Shortcuts are more consistent.
Keep the debile happy.
2015-10-31 09:29:04 +01:00
Jason Woofenden f56c58a968 fix bug where first selection snaps to lines 2015-10-11 11:44:34 +02:00
Quentin Rameau 293f573efd Fix the cursor colors selection
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-06 17:36:02 +02:00
Christoph Lohmann 2ea02c937e Normalize the whole color selection in xdrawcursor. 2015-10-06 00:21:44 +02:00
Quentin Rameau 80fe97f8a6 Fix the cursor color when over selection.
If we want to show a custom selected cursor color, we must not set the
revert attribute to the drawn glyph.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-06 00:05:04 +02:00
Christoph Lohmann a2a60f0a2c Make the cursor shapes more descriptive.
»IBeam« is now »Bar« because it's named like that in the source code.
2015-10-05 23:05:38 +02:00
Christoph Lohmann 52d0e82df7 Snowman is everywhere. 2015-10-05 22:59:04 +02:00
Christoph Lohmann 78b04865fb Style normalisation in the config.def.h.
This adds an awareness commit for the big key array too.
2015-10-05 22:54:44 +02:00
Christoph Lohmann f7b80caebe The definition of the reverse cursor is now up to the user. 2015-10-05 22:38:19 +02:00
Christoph Lohmann 594a259836 Fixing the cursor movement in selections.
Before the fix the cursor wouldn't obey if it's in a selection. If it is
inside it will now change to the reverse. This patch also adds that the
defaultcs will be reversed for the manually drawn cursors.
2015-10-05 22:09:51 +02:00
Christoph Lohmann 91c70213d1 When the cursor is moved, clear the selection. 2015-10-05 21:18:34 +02:00
Christoph Lohmann 2677296147 Reverse the cursor on selection. 2015-10-05 21:06:42 +02:00
Christoph Lohmann 5ece2b5f4a More style changes. We forgot some switches. 2015-10-05 20:48:24 +02:00
Christoph Lohmann 2bef36ab81 Small style change. 2015-10-05 20:08:21 +02:00
Christoph Lohmann 1682484327 There's no need for libXext to compile st. 2015-09-28 20:08:58 +02:00
dequis 4be353e381 Fix extra bracketed paste markers when pasting >8kb
Before this patch, when pasting over BUFSIZE (8192 bytes here), st would
do the following:

    \e[200~...8192 bytes...\e[201~\e[200~...remaining bytes...\e[201~

With this patch, the start marker is only sent when the offset is 0 (at
the beginning of selnotify) and the end marker is only sent when the
remaining bytes to read are 0 (at the end).

For short pastes, both conditions are true in the same iteration.

For long pastes, it removes the extra markers in the middle, keeping the
intended wrapping:

    \e[200~...8192 bytes......remaining bytes...\e[201~

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-09-25 20:16:30 +02:00
FRIGN 20d53cebc1 dup() -> dup2()
gcc would warn about an unused result. We know it is 0 and dup()
can't fail in these circumstances, as we closed fd0 previously.
Using dup2() to do the same saves one line and shuts gcc up, bringing
us a clean build back.
2015-09-22 14:15:24 +02:00
Christoph Lohmann bf8c71e429 The times of bad fonts are over.
The antialiasing was false due to circumstances that do not exist anymore. We
need antialiasing on big screens with big fonts. Autohinting too.
2015-09-12 16:43:32 +02:00
Roberto E. Vargas Caballero 5d2d9d540d Fix copy of line with len = 0
When a line has no any character linelen is 0, so last = &term.line[y][MIN(lastx, linelen-1)]
generated a pointer to the end of the previous line. The best thing we can do in this case
is to add a newline, because we don't have a glyph to print (and consult its state of
wrapping).
2015-09-10 11:53:11 +02:00
Roberto E. Vargas Caballero a1ed5071e5 Change Pause to Break in shortcut for serial break 2015-09-08 17:02:15 +02:00
Jan Christoph Ebersbach 3ba9c8fc3f Expose cursor shape in config.def.h
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-09-08 16:29:05 +02:00
Roberto E. Vargas Caballero 1f087aa8b7 Add key to send a break to the serial line 2015-09-08 12:10:11 +02:00
Roberto E. Vargas Caballero 473326f2e3 Set default values of stty according to the man page
This configuration is basically 38400 8N1, without echo and
in raw mode. Kernel will not process any of the characters
sent by the user.
2015-09-08 10:47:31 +02:00
Christoph Lohmann aa5d4c3b34 Making st.1 more descriptive about -l and fix -l in st.c. 2015-09-07 22:59:05 +02:00
Christoph Lohmann 080a5ae425 Fix the st manpage for -l line. 2015-09-07 20:00:49 +02:00
Christoph Lohmann 9eeb4e1ea2 Reordering and adding control codes.
For completeness and documentation add all C1 control codes.
2015-08-31 15:26:21 +02:00
Christoph Lohmann 0c94f8621b Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-08-30 11:29:23 +02:00
Christoph Lohmann 0d838b7243 Don't read if we chunked the input data. 2015-08-30 11:28:35 +02:00
Roberto E. Vargas Caballero 7e61f5e4c5 Do not mark as invalid UTF8 control codes
wcwidth() returns -1 for all the non visible characters, but it doesn't
necessarilly mean that they are incorrect. It only means that they are not
printable.
2015-08-18 08:31:51 +02:00
Quentin Rameau 9984ad4ba7 st.info: replace the acsc entry from xterm to urxvt
The current acsc entry, copied from xterm was not exposing capability to
display arrows.
2015-08-12 09:02:12 +02:00
Alex Kozadaev ee5cad439b Adding mouse colour/shape settings 2015-07-28 12:21:11 +02:00
Christoph Lohmann dc33d1d66e Adding -T to the usage too. 2015-07-24 18:25:33 +02:00
Christoph Lohmann b5e29cce52 Add -T, as recommended by Dmitrij D. Czarkoff 2015-07-24 18:24:10 +02:00
Quentin Rameau 4a193b9686 Fix type for write(2) return variable.
A little fix in xwrite().

>From 3727d2e3344b57128ab51c7839795204f1f839ff Mon Sep 17 00:00:00 2001
From: Quentin Rameau <quinq@fifth.space>
Date: Fri, 24 Jul 2015 11:40:46 +0200
Subject: [PATCH] Fix type for write(2) return variable.

The allocated lengh of s fits into an integer so we can safely use
ssize_t here.
2015-07-24 12:01:56 +02:00
Mytchel Hammond 1d348e98e3 added note about the low precedence of shell to config.def.h 2015-07-24 08:15:55 +02:00
Roberto E. Vargas Caballero 62756fdb49 Fix style in execsh 2015-07-24 07:44:34 +02:00
Christoph Lohmann d032b61597 Make the comment for the IM XFilter more understandable. 2015-07-10 14:31:40 +02:00
Christoph Lohmann 684c72d05e Return style unification. 2015-07-10 14:30:37 +02:00
Christoph Lohmann b823f57fa0 Aligning the macros. 2015-07-10 14:21:52 +02:00
Christoph Lohmann 684f0a0729 Unix end of file. 2015-07-10 14:19:52 +02:00
Christoph Lohmann d3c7b6fb73 No inline declarations please. 2015-07-10 14:19:31 +02:00
Christoph Lohmann 41f70a1cff Typo and the missing incr atom from the patches. 2015-07-10 14:17:51 +02:00
Christoph Lohmann 261ea4b7e0 Implement chunked write to the cmdfd.
This is needed so big input like a paste of several megabyte does not clog our
I/O.
2015-07-10 14:15:39 +02:00
Christoph Lohmann f8c6e7d041 Implement INCR transfers in the clipboard. 2015-07-10 14:10:17 +02:00
FRIGN 539afe3af1 Update LICENSE
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-07-10 13:59:08 +02:00
FRIGN f1307d91e2 Don't treat clauses like functions
and add a space between the keyword and the parentheses.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-07-10 13:58:31 +02:00
FRIGN 13233574ed Use BSD-style function notation
Put the opening brace on a new line. This was already used for some
functions inside st.c.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-07-10 13:58:09 +02:00
FRIGN 9de853a98d Unboolify st
This practice proved itself in sbase, ubase and a couple of other
projects.
Also remove the True and False defined in X11 and FcTrue and FcFalse
defined in Fontconfig.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-07-09 18:34:46 +02:00
FRIGN abfad4c4fc Remove insane *_FILENO and EXIT_* usage
Any system having different assignments than the usual 0, 1, 2 for
the standard file numbers and 0, 1 for the exit-statuses is broken
beyond repair.
Let's keep it simple and just use the numbers, no reason to fall
out of the window here and bend down for POSIX.
In one occasion, the ret-variable was not necessary. The check was
rewritten.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-07-09 18:34:41 +02:00
Christoph Lohmann 92e092efe6 Commit to push the 0.6 release. 2015-07-07 22:26:44 +02:00
Weng Xuetian 5f48e89716 Revert "Remove unnecessary XFilterEvent call."
This reverts commit d2937b05ae.
2015-07-02 11:11:55 +02:00
Quentin Rameau bdd649a102 do not truncate font size when zooming 2015-06-19 11:49:13 +02:00
Roberto E. Vargas Caballero 71fa10f613 Revert "Optimize memory footprint of line buffers"
This reverts commit 7ab6c92e18.
We need 32 bits for real color support.
2015-06-03 08:07:55 +02:00
Jan Christoph Ebersbach caa97cc781 Support UTF-8 characters as word delimiters
For a higher usefulness of the utf8strchr function, the index of the
UTF-8 character could be returned in addition with a Rune instead of a
char*.  Since utf8strchr is currently only used by ISDELIM I didn't
bother to increase the complexity.
2015-05-25 08:35:32 +02:00
Roberto E. Vargas Caballero c03548750b Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-05-15 07:51:58 +02:00
v4hn 8e15887de9 set selection to IDLE on clear
Otherwise a tangling bmotion event will consider
the selection still valid and selnormalize segfaults
because of an invalid sel.ob.y index.
2015-05-15 07:42:40 +02:00
suigin 89cf0fc597 Small bugfix for makeglyphfontspecs call in drawregion
Here's a patch that fixes a bug when calling `makedrawglyphfontspecs'
in `drawregion'. Wasn't offseting the pointer into the input glyphs
array by `x1'. The bug isn't causing any problems currently, because
`drawregion' is always called with `x1' and `y1' values of 0, but if
this ever changes in the future, the bug would certainly cause some
problems.
2015-05-12 07:37:13 +02:00
Christoph Lohmann 980991fa6e Fix the new -e handling. An empty cmd has to work for backwards compatibility. 2015-05-10 15:19:48 +02:00
suigin ae1923d275 Clean up xdraws and optimize glyph drawing with non-unit kerning values
I have another patch here for review that optimizes the performance of
glyph drawing, primarily when using non-unit kerning values, and fixes a
few other minor issues. It's dependent on the earlier patch from me that
stores unicode codepoints in a Rune type, typedef'd to uint_least32_t.

This patch is a pretty big change to xdraws so your scrutiny is
appreciated.

First, some performance numbers. I used Yu-Jie Lin termfps.sh shell
script to benchmark before and after, and you can find it in the
attachments. On my Kaveri A10 7850k machine, I get the following
results:

Before Patch
============

1) Font: "Liberation Mono:pixelsize=12:antialias=false:autohint=false"
   cwscale: 1.0, chscale: 1.0
   For 273x83 100 frames.
   Elapsed time :     1.553
   Frames/second:    64.352
   Chars /second: 1,458,159

2) Font: "Inconsolata:pixelsize=14:antialias=true:autohint=true"
   cwscale: 1.001, chscale: 1.001
   For 239x73 100 frames.
   Elapsed time :   159.286
   Frames/second:     0.627
   Chars /second:    10,953

After Patch
===========

3) Font: "Liberation Mono:pixelsize=12:antialias=false:autohint=false"
   cwscale: 1.0, chscale: 1.0
   For 273x83 100 frames.
   Elapsed time :     1.544
   Frames/second:    64.728
   Chars /second: 1,466,690

4) Font: "Inconsolata:pixelsize=14:antialias=true:autohint=true"
   cwscale: 1.001, chscale: 1.001
   For 239x73 100 frames.
   Elapsed time :     1.955
   Frames/second:    51.146
   Chars /second:   892,361

As you can see, while the improvements for fonts with unit-kerning is
marginal, there's a huge ~81x performance increase with the patch when
using kerning values other than 1.0.

So what does the patch do?

The `xdraws' function would render each glyph one at a time if non-unit
kerning values were configured, and this was the primary cause of the
slow down. Xft provides a handful of functions which allow you to render
multiple characters or glyphs at time, each with a unique <x,y> position,
so it was simply a matter of massaging the data into a format that would
allow us to use one of these functions.

I've split `xdraws' up into two functions. In the first pass with
`xmakeglyphfontspecs' it will iterate over all of the glyphs in a given
row and it will build up an array of corresponding XftGlyphFontSpec
records. Much of the old logic for resolving fonts for glyphs using Xft
and fontconfig went into this function.

The second pass is done with `xrenderglyphfontspecs' which contains the
old logic for determining colors, clearing the background, and finally
rendering the array of XftGlyphFontSpec records.

There's a couple of other things that have been improved by this patch.
For instance, the UTF-32 codepoints in the Line's were being re-encoded
back into UTF-8 strings to be passed to `xdraws' which in turn would then
decode back to UTF-32 to verify that the Font contained a matching glyph
for the code point. Next, the UTF-8 string was being passed to
`XftDrawStringUtf8' which internally mallocs a scratch buffer and decodes
back to UTF-32 and does the lookup of the glyphs all over again.

This patch gets rid of all of this redundant round-trip encoding and
decoding of characters to be rendered and only looks up the glyph index
once (per font) during the font resolution phase. So this is probably
what's responsible for the marginal improvements seen when kerning values
are kept to 1.0.

I imagine there are other performance improvements here too, not seen in
the above benchmarks, if the user has lots of non-ASCII code plane characters
on the screen, or several different fonts are being utilized during
screen redraw.

Anyway, if you see any problems, please let me know and I can fix them.
2015-05-07 12:03:44 +02:00
suigin 38af006b5e Changed type for UTF-32 codepoints from long to uint_least32_t 2015-05-06 08:15:41 +02:00
noname c990abfedf Fix empty selection highlighting bug.
When user clicks LMB, one character is selected, but will not be copied
to selection until the user moves cursor a bit. Therefore, the character
should not be highlighted as selected yet.

Before the patch, the trick was not to mark line as dirty to avoid
highlighting it. However, if user has already selected something and
clicks in line that contains selection, selclear sets the line as dirty
and one character is highlighted when it should not.

This patch replaces dirty trick with explicit check for sel.mode inside
selected().
2015-05-04 12:06:43 +02:00
noname 3cb7f27afe Fix indentation. 2015-05-04 12:00:10 +02:00
noname 1811b6030c Add enumeration for sel.mode
This patch also prevents sel.mode from increasing beyond 2. It is almost
impossible, but sel.mode may overflow if mouse is moved around for too
long while selecting.
2015-05-04 11:57:17 +02:00
noname 22571ea4e8 selnormalize: make special case explicit
Special case is when regular selection spans multiple lines.
Otherwise, just sort sel.ob.x and sel.ob.y.
2015-05-04 11:47:53 +02:00
noname 8751809aff selsnap: simplify SNAP_LINE case
Also make sure y never exceeds term.row-1 even if ATTR_WRAP is set for
some reason.
2015-05-04 11:41:55 +02:00
noname 765bb0fd14 Remove first argument of selsnap. 2015-05-04 11:16:08 +02:00
Jochen Sprickerhof 07ce96a3a0 Fix sigchld
Only wait for termination of the shell.
2015-05-04 10:57:40 +02:00
mvdan@mvdan.cc 190b94c7a2 len assignment is never used
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2015-04-27 10:10:30 +02:00
mvdan@mvdan.cc 4f21c41a1c Clarify calculation precedence for '&' and '?'
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2015-04-27 10:09:49 +02:00
mvdan@mvdan.cc 3a5053f6c1 Use %u for uint
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2015-04-27 10:09:15 +02:00
suigin 7ab6c92e18 Optimize memory footprint of line buffers 2015-04-27 10:05:14 +02:00
noname@inventati.org 0622ad9bad Make tputc, tsetchar and techo accept unicode 2015-04-27 09:50:40 +02:00
noname@inventati.org 21f765426c Change internal character representation. 2015-04-27 09:50:01 +02:00
noname@inventati.org 753fe862b1 Remove last parameter of utf8encode
This parameter was always UTF_SIZ, so it is better remove it and
use directly UTF_SIZ in it.
2015-04-27 08:59:45 +02:00
noname@inventati.org 61c35cd246 Use utf8len instead of utf8decode. 2015-04-27 08:58:37 +02:00
alp@alexpilon.ca 742a41d655 Make build shut up about system() without return value check.
st.c:1321:2: warning: ignoring return value of function declared with warn_unused_result attribute [-Wunused-result]
            system(cmd);
            ^~~~~~ ~~~

Debatable whether an error here should case exit(EXIT_FAILURE). Just
preserving the existing behaviour for now.
2015-04-27 08:57:51 +02:00
Roberto E. Vargas Caballero f36dd277a2 Merge remote-tracking branch 'origin/master' 2015-04-23 17:59:39 +02:00
Roberto E. Vargas Caballero 0d7448dabc Fix segmentation fault in strhandle()
We cannot pass strescseq.args[0] to atoi when nargs is zero,
because in this case it will be null.
2015-04-23 17:59:10 +02:00
Roberto E. Vargas Caballero b17aa18f7c Uses a &[] pointer loop instead of + pointer loop 2015-04-23 17:59:10 +02:00
noname@inventati.org 736685d641 Do not set terminal title based on stty arguments. 2015-04-23 17:59:10 +02:00
noname@inventati.org 89807ed453 Move common code to xloadcolor 2015-04-21 09:48:33 +02:00
noname@inventati.org 84c756b97e Use LEN(dc.col) instead of LEN(colorname).
LEN(colorname) may be below 256 for some configurations.
2015-04-21 08:13:46 +02:00
noname@inventati.org 2fdcc5e5f6 Remove WIN_REDRAW flag.
WIN_REDRAW flag was not used since introduction of Xdbe
in commit 94771d0588
2015-04-21 07:49:07 +02:00
noname@inventati.org ab69ea89b7 Place memset arguments in the correct order. 2015-04-20 09:29:24 +02:00
noname@inventati.org 5528280fae Remove explicit 'return' from 'void' functions. 2015-04-20 09:28:14 +02:00
noname@inventati.org 6dc2b546ec Increment accuaracy in drawtime calculation
This way is a bit more accurate.
2015-04-20 09:20:35 +02:00
noname@inventati.org c27c731b9f Monotonic clock cannot jump backwards.
The check was introduced back when st used gettimeofday.
The condition is also modified to increment the accuaracy of the
calculation.
2015-04-20 09:18:40 +02:00
noname@inventati.org 6ee56d6590 Place tlinelen type on separate line. 2015-04-20 08:30:49 +02:00
Roberto E. Vargas Caballero 215bdb2da3 Add tty line support
Not always is desirable to create a pseudo terminal, and some times
we want to open a terminal emulator over a tty line. With this new
patch is possible to do someting like:

	$ st -l /dev/ttyS0 115200

Without this option was needed to launch another terminal emulator
over st (for example minicom, picocom, cu, ...).
2015-04-15 10:52:44 +02:00
sin 56abffb4b6 Fix memmove() invocation with src/dst being NULL
This fixes a segmentation fault on some systems.
2015-04-15 10:51:00 +02:00
noname@inventati.org aff35af275 Use as command arguments the remaining parameters
This change allows execute st as 'st mutt' while it keeps the
compability with xterm and urxt.
2015-04-14 09:55:15 +02:00
Roberto E. Vargas Caballero 83e73c6242 Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-04-14 09:47:19 +02:00
Markus Wichmann 42fa1f5ce4 Implement most ICCCM rules for selection handling.
ICCCM mandates the use of real timestamps to interact with the
selection, to rule out race conditions if the clients are run at
different speeds. I have implemented the low hanging fruit, putting the
timestamps into text selection. Also, ICCCM mandates a check for whether
XSetSelectionOwner() worked. Not sure my version is correct, though.
2015-04-13 22:18:45 +02:00
Roberto E. Vargas Caballero 23ed12857f Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-04-13 22:01:40 +02:00
noname@inventati.org 9eb70a2d3e Do not use tmoveto in tputtab.
tmoveto resets CURSOR_WRAPNEXT.

Simple testcase:

for i in $(seq 1 200); do
	printf '\t.';
	usleep 100000;
	printf '\t@';
	usleep 100000;
done

In st executing this script causes @ and . to overwrite each other in
the last column.
2015-04-13 21:33:36 +02:00
noname@inventati.org 9619760e12 tresize: remove unnecessary if 2015-04-13 17:12:49 +02:00
noname@inventati.org a6af2cc469 Remove old TODO entry.
It probably refers to
http://lists.suckless.org/dev/1211/13427.html
and does not seem like a bug in st.
2015-04-13 17:06:11 +02:00
noname@inventati.org b94ad75e5d Remove 'titles' variable.
We do not free it until exit anyway.
2015-04-13 17:00:08 +02:00
noname@inventati.org e6dd0f825d Remove useless if in tstrsequence. 2015-04-13 15:17:24 +02:00
noname@inventati.org b0310fba5d Simplify tmoveto.
LIMIT returns value. This fact is already used in x2col and y2row.
2015-04-13 15:15:47 +02:00
noname@inventati.org 9d1495f9ee Fix typo.
It seems that LICENSE files are more common than LICENCE files.
At least this patch makes spelling consistent.
2015-04-13 14:26:01 +02:00
noname@inventati.org c569e3146e Remove 'slide' variable in tresize. 2015-04-13 10:18:08 +02:00
noname@inventati.org 39ae1a4de5 Move tresize comments around. 2015-04-13 09:26:03 +02:00
noname@inventati.org 6352502d64 tresize: move for loop outside if
There is no need to check that slide > 0 before executing loop.
If slide <= 0, loop stops immediately.
2015-04-13 09:21:03 +02:00
noname@inventati.org b9390a5496 Simplify loop condition. 2015-04-13 09:20:00 +02:00
noname@inventati.org d2937b05ae Remove unnecessary XFilterEvent call.
XFilterEvent usually filters KeyPress events according to input method.
At this point the window is not mapped. The only events that we process
are ConfigureNotify and MapNotify. They should not be filtered by input
method.
2015-04-13 09:17:06 +02:00
noname@inventati.org d3e0f3444b Use do..while in window mapping loop. 2015-04-13 09:15:42 +02:00
Omar Sandoval ecac5ee35e Make DECSCUSR thickness configurable 2015-04-10 23:43:05 +02:00
noname 93b54cfcc4 Use MAX macro where possible. 2015-04-10 23:34:06 +02:00
noname 6f5f770186 Remove 'xloadfontset' function.
It was used only once and its return value was ignored.
2015-04-10 23:31:53 +02:00
noname 6524f022f7 Remove keywords from function definitions. 2015-04-10 23:28:21 +02:00
noname 9305f3c184 Remove variable names from function declarations. 2015-04-10 23:28:16 +02:00
Roberto E. Vargas Caballero 5bb90125c8 Remove redundant control check
control was set, but it was not ever used because it was set
again some lines later.
2015-04-06 10:55:00 +02:00
noname 69d1fe06a9 Fixed STR sequence termination condition
ascii code may only be checked for characters that have length equal to
1, not width equal to 1
2015-04-06 10:52:47 +02:00
Roberto E. Vargas Caballero 288f80cb06 Remove strsep() call
strsep() is not a POSIX function, and it means that every system
needs different defines to expose it. If the prototype of strsep
is not exposed then an ugly int/pointer is done and it might mean
a crash. The best solution?, to remove the strsep and make a custom
loop. If C programmers cannot do this kind of loops without calling
a library function, then maybe we should move all the suckless
software to Java.
2015-03-20 07:29:28 +00:00
Roberto E. Vargas Caballero c9357a8edf Merge remote-tracking branch 'origin/master' 2015-03-19 08:36:50 +00:00
LemonBoy 580302f317 Support the DECSCUSR CSI escape sequence 2015-03-19 05:36:54 +00:00
Christoph Lohmann 246c3481d7 arg.h wasn't used for dist. 2015-03-16 22:17:30 +01:00
Alex Pilon b341e51351 Handle pasting of empty selection.
Otherwise, pasting the X11 primary selection when empty results an
error and Xlib forcibly exits.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-03-16 20:31:15 +01:00
Roberto E. Vargas Caballero 86d1e432a8 Support XA_STRING in notify request
Some programs can only deal with XA_STRING, and it makes impossible st
be able of copying to them. This patch makes st answer also to XA_STRING,
althought it sends utf8 strings. It is not a problem because moderm
applications must support utf8.
2015-03-15 18:07:46 +00:00
Christoph Lohmann c7e24e44c8 TODO: Fix fontconfig 2015-03-14 08:53:41 +01:00
Christoph Lohmann 5406e655da Add the new selection shortcuts to the manpage. 2015-03-14 08:52:37 +01:00
Christoph Lohmann 72d2accc22 Glibc wants me to use _DEFAULT_SOURCe. I do obey. 2015-03-14 08:43:57 +01:00
Christoph Lohmann 2fcfea1bf1 Add Mod + Shift + c/v and no selclear.
Thanks to Alex Pilon <alp@alexpilon.ca>!

Now there is a distinction between the primary and clipboard selection. With
Mod + Shift + c/v the clipboard is handled. The old Insert behavious does
reside.
2015-03-14 07:41:59 +01:00
Roberto E. Vargas Caballero b746816b78 Allow combinations with Backspace
XN_ANY_MOD makes that any combination of backspace will return always
DEL. This patch lets to X to decide which value returns.
2015-03-13 07:26:16 +00:00
Alexander Huemer 4f60751440 FAQ: fix wording 2015-03-11 17:27:55 +00:00
Ivan Delalande f5075a9e9d Backspace value shouldn't depend on keypad state 2015-03-11 17:25:48 +00:00
Christoph Lohmann c87d45466b Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-03-10 21:59:41 +01:00
Christoph Lohmann 28259f5750 St now does only set PRIMARY on selection.
http://standards.freedesktop.org/clipboards-spec/clipboards-latest.txt
2015-03-10 21:58:32 +01:00
Alexander Huemer adeb2e95d6 FAQ: fix wording 2015-03-10 20:56:25 +00:00
Christoph Lohmann 9494362d0b Fixing the C reading test.
This was a test to see if anyone actually reads what is submitted. The list of
people not contributing will be valuable in the future.
2015-03-10 21:11:04 +01:00
Christoph Lohmann cf1fcc4d96 Change the FAQ for the new Backspace behaviour. 2015-03-10 00:20:28 +01:00
Christoph Lohmann 230d0c8428 Finally resolving the backspace problem.
The majority now using the Linux behaviour. Minorities have to live in their
ghettos.
2015-03-10 00:00:44 +01:00
Christoph Lohmann b0bddc694a Add a hack to handle unknown chars in fontconfig.
The unicode long is added to the cache. So when fontconfig does fall back to
the default font (where there is no easy way to find this out from the
pattern) it isn't reloaded.
2015-03-09 23:16:03 +01:00
Johannes Postma 487bbb24d0 Update kdch1 definition to three octal digits.
ncurses wasn't able to detect the delete-character key as KEY_DC.  This
patch fixes that.

kdch1 was defined as "\0177", but terminfo(5) states:
	... characters may be given as three octal digits after a \.

The delete-character key is correctly defined in config.def.h.
2015-03-07 18:21:19 +00:00
Roberto E. Vargas Caballero 29619a1a35 Small improvements to the FAQ 2015-02-28 16:15:16 +00:00
Greg Reagle b8804f9f67 document keys in man page 2015-02-23 11:14:21 +01:00
Ivan Delalande 1b514048b2 Let curses do the dirty work for flash
Use the terminfo delay syntax ($<x>) in our flash capability to avoid
hardcoding a fixed delay in redraw() when called from tsetmode() with
DECSCNM.
We need to turn on the npc capability so that delays are made with
xon/xoff instead of padding characters.
2015-02-22 11:53:34 +00:00
Roberto E. Vargas Caballero 3604445ffc Comment default CC assignment
CC by default is cc, so the assignment was doing nothing, but
it was using non standard syntax, so some system (NetBSD) fail
to compile.
2015-02-22 10:59:26 +00:00
Roberto E. Vargas Caballero ac11bbb03b Update dates in LICENSE 2015-02-22 10:58:37 +00:00
Nils Reuße c5f1d74fd8 Update year in usage() 2015-02-15 17:46:15 +01:00
Nils Reuße 7dd24bfb4c Fix crash on font resize resize
if you keep downsizing your fontsize until either xw.ch or xw.cw gets 0,
st crashes, because there is an unchecked division in cresize.
2015-02-15 17:12:36 +01:00
Rian Hunter aba6c292af Correct shift amount on MODE_INSERT in tputc()
When MODE_INSERT is set we'd shift characters on the same
line forward before inserting our character in tputc().
This did not account for wide characters where width != 1.
This patch makes it so we shift the correct amount.
2015-02-05 20:28:00 +01:00
Rian Hunter 4d14d97547 Fix crash due to wide characters
In tputc(), when a character wasn't large enough to fit
on the current line, we would call tnewline() to place it on
the next line. Unfortunately, we weren't resetting our glyph
pointer and this caused memory corruption when a
wide character (width == 2) was being written. This patch
resets our glyph pointer after calls to tnewline().
2015-02-05 20:28:00 +01:00
Ivan Delalande 708b697ed7 Fix crash due to invalid timespec given to pselect
If blinktimeout is set to a value greater than 1000, pselect will
receive a timeout argument with tv_nsec greater than 1E9 (1 sec), and
fail, making st crash. This patch just ensures that the timespec
structure is correctly filled with a value properly decomposed between
tv_sec and tv_nsec.

Reported by JasonWoof on IRC. Thanks!
2014-12-23 16:20:59 +01:00
Ivan Delalande 09f5d98251 Trim trailing whitespaces in every selection case
Trailing whitespaces are trimmed when copying from normal selection and
rectangular selection on lines that have their last character included
or on the left of the selection. It leads to inconsistent behaviors when
copying the exact same text from the left and right window in
applications with vertical splits.
This patch solves this issue by always trimming the selection.
2014-11-19 18:53:17 +01:00
sin 4418939dd9 Call _exit() instead of exit() if exec*() fails
exit() will also unwind the atexit() functions.  This is bad
because if exec*() fails the process is in an inconsistent state.
2014-11-19 18:52:42 +01:00
Eric Pruitt bafbba56cd Check for presence of SHELL environment variable
- POSIX states the SHELL environment variable "... shall represent a
  pathname of the user's preferred command language interpreter." As
  such, st should check for its presence when deciding what shell to
  use; just as HOME can be defined to override one's passwd-defined home
  directory, a user should also be able to override their passwd-defined
  shell using the SHELL environment variable.
2014-11-11 19:20:56 +01:00
czarkoff@gmail.com 11625c7166 Replace character with U+FFFD if wcwidth() is -1
Helpful when new Unicode codepoints are not recognized by libc.
2014-11-03 22:52:58 +01:00
Quentin Rameau 008aae541b Avoid failing when embedding with a Window id of 0
I'd like to let st run with its own window when trying to embed it to a window with id 0 instead of exiting with an error.
2014-10-21 18:18:26 +02:00
Christoph Lohmann cd159883d1 Reverting smacs and rmacs to the xterm defaults.
These are needed by ncurses to correctly handle the switch between line
drawing. The changes to the alternative characterset code already fixed the
urwid hack.
2014-10-21 16:36:01 +02:00
Roberto E. Vargas Caballero f9fb620914 Do not set SHELL to utmp ever
SHELL must be set to the SHELL of the user, but it was possible set
it to utmp.
2014-10-15 19:42:20 +02:00
CustaiCo 86633ada91 patch for bell in st
The XBell() call currently used when a bell is recieved sends a message
to the X server, but if the X server doesn't know how to sound it,
it just gets ignored and I have not been able to find anywhere in x.org's
code a way to configure the action that the server does.

However, if you use XkbBell() then you can have a process listening for
the XkbBellNotifyEvent that is produced and either alert you visually or
play an audio file or whatever you want as your notification. You have
to include one more header file but the function seems to be compiled as
part of Xlib, at least on my installation.

CustaiCo
2014-10-13 19:15:52 +02:00
Roberto E. Vargas Caballero dcfe505d3c Use G1 for alternate charset
St has enacs, which must be printed if a program requires to use
the alternate charset (graphic charset), that in st case was to
select charset graphic for G1, but it was not useful
at all because smacs and rmacs were always redefining the value
of G0.
2014-10-08 11:35:45 +02:00
Roberto E. Vargas Caballero 88429cdcbf Add LS2 and LS3
These sequences are the equivalents of LS0 and LS1, but for G2 and
G3.
2014-10-08 11:33:36 +02:00
Roberto E. Vargas Caballero 0c8feecbf7 Fix SI and SO
SI (0x0F or ^O) means Shift In, and it selects G1 charset definition,
and SO (0x0E or ^N) means Shift Out, and it selects G0 charset
definition, but st was doing just the inverse.
2014-10-08 11:28:54 +02:00
Christoph Lohmann a7eef8f230 Removing an extra space. 2014-09-29 15:41:10 +02:00
Christoph Lohmann 63a07eb19c Minor style changes for the last patch. 2014-09-29 15:40:37 +02:00
Christoph Lohmann dc8c5c82aa Implementing xzoomreset.
Thanks mvdan@mvdan.cc for proposing this.
2014-09-29 15:38:21 +02:00
Roberto E. Vargas Caballero c7a945c408 Add missed names of charset sequences 2014-09-23 07:16:58 +02:00
Roberto E. Vargas Caballero 5afb3862ba Add support for utmp in st
St runs an interactive shell and not a login shell, and it means
that profile is not loaded. The default terminal configuration
in some system is not the correct for st, but since profile is
not loaded there is no way of getting a script configures the
correct values.

St doesn't update the utmp files, this is the job of another
suckless tool, utmp. Utmp also opens a login shell (it is the
logical behaviour when you create a new user record) it is a
good option execute utmp and then get a correct input in
utmp, wtmp and lastlog file, and execute the content of the
profile.
2014-09-23 07:12:41 +02:00
Roberto E. Vargas Caballero 0392d165d0 Remove indentation level in xdrawcursor 2014-09-09 05:51:36 +02:00
Ben Hendrickson 98a1085d0e Removing wrapping newlines from selection
When getting selected text, lines that were wrapped because of length
ought not include the wrapping newline in the selection.

This comes up, for example, when copying a bash command that is long
enough to wrap from the console and pasting it back into the console.
The extra newline breaks it.

Similiarly, changes behavior when trimming whitespace from the end of a
physical line to only do so if the line does not wrap. Otherwise we are
trimming whitespace from the middle of a logical line, which may change
its meaning.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-23 09:52:18 +02:00
Ivan Delalande 51466e019a Change the behavior of word snapping on delimiters
This makes any sequence of identical delimiters be considered a single
word in word-snapping mode. This seems more coherent for this mode and
is similar to what xterm does.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-21 17:50:31 +02:00
Ivan Delalande c490a60b80 Move calls to selsnap into selnormalize
This simplifies getbuttoninfo() and bpress(), and fixes a bug which made word
snapping behave incorrectly when a delimiter was at the beginning or end of
line.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-21 17:50:31 +02:00
Alexander Huemer 83dea7fd7b Improve readability of enum members
The 'left shift from one' notation of power of two integers is more
expressive than the result.

Signed-off-by: Alexander Huemer <alexander.huemer@xx.vu>
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-20 21:52:33 +02:00
Roberto E. Vargas Caballero e5f6736ee0 Add eschandle()
We already have a csihandle() function, where is located code about
CSI sequences, so it is logical do the same with ESC sequences.
This change helps to simplify tcontrol(), which has a complex flow
and should be rewritten.
2014-08-20 21:52:33 +02:00
Roberto E. Vargas Caballero a3549c2eec Improve execsh() and don't allow anonymous shells
This patch improves the shell selection on execsh and forbid
shell with users don't registered in the passwd file.
2014-08-20 09:03:44 +02:00
Roberto E. Vargas Caballero 8342036f98 Fix definition of CONTROLC0
DEL character is not thecnically talking a C0 control character,
although it has some common properties with them, so it is useful
for us consider it as C0. Before this patch DEL (\177), was not
ignored as it ought to be.
2014-08-19 12:57:44 +02:00
Roberto E. Vargas Caballero 9d9e049eac Make useful DEL in application mode
DEL key has to generate the sequence ^[P in application mode,
because such sequence means delete current character. It implies
that the character sent in keypad mode must be ^? (DEL character).
2014-08-19 12:57:43 +02:00
Quentin Carbonneaux 177d888dff reset the alt screen in treset
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-19 12:57:43 +02:00
Quentin Carbonneaux fa04911c91 simplify loop in tresize
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-19 12:57:43 +02:00
Alexander Huemer 1926305318 Simplify README
The term 'virtual terminal emulator' was broken. There is nothing
virtual about it, it's a terminal emulator.

Signed-off-by: Alexander Huemer <alexander.huemer@xx.vu>
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-18 12:12:26 +02:00
Roberto E. Vargas Caballero 8f3e6a577d Fix man page and usage()
Man page was repeating -f option, the second time instead of -i,
and this option was lost in usage() message. This patch also indent
the output of usage().
2014-08-17 20:49:33 +02:00
Roberto E. Vargas Caballero f8b4998b32 Convert VT102ID to a config variable
VT102ID is the sequence that the terminal returns when it is inquired
to identify itself. This value should be configurable in the same
way that another st parameters.
2014-08-15 15:00:48 +02:00
Roberto E. Vargas Caballero 6530025bca Fix portability problem in techo()
ISCONTROL chechks if a value is between 0 and 0x1f or
between 0x80 and 0x9f. Char signess depends of architecture
and compiler, so in some environment the second case is
always false (and wrong), Techo() calls ISCONTROL with a
char variable, whose type cannot be changed because tpuc()
expects a pointer to char, so the solution is to insert a
cast in the call to ISCONTROL.
2014-08-15 14:48:16 +02:00
noname d4a17316d3 Don't set dirty all lines because tswapcreen do it
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-10 22:22:42 +02:00
noname 20c4f12254 tresize return value is not used
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-08-10 22:16:21 +02:00
Roberto E. Vargas Caballero 821a6e00a5 Remove ul capability
This capability indicates that underscore '_' overstrike current
letter under the cursor. It means that you can generate a
underline 'b' using 'b^H_', because it writes a 'b' then backward
one characther and then overstrike '_'. St has not such behaviour,
so it is an error to have this capability.
2014-08-07 10:19:48 +02:00
Roberto E. Vargas Caballero 8de8ae3923 Unset mode when clearing regions
tclearregion() was clearing regions using spaces and the current
attributes of the terminal. It was correct with all the modes excepct
underline, because they didn't affect the space character, but in
the case of underline it was a problem. A easy way of seeing this
problem is writing this in the last line of the terminal:

	tput smul ; echo first; tput rmul; echo second; echo third

Fist was underlined, and second and third were not underlined, but
the spaces at the right of second was underlined becuause in the
previous scrool underline mode was set.
2014-08-07 10:11:38 +02:00
Roberto E. Vargas Caballero ec3268961d Add error message when child exits whit error
Master proccess was not showing any error message when the child
died with an error, and it was very confusing for the user (for
example with incorrect -e command).
2014-08-04 22:07:04 +02:00
Roberto E. Vargas Caballero 769d481807 Remove difference between fast and slow blinking
One blinking mode is good enough, and two is too much. The best aproach
is emulate the fast blinking with the slow blinking, that it is more
used.
It is removed the flag ATTR_FASTBLINK because it has not a different
meaning of ATTR_BLINK, so it is not needed.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-07-31 19:40:37 +02:00
Michael Forney b4dfa18124 Fix disabling of bold and fastblink
According to ECMA-48¹ 8.3.117, an attribute value of 21 is "doubly
underlined", while 22 is "normal colour or normal intensity (neither
bold nor faint)".

Additionally, 25 is "steady (not blinking)", which likely means neither
slow blink nor fast blink.

¹: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-07-26 10:13:11 +02:00
Wolfgang Corcoran-Mathe e8f3513bf4 Add info about Backspace and Delete to the FAQ
Here is a modest attempt at cleaning it up a little bit. I changed a
few phrases that seemed awkward, but I think the content is the same.

--
Wolfgang Corcoran-Mathe

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-07-26 10:11:08 +02:00
Roberto E. Vargas Caballero f210ea26c4 Add info about Backspace and Delete to the FAQ 2014-07-25 17:09:27 +02:00
Roberto E. Vargas Caballero 8306568bd0 Add information about librt and OpenBSD to the FAQ 2014-07-25 17:09:27 +02:00
Roberto E. Vargas Caballero 844cd7ce17 Add information about librt and OpenBSD to the FAQ 2014-07-24 19:50:38 +02:00
Roberto E. Vargas Caballero 8c5ba1cfb0 Add information about librt and OpenBSD to the FAQ 2014-07-21 17:44:31 +02:00
Wolfgang Corcoran-Mathe 3949aa7c5d Very minor grammar fixes in FAQ
Self-explanatory.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-07-21 17:44:30 +02:00
Weng Xuetian 84ceefe089 Fix st with input method.
XFilterEvent need to be called against every event, otherwise it would
missing some message in the xim protocol and misbehave on some im server.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-07-19 19:46:31 +02:00
Eric Pruitt b5d0a13c10 Changed inconsistent indent
- A line was indented using spaces despite the rest of the code using
  tabs.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-07-15 19:30:48 +02:00
Roberto E. Vargas Caballero 984c12d2a6 Add 8 bit version of DCS, APC, PM, OSC
DCS, APC, PM, OSC version for 7 bits environments already was implemented
in st.  This patch adds the 8 bit version of it.
2014-07-08 23:32:28 +02:00
Roberto E. Vargas Caballero da78629cf5 Add 8 bit version of HTS
HTS version for 7 bits environments already was implemented in st.
This patch adds the 8 bit version of it.
2014-07-08 23:32:28 +02:00
Roberto E. Vargas Caballero f5356d0185 Add 8 bit version of NEL
NEL version for 7 bits environments already was implemented in st.
This patch adds the 8 bit version of it.
2014-07-08 23:32:25 +02:00
Roberto E. Vargas Caballero bcbaf5d9be Add 8 bit version of DECID
DECID version for 7 bits environments already was implemented in st.
This patch adds the 8 bit version of it.
2014-07-08 23:28:10 +02:00
Anders Eurenius f796533b1b Render faint attribute
Faint text is implemented by allocating a new color at one-half
intensity of each of the r, g, b components, or if the text bold at the
same time, it is not made lighter.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2014-07-08 22:46:55 +02:00
Ivan Delalande 955923b38b Remove all strcmp and strlen calls on Glyph.c[]
There were a few occurrences of strcmp and strlen being called on Glyph.c[],
which is not always null-terminated (this actually depends on the last values in
the buffer s in ttyread()). This patch replace all the calls to strcmp with a
test on c[0] directly or a call to tlinelen, and the one to strlen with utf8len.
I also took the opportunity to refactor getsel and tdumpline.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-07-08 09:21:48 +02:00
Christoph Lohmann 0015e198bf Making surf compile again with rt.
The clock_gettime patch needs librt to be linked to surf.

Thanks _odie for the hint.
2014-06-30 17:33:43 +02:00
Anders Eurenius 1fc4afd1e6 Render struck-out attribute
Implement crossed-out text with an XftDrawRect call, similar to how
underline is implemented. The line is drawn at 2/3 of the font ascent,
which seems to work nicely in practice.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-27 14:07:22 +02:00
Anders Eurenius 21bd4f4f9d Render invisible attribute
Implement invisible mode by setting the foreground color to be the same
as the background color. Not rendering anything would also be an
alternative, but this seems less likely to cause surprises in
conjunction with any hacks.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-27 14:06:21 +02:00
Anders Eurenius 50e6355e0d Reorder and extend glyph attributes
Faint, invisible, struck and fast blink are added as glyph attributes.
Since there's an edit here, let's take the opportunity to reorder them
so that they correspond to the two's power of the corresponding escape
code. (just for neatness, let's hope that property never gets used for
anything.)

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-27 14:04:47 +02:00
Roberto E. Vargas Caballero 77569526c0 Remove CEIL macro
This macro was not correct in some cases, and it was used only in
one place, where we did'nt get any benefit in performance of in size,
so the macro is removed and ceilf is used instead of it. The only
function needed from math.h is ceilf, so this patch defines the
prototype of it instead of including math.h.
2014-06-26 12:37:06 +02:00
Ivan Delalande 19d095717f Fixed wrong nanosecond factor 10E6.
Commit 5edeec1 introduced a wrong factor for nanosecond computation, the correct
value is 1E6. Time and timeout values are 10 times less than they should be and
this cause high CPU usage.

Reported by pyroh on IRC. Thanks!

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-26 12:33:55 +02:00
FRIGN 5edeec1b20 Use monotonic clock to prevent timing issues
This patch replaces the gettimeofday()/timeval-system with
uses of clock_gettime() with a monolithic clock and timespec-structs.
gettimeofday() is not accurate and prone to jumps and POSIX.1-2008
marks it as obsolete. Read more here [0].

The patch should speak for itself and decreases the binary
size for me by almost 200K(!).

[0]: http://blog.habets.pp.se/2010/09/gettimeofday-should-never-be-used-to-measure-time

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-24 21:45:36 +02:00
Eric Pruitt 738f555f66 Fix typo in config.def.h
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-21 10:24:36 +02:00
Troy Sankey 58eaa998b3 update size hints on zoom
On font zooming (i.e. xzoom()), window size hints are not updated.  This
patch does that.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-21 10:03:41 +02:00
Silvan Jegen c2fd2754eb Refactor the innermost loop of the xdraws function
Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2014-06-15 12:12:23 +02:00
Hiltjo Posthuma 27b28f1dc2 FAQ: update typo and escape code for smkx
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-11 11:17:17 +02:00
Christoph Lohmann 587b443592 Style police. 2014-06-07 13:49:04 +02:00
Roberto E. Vargas Caballero 93661042a2 Simplify tdeftrans 2014-06-07 13:23:45 +02:00
FRIGN 18a05fdf43 Remove unnecessary typedef
This should also fix compiling-errors on OpenBSD,
as reported by Nils R. Thanks!

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-06 15:23:22 +02:00
Colona 5159d55c63 Refactor selsnap SNAP_WORD.
Refactor the SNAP_WORD part in selsnap, and fix a bug that caused the word
delimiters to be ignored if it was at the very beginning or end of a wrapped
line.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-05 21:14:45 +02:00
Colona 6fd887077e Fix rectangular selection.
selsort computes the wrong normalized coordinates when rectangular
selection is enabled, causing rectangular selection to only work
when going toward either the top left corner, or the bottom right
one.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-04 21:10:25 +02:00
Hiltjo Posthuma bb6dc33206 tiny cleanup
Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-04 21:09:07 +02:00
Colona 2323e962e6 Make selection consistent over line breaks.
Currently, selection is expanded to the end of the line over line breaks only in
regular selection mode, when the line in not empty and when going down and/or
right. This covers all the cases including word selection mode, with the
exception of rectangular selection because it would make this mode too rigid.
This adjustment is made in selsort so I renamed it to selnormalize to better
reflect what it does now.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-06-04 21:09:07 +02:00
Christoph Lohmann c6fcb78b3a Fixing color and refactor xsetcolorname.
By  the recommendation of FRIGN I refactored xsetcolorname to remove the
unnecessary r, g, b variables when allocating a new  color.  Colors  are
now freed and set to the new color. A die() should not happen here. Oth‐
erwise it is easy for applications to kill st. St should be resilent  to
malicious input.

Second  this  patch  standardises  the  naming  of  »color«. There is no
»colour« here. Maybe in some parts of the world.
2014-06-01 17:08:16 +02:00
Christoph Lohmann 8b4cfcea73 Revert "Refactor xsetcolorname()"
This reverts commit a32c5f5726.
2014-06-01 16:52:19 +02:00
FRIGN a32c5f5726 Refactor xsetcolorname()
I mainly improved the slightly off algorithm used to load colours in the 256-colour-space and
removed unnecessary local values (r,g,b,colour).
"colour" is not necessary as a punchbag for XftColorAlloc[Value,Name], as they don't mess with
the result-adress until they are absolutely sure everything worked out[0].

Being at it, I changed the error-returns for AllocValue to dies (just like in xloadcols()), as
a failure is most likely an OOM-situation you better catch early.
In case of an invalid name everything stays the same.

[0]: http://www.opensource.apple.com/source/X11libs/X11libs-40/libXft/libXft-2.1.13/src/xftcolor.c

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2014-06-01 16:20:22 +02:00
Balazs Kezes ba36d1394b Don't report release events for mouse wheel
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2014-06-01 15:57:03 +02:00
Christoph Lohmann ede83bd08b Fixing italic bold.
Thanks Felipe Spychalski <spychalski@gmail.com> for the patch!
2014-06-01 15:54:28 +02:00
Alexander 2411308bd2 Fixed copying empty lines inside selection.
The code was assuming that empty lines have implicit wrap-around attribute.

Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
2014-05-27 08:37:12 +02:00
Christoph Lohmann d03aa8d20b Fix some more LICENSE changes. 2014-05-24 21:27:54 +02:00
FRIGN 80d8051269 Add FRIGN to License, remove trailing whitespace
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2014-05-24 21:27:30 +02:00
Christoph Lohmann 488977c8ef Brightening is again on the TODO list. 2014-05-24 13:52:24 +02:00
Christoph Lohmann f4ebb3180f Fixing trailing whitespaces. 2014-05-24 13:48:44 +02:00
FRIGN 3544e354b2 Fix colour-model and simplify xloadcols()
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2014-05-24 13:47:00 +02:00
Hiltjo Posthuma cf890e5bf0 Allow mouse selection override using ShiftMask
Similar to xterm or urxvt holding shift before selecting text with the mouse
allows to override copying text. For example in tmux with "mode-mouse on" or
vim (compiled with --with-x), mc, htop, etc.

forceselmod in config.h sets the modifier to use this mode, by default
ShiftMask.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-05-14 07:48:25 +02:00
Christoph Lohmann bdb850a16a Redraw needs all dirty lines to have flash etc. work. 2014-05-09 17:12:58 +02:00
Colona e31829f659 End a sequence only on CAN, SUB, \a and C1s. 2014-05-09 10:25:29 +02:00
Colona 5e917ab287 Also clears ESC_START on interrupt characters during sequences.
Otherwise, the rest of the input is interpreted as a new escape
sequence.
For the ESC character, ESC_START is re-set in tcontrolcode.
2014-05-09 08:26:37 +02:00
noname 99fb365aa3 Consistent FALLTHROUGH comments. 2014-05-02 21:49:52 +02:00
Roberto E. Vargas Caballero 870f961c49 Fix displaying control code
Control code are never displayed. It is not important if graphic
charset is displayed or not.
2014-04-30 08:35:53 +02:00
Roberto E. Vargas Caballero 1629363f2d Remove ATTR_GFX and tselcs
ATTR_GFX was used long time ago to detect when terminal was in
graphic mode. Today graphic mode is implemented using a charset
pointer, so ATTR_GFX is not needed anymore because graphic
condition can be detected directly checking if current charset
is GRAPHICS C0.
2014-04-29 15:17:51 +02:00
noname 6b315558f8 Do not save cursor in tresize.
This patch fixes the bug introduced in
8f11e1cd03

To reproduce the bug:
1. Save cursor: printf '\e[s'
2. Load cursor: printf '\e[u'
3. Resize st window.
4. Load cursor again: printf '\e[u'
2014-04-29 15:17:50 +02:00
noname 5f91983541 Simplify selected(). 2014-04-28 18:49:45 +02:00
noname 9e3e8ce466 Do not export chscale and cwscale. 2014-04-28 18:49:05 +02:00
noname 0e439e5624 Simplify xunloadfonts. 2014-04-28 18:48:09 +02:00
noname 74962bf566 Remove one indentation level in getsel(). 2014-04-28 18:38:07 +02:00
noname 6681af165b Remove unused dump() function. 2014-04-28 18:38:07 +02:00
noname 1ae2745fd1 Add missing function prototypes. 2014-04-28 18:38:06 +02:00
noname a48f2be7f5 Use MODBIT in xseturgency. 2014-04-28 18:38:06 +02:00
noname 17fa1493ee Compute ena_sel as one expression. 2014-04-28 18:38:06 +02:00
Roberto E. Vargas Caballero a8a9e66a7d Simplify expressions in tputc() 2014-04-28 18:38:05 +02:00
Roberto E. Vargas Caballero 17290f493b Fix misplaced break
This misplaced break was causing an incorrect fall through
from DSR to DECSTBM.
2014-04-28 18:38:05 +02:00
Roberto E. Vargas Caballero 43d74ef362 Create a function for DEC test
Almost of the sequences execute their action in a separate function,
which is good because helps to read the full set of sequences
faster.
2014-04-28 18:38:05 +02:00
Roberto E. Vargas Caballero 3764f38fc8 Fix tputc control code handling
The patch 53105cf modified how control codes were detected, because
it tried to handle also C1 control codes (0x80-0x9f), that have
upper bit to 1, so they are multi byte character in utf8.
Code was checking the value of width in order to known that after
decoding the unicode point had a width of 1 byte, but it as incorrect
because this width is the columnb width.
2014-04-28 18:32:09 +02:00
Roberto E. Vargas Caballero 53105cf74f Remove repeated initialisation of term.esc
Once a sequence is completed term.esc must return to 0, so
instead of repeating this expression in all the cases is
better put it at the end of the block.
2014-04-27 11:30:21 +02:00
Roberto E. Vargas Caballero aa35bbd7a1 Cancel DCS with SUB, CAN, ESC or any CC1 code
From http://www.vt100.net/docs/vt510-rm/chapter4:

	*The VT510 ignores all following characters until it receives a
	 SUB, ST, or any other C1 control character.

So OSC, PM and APC sequence ends with a SUB (it cancels the sequence
and show a question mark as error), ST or any another C1 (8 bits)
code, or their C0 (7 bits) equivalent sequences (at this moment we
do not handle C1 codes, but we should). But it is also said that:

	Cancel  CAN
	1/8     Immediately cancels an escape sequence, control sequence,
		or device control string in progress. In this case, the
		VT510 does not display any error character.

	Escape  ESC
	1/11    Introduces an escape sequence. ESC also cancels any escape
		sequence, control sequence, or device control string in
		progress.
2014-04-27 11:30:13 +02:00
Markus Teich 704d12442e add break;s for last cases in switch statements 2014-04-27 10:34:57 +02:00
noname 02d2df5790 Do not eat ESC character if control string is not properly terminated.
Currently tputc handles the case of too long control string waiting for
the end of control string.

Another case is when there is ESC character is encountered but is not
followed by '\\'.  In this case st stops processing control string,
but ESC character is ignored.

After this patch st processes ESC characters in control strings properly.

Test case:
printf '\e]0;abc\e[1mBOLD\e[0m'

Also ^[\ is actually processed in the code that handles ST.
According to ECMA-048 ST stands for STRING TERMINATOR and is used to
close control strings.
2014-04-26 00:14:42 +02:00
noname c4b79b055d Fix for multibyte characters in techo.
Works for both signed and unsigned char.
2014-04-26 00:03:09 +02:00
noname 7f1e02e4db s/DSC/DCS/ DCS stands for DEVICE CONTROL STRING 2014-04-26 00:03:09 +02:00
noname 84f6dbffa5 Use xwrite instead of write. 2014-04-26 00:03:08 +02:00
noname 2d67f99d28 Remove unnecessary break 2014-04-26 00:03:08 +02:00
noname 4a8574b439 Comment fix. 2014-04-25 23:57:44 +02:00
Colona 8f11e1cd03 On terminal resize, clear the alt screen with its own cursor.
Currently the alternate screen get messed up on resize if it has
different colors or mode.
2014-04-25 23:57:44 +02:00
noname 844c503c80 Optimize tputtab.
Before this patch executing
	printf '\e[10000000000I'
or
	printf '\e[10000000000Z'
resulted in long delay.
2014-04-25 23:57:44 +02:00
noname 1b0b9759dc Use != instead of ^ for logical values.
sel.alt is only changed by
	sel.alt = IS_SET(MODE_ALTSCREEN);
2014-04-25 23:57:43 +02:00
noname 99d2d6007a Use BETWEEN macro in xsetcolorname and fix style. 2014-04-25 23:57:43 +02:00
Christoph Lohmann fe31a3f634 Conformity in the -g geometry handling.
Thanks to Yuri Karaban for suggesting this!

These changes make -g correspond to <cols>x<rows> and honor it so non-tiling
window managers can work with the size hints afterwards. It also adds a -i
flag to force the window size. This is needed so -g keeps being useful in dwm.
2014-04-25 22:34:24 +02:00
Roberto E. Vargas Caballero 6b7f63bac5 Simplify a bit more tdeletechar and tinsertblank
The large and repeated expression used in memmove to indirect
the line can be simplified using a pointer, that makes more
clear where begins and where ends the movement.
2014-04-25 17:25:59 +02:00
noname 80b32af794 Simplify tdeletechar and tinsertblank and fix memory corruption.
Current CSI parsing code uses strtol to parse arguments and allows them
to be negative. Negative argument is not properly handled in tdeletechar
and tinsertblank and results in memory corruption in memmove.

Reproduce with printf '\e[-500@'

Patch also removes special handling for corner case and simplifies
the code.

Removed
	term.dirty[term.c.y] = 1
because tclearregion sets dirty flag.
2014-04-25 17:17:48 +02:00
noname 16ac85bf54 Style fixes in tscrollup. 2014-04-23 20:38:04 +02:00
noname fe527aa508 Do not set dirty flag twice in tscrollup and tscrolldown. 2014-04-23 20:37:59 +02:00
noname 3afdb4ff04 Use tsetdirt in tscrollup and tscrolldown.
tscrollup and tscrolldown do not use tsetdirt, but their code is
equivalent to

        tsetdirt(orig, term.bot-n);
        tsetdirt(orig+n, term.bot);

tclearregion also marks cleared lines as dirty.
In tscrolldown it sets lines from term.bot-n+1 to term.bot dirty, and in
tscrollup it sets lines from orig to orig+n-1 dirty.

In both functions all lines from orig to term.bot are effectively set
dirty, but in tscrolldown lines from orig+n to term.bot are set dirty
twice, and in tscrollup lines from orig to term.bot-n are set dirty
twice.

These patches make it clear which lines are set dirty and sets them
dirty once in each funciton.
2014-04-23 20:35:16 +02:00
noname f9dc374ea0 Fix techo handling of control and multibyte characters.
techo compares signed char to '\x20'. Any character with code less then
'\x20' is treated as control character.  This way characters with MSB
set to 1 are considered control characters too.

Also this patch makes techo display DEL character as ^?.

To reprocuce the bug, enable echo mode using printf '\e[12l',
then type DEL character or any non-ASCII character.
2014-04-23 20:31:45 +02:00
noname fa19f241a3 Make xrealloc and xstrdup style consistent. 2014-04-23 15:39:04 +02:00
noname df1810dd8f Use BETWEEN in tsetchar. 2014-04-23 15:39:03 +02:00
noname ed855ea432 Use uint and uchar instead of unsigned int and unsigned char. 2014-04-23 15:39:03 +02:00
noname 68d97457ec Remove argument names from function prototypes. 2014-04-23 15:39:03 +02:00
noname 49672dac7b Style fix in tdumpsel. 2014-04-23 15:39:02 +02:00
noname f21e47f44a Use BETWEEN in tinsertblankline and tdeleteline. 2014-04-23 15:39:02 +02:00
Christoph Lohmann 87abc7cd59 It's 2014 now. 2014-04-22 19:22:58 +02:00
noname@inventati.org 1388870331 move MODBIT to Macros section
Patch moves MODBIT to macros section and uses it in tselcs.
2014-04-20 21:13:37 +02:00
noname@inventati.org 6b56cbf9cc misplaced parenthesis in LEN macro 2014-04-20 21:07:04 +02:00
Markus Teich 3269bf213d remove confusing SERRNO macro
I found the SERRNO Macro slightly confusing, since you have to look
it up, if you don't know it already. A web search showed it does
not seem to be any kind of standard. Also there was no reason in
the commit log when it was introduced in 2009. As you can see it
also leads to new patches, which don't use this macro (probably the
author did not know about it).
2014-04-20 21:00:46 +02:00
noname@inventati.org 4ad2fc7f18 Simplify techo
Remove special case for \e because it is handled well by "control code"
case.
2014-04-15 08:16:39 +02:00
noname@inventati.org dc74c4f729 typedefs instead of #defines
Replaced #defines with typedefs where possible, patch attached.
2014-04-15 08:14:46 +02:00
q@c9x.me b8d6171cb0 fix cursor handling when alt screen is disabled
I don't like this alt screen thing, but when
allowaltscreen == 0, the cursor is still saved
and restored after calling 'less' (or 'man').

This patch makes allowaltscreen == 0 usable.
2014-04-15 08:13:41 +02:00
Roberto E. Vargas Caballero ebb6e03201 Merge remote-tracking branch 'origin/master' into omaster 2014-04-15 08:11:47 +02:00
Christoph Lohmann f27b44b7c2 Removing two unnecessary gettimeofday(). 2014-04-11 18:11:25 +02:00
Toaster Toaster 3cb80840db Increment XSync consistency
This patch cleans up a style inconsistency.
2014-04-11 16:29:13 +02:00
Roberto E. Vargas Caballero c46d929fe1 Fix Backspace and Delete characters
Backspace key must generate the backspace character (\010) and
Delete key must generate the delete character (\0177). In
some systems the kernel configuration for erasing previous character
is \0177, so some programs (for example cat, ed, mail, ...), can not
understand the correct meaning of backspace. In this cases it is only
needed this command:

	stty erase 
2014-04-11 15:08:37 +02:00
14 changed files with 4353 additions and 3055 deletions

201
FAQ
View File

@ -1,12 +1,14 @@
## Why does st not handle utmp entries?
Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task.
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
It means that st doesnt have any terminfo entry on your system. Chances are
you did not `make install`. If you just want to test it without installing it,
you can manualy run `tic -s st.info`.
you can manually run `tic -sx st.info`.
## Nothing works, and nothing is said about an unknown terminal!
@ -15,19 +17,21 @@ you can manualy run `tic -s st.info`.
* Some programs dont complain about the lacking st description and default to
another terminal. In that case see the question about terminfo.
## I get some weird glitches/visual bug on _random program_!
Try launching it with a different TERM: $ TERM=xterm myapp. toe(1) will give
you a list of available terminals, but youll most likely switch between xterm,
st or st-256color. The default value for TERM can be changed in config.h
(TNAME).
## How do I scroll back up?
Using a terminal multiplexer.
* Using a terminal multiplexer.
* `st -e tmux` using C-b [
* `st -e screen` using C-a ESC
* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
## I would like to have utmp and/or scroll functionality by default
You can add the absolute patch of both programs in your config.h
file. You only have to modify the value of utmp and scroll variables.
* `st -e tmux` using C-b [
* `st -e screen` using C-a ESC
## Why doesn't the Del key work in some programs?
@ -37,23 +41,23 @@ Taken from the terminfo manpage:
are pressed, this information can be given. Note that it is not
possible to handle terminals where the keypad only works in
local (this applies, for example, to the unshifted HP 2621 keys).
If the keypad can be set to transmit or not transmit, tive these
If the keypad can be set to transmit or not transmit, give these
codes as smkx and rmkx. Otherwise the keypad is assumed to
always transmit.
In the st case smkx=E[?1hE= and rmkx=E[?1lE>, so it is mandatory that
applications which want to test against keypad keys, have to send these
applications which want to test against keypad keys send these
sequences.
But buggy applications like bash and irssi for example don't do this. A fast
But buggy applications (like bash and irssi, for example) don't do this. A fast
solution for them is to use the following command:
$ printf "\033?1h\033=" >/dev/tty
$ printf '\033[?1h\033=' >/dev/tty
or
$ echo $(tput smkx) >/dev/tty
$ tput smkx
In the case of bash readline is used. Readline has a different note in its
In the case of bash, readline is used. Readline has a different note in its
manpage about this issue:
enable-keypad (Off)
@ -84,8 +88,163 @@ If you are using zsh, then read the zsh FAQ
Putting these lines into your .zshrc will fix the problems.
## How can use meta in 8bit mode?
St support meta in 8bit mode, but the default terminfo entry doesn't
use this capability. If you want it, you have to use st-meta value
in TERM.
## How can I use meta in 8bit mode?
St supports meta in 8bit mode, but the default terminfo entry doesn't
use this capability. If you want it, you have to use the 'st-meta' value
in TERM.
## I cannot compile st in OpenBSD
OpenBSD lacks librt, despite it being mandatory in POSIX
<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_13>.
If you want to compile st for OpenBSD you have to remove -lrt from config.mk, and
st will compile without any loss of functionality, because all the functions are
included in libc on this platform.
## The Backspace Case
St is emulating the Linux way of handling backspace being delete and delete being
backspace.
This is an issue that was discussed in suckless mailing list
<https://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
terminal users wants its backspace to be how he feels it:
Well, I am going to comment why I want to change the behaviour
of this key. When ASCII was defined in 1968, communication
with computers was done using punched cards, or hardcopy
terminals (basically a typewriter machine connected with the
computer using a serial port). ASCII defines DELETE as 7F,
because, in punched-card terms, it means all the holes of the
card punched; it is thus a kind of 'physical delete'. In the
same way, the BACKSPACE key was a non-destructive backspace,
as on a typewriter. So, if you wanted to delete a character,
you had to BACKSPACE and then DELETE. Another use of BACKSPACE
was to type accented characters, for example 'a BACKSPACE `'.
The VT100 had no BACKSPACE key; it was generated using the
CONTROL key as another control character (CONTROL key sets to
0 b7 b6 b5, so it converts H (code 0x48) into BACKSPACE (code
0x08)), but it had a DELETE key in a similar position where
the BACKSPACE key is located today on common PC keyboards.
All the terminal emulators emulated the difference between
these keys correctly: the backspace key generated a BACKSPACE
(^H) and delete key generated a DELETE (^?).
But a problem arose when Linus Torvalds wrote Linux. Unlike
earlier terminals, the Linux virtual terminal (the terminal
emulator integrated in the kernel) returned a DELETE when
backspace was pressed, due to the VT100 having a DELETE key in
the same position. This created a lot of problems (see [1]
and [2]). Since Linux has become the king, a lot of terminal
emulators today generate a DELETE when the backspace key is
pressed in order to avoid problems with Linux. The result is
that the only way of generating a BACKSPACE on these systems
is by using CONTROL + H. (I also think that emacs had an
important point here because the CONTROL + H prefix is used
in emacs in some commands (help commands).)
From point of view of the kernel, you can change the key
for deleting a previous character with stty erase. When you
connect a real terminal into a machine you describe the type
of terminal, so getty configures the correct value of stty
erase for this terminal. In the case of terminal emulators,
however, you don't have any getty that can set the correct
value of stty erase, so you always get the default value.
For this reason, it is necessary to add 'stty erase ^H' to your
profile if you have changed the value of the backspace key.
Of course, another solution is for st itself to modify the
value of stty erase. I usually have the inverse problem:
when I connect to non-Unix machines, I have to press CONTROL +
h to get a BACKSPACE. The inverse problem occurs when a user
connects to my Unix machines from a different system with a
correct backspace key.
[1] http://www.ibb.net/~anne/keyboard.html
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
## But I really want the old grumpy behaviour of my terminal
Apply [1].
[1] https://st.suckless.org/patches/delkey
## Why do images not work in st using the w3m image hack?
w3mimg uses a hack that draws an image on top of the terminal emulator Drawable
window. The hack relies on the terminal to use a single buffer to draw its
contents directly.
st uses double-buffered drawing so the image is quickly replaced and may show a
short flicker effect.
Below is a patch example to change st double-buffering to a single Drawable
buffer.
diff --git a/x.c b/x.c
--- a/x.c
+++ b/x.c
@@ -732,10 +732,6 @@ xresize(int col, int row)
win.tw = col * win.cw;
win.th = row * win.ch;
- XFreePixmap(xw.dpy, xw.buf);
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
- DefaultDepth(xw.dpy, xw.scr));
- XftDrawChange(xw.draw, xw.buf);
xclear(0, 0, win.w, win.h);
/* resize to new width */
@@ -1148,8 +1144,7 @@ xinit(int cols, int rows)
gcvalues.graphics_exposures = False;
dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
&gcvalues);
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
- DefaultDepth(xw.dpy, xw.scr));
+ xw.buf = xw.win;
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
@@ -1632,8 +1627,6 @@ xdrawline(Line line, int x1, int y1, int x2)
void
xfinishdraw(void)
{
- XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w,
- win.h, 0, 0);
XSetForeground(xw.dpy, dc.gc,
dc.col[IS_SET(MODE_REVERSE)?
defaultfg : defaultbg].pixel);
## BadLength X error in Xft when trying to render emoji
Xft makes st crash when rendering color emojis with the following error:
"X Error of failed request: BadLength (poly request too large or internal Xlib length error)"
Major opcode of failed request: 139 (RENDER)
Minor opcode of failed request: 20 (RenderAddGlyphs)
Serial number of failed request: 1595
Current serial number in output stream: 1818"
This is a known bug in Xft (not st) which happens on some platforms and
combination of particular fonts and fontconfig settings.
See also:
https://gitlab.freedesktop.org/xorg/lib/libxft/issues/6
https://bugs.freedesktop.org/show_bug.cgi?id=107534
https://bugzilla.redhat.com/show_bug.cgi?id=1498269
The solution is to remove color emoji fonts or disable this in the fontconfig
XML configuration. As an ugly workaround (which may work only on newer
fontconfig versions (FC_COLOR)), the following code can be used to mask color
fonts:
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
Please don't bother reporting this bug to st, but notify the upstream Xft
developers about fixing this bug.

16
LICENSE
View File

@ -1,15 +1,19 @@
MIT/X Consortium License
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
© 2009 Anselm R Garbe <garbeam at gmail dot com>
© 2012 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
© 2012 Christoph Lohmann <20h at r-36 dot net>
© 2014-2020 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>
© 2008-2017 Anselm R Garbe <garbeam at gmail dot com>
© 2012-2017 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
© 2012-2016 Christoph Lohmann <20h at r-36 dot net>
© 2013 Eon S. Jeon <esjeon at hyunmu dot am>
© 2013 Alexander Sedov <alex0player at gmail dot com>
© 2013 Mark Edgar <medgar123 at gmail dot com>
© 2013 Eric Pruitt <eric.pruitt at gmail dot com>
© 2013-2014 Eric Pruitt <eric.pruitt at gmail dot com>
© 2013 Michael Forney <mforney at mforney dot org>
© 2013 Markus Teich <markus dot teich at stusta dot mhn dot de>
© 2013-2014 Markus Teich <markus dot teich at stusta dot mhn dot de>
© 2014-2015 Laslo Hunhold <dev at frign dot de>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),

View File

@ -1,60 +1,57 @@
# st - simple terminal
# See LICENSE file for copyright and license details.
.POSIX:
include config.mk
SRC = st.c
OBJ = ${SRC:.c=.o}
SRC = st.c x.c
OBJ = $(SRC:.c=.o)
all: options st
options:
@echo st build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}"
@echo "CFLAGS = $(STCFLAGS)"
@echo "LDFLAGS = $(STLDFLAGS)"
@echo "CC = $(CC)"
config.h:
cp config.def.h config.h
.c.o:
@echo CC $<
@${CC} -c ${CFLAGS} $<
$(CC) $(STCFLAGS) -c $<
${OBJ}: config.h config.mk
st.o: config.h st.h win.h
x.o: arg.h config.h st.h win.h
st: ${OBJ}
@echo CC -o $@
@${CC} -o $@ ${OBJ} ${LDFLAGS}
$(OBJ): config.h config.mk
st: $(OBJ)
$(CC) -o $@ $(OBJ) $(STLDFLAGS)
clean:
@echo cleaning
@rm -f st ${OBJ} st-${VERSION}.tar.gz
rm -f st $(OBJ) st-$(VERSION).tar.gz
dist: clean
@echo creating dist tarball
@mkdir -p st-${VERSION}
@cp -R LICENSE Makefile README config.mk config.def.h st.info st.1 ${SRC} st-${VERSION}
@tar -cf st-${VERSION}.tar st-${VERSION}
@gzip st-${VERSION}.tar
@rm -rf st-${VERSION}
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 $(SRC)\
st-$(VERSION)
tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
rm -rf st-$(VERSION)
install: all
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin
@cp -f st ${DESTDIR}${PREFIX}/bin
@chmod 755 ${DESTDIR}${PREFIX}/bin/st
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
@sed "s/VERSION/${VERSION}/g" < st.1 > ${DESTDIR}${MANPREFIX}/man1/st.1
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/st.1
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.
@tic -s st.info
uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
@rm -f ${DESTDIR}${PREFIX}/bin/st
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
@rm -f ${DESTDIR}${MANPREFIX}/man1/st.1
rm -f $(DESTDIR)$(PREFIX)/bin/st
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
.PHONY: all options clean dist install uninstall

4
README
View File

@ -1,6 +1,6 @@
st - simple terminal
--------------------
st is a simple virtual terminal emulator for X which sucks less.
st is a simple terminal emulator for X which sucks less.
Requirements
@ -24,7 +24,7 @@ Running st
If you did not install st with make clean install, you must compile
the st terminfo entry with the following command:
tic -s st.info
tic -sx st.info
See the man page for additional details.

3
TODO
View File

@ -11,13 +11,14 @@ code & interface
drawing
-------
* add diacritics support to xdraws()
* switch to a suckless font drawing library
* make the font cache simpler
* add better support for brightening of the upper colors
bugs
----
* fix shift up/down (shift selection in emacs)
* fix -e handling
* remove DEC test sequence when appropriate
misc

39
arg.h
View File

@ -10,8 +10,8 @@ extern char *argv0;
/* use main(int argc, char *argv[]) */
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
argv[0] && argv[0][1]\
&& argv[0][0] == '-';\
argv[0] && argv[0][0] == '-'\
&& argv[0][1];\
argc--, argv++) {\
char argc_;\
char **argv_;\
@ -21,43 +21,30 @@ extern char *argv0;
argc--;\
break;\
}\
for (brk_ = 0, argv[0]++, argv_ = argv;\
argv[0][0] && !brk_;\
argv[0]++) {\
int i_;\
for (i_ = 1, brk_ = 0, argv_ = argv;\
argv[0][i_] && !brk_;\
i_++) {\
if (argv_ != argv)\
break;\
argc_ = argv[0][0];\
argc_ = argv[0][i_];\
switch (argc_)
/* Handles obsolete -NUM syntax */
#define ARGNUM case '0':\
case '1':\
case '2':\
case '3':\
case '4':\
case '5':\
case '6':\
case '7':\
case '8':\
case '9'
#define ARGEND }\
}
#define ARGC() argc_
#define ARGNUMF(base) (brk_ = 1, estrtol(argv[0], (base)))
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
((x), abort(), (char *)0) :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(brk_ = 1, (argv[0][i_+1] != '\0')?\
(&argv[0][i_+1]) :\
(argc--, argv++, argv[0])))
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
(char *)0 :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(brk_ = 1, (argv[0][i_+1] != '\0')?\
(&argv[0][i_+1]) :\
(argc--, argv++, argv[0])))
#endif

View File

@ -5,31 +5,56 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=false";
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static int borderpx = 2;
static char shell[] = "/bin/sh";
/* Kerning / character bounding-box mutlipliers */
float cwscale = 1.0;
float chscale = 1.0;
/*
* 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: " `'\"()[]{}"
* More advanced example: L" `'\"()[]{}"
*/
static char worddelimiters[] = " ";
wchar_t *worddelimiters = L" ";
/* selection timeouts (in milliseconds) */
static unsigned int doubleclicktimeout = 300;
static unsigned int tripleclicktimeout = 600;
/* alt screens */
static bool allowaltscreen = true;
int allowaltscreen = 1;
/* frames per second st should at maximum draw to the screen */
static unsigned int xfps = 120;
static unsigned int actionfps = 30;
/* 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;
/*
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
@ -37,17 +62,36 @@ static unsigned int actionfps = 30;
*/
static unsigned int blinktimeout = 800;
/*
* thickness of underline and bar cursors
*/
static unsigned int cursorthickness = 2;
/*
* bell volume. It must be a value between -100 and 100. Use 0 for disabling
* it
*/
static int bellvolume = 0;
/* TERM value */
static char termname[] = "st-256color";
static unsigned int tabspaces = 8;
/* default TERM value */
char *termname = "st-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;
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
@ -75,46 +119,86 @@ static const char *colorname[] = {
/* more colors can be added after 255 to use with DefaultXX */
"#cccccc",
"#555555",
};
/*
* Default colors (colorname index)
* foreground, background, cursor
* foreground, background, cursor, reverse cursor
*/
static unsigned int defaultfg = 7;
static unsigned int defaultbg = 0;
unsigned int defaultfg = 7;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
/*
* 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.
* Default shape of cursor
* 2: Block ("")
* 4: Underline ("_")
* 6: Bar ("|")
* 7: Snowman ("")
*/
static unsigned int defaultitalic = 11;
static unsigned int defaultunderline = 7;
static unsigned int cursorshape = 2;
/* Internal mouse shortcuts. */
/* Beware that overloading Button1 will disable the selection. */
static Mousekey mshortcuts[] = {
/* button mask string */
{ Button4, XK_ANY_MOD, "\031" },
{ Button5, XK_ANY_MOD, "\005" },
/*
* 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;
/*
* Internal mouse shortcuts.
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
/* mask button function argument release */
{ 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} },
{ MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} },
{ MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} },
{ 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} },
{ MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} },
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
};
/*
@ -132,12 +216,8 @@ static Shortcut shortcuts[] = {
* * 0: no value
* * > 0: cursor application mode enabled
* * < 0: cursor application mode disabled
* crlf value
* * 0: no value
* * > 0: crlf mode is enabled
* * < 0: crlf mode is disabled
*
* Be careful with the order of the definitons because st searchs in
* 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.
*/
@ -154,203 +234,221 @@ static KeySym mappedkeys[] = { -1 };
*/
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.
*/
static Key key[] = {
/* keysym mask string appkey appcursor crlf */
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1, 0},
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1, 0},
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1, 0},
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1, 0},
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0, 0},
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0},
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0, 0},
{ XK_KP_End, ControlMask, "\033[J", -1, 0, 0},
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0, 0},
{ XK_KP_End, ShiftMask, "\033[K", -1, 0, 0},
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0, 0},
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0, 0},
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0, 0},
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0, 0},
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0, 0},
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0},
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0, 0},
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0, 0},
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0, 0},
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0},
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0, -1},
{ XK_KP_Enter, XK_ANY_MOD, "\r\n", -1, 0, +1},
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0, 0},
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0, 0},
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0, 0},
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0, 0},
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0, 0},
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0, 0},
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0, 0},
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0, 0},
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0, 0},
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0, 0},
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0, 0},
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0, 0},
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0, 0},
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0, 0},
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0, 0},
{ XK_Up, ControlMask, "\033[1;5A", 0, 0, 0},
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0, 0},
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1, 0},
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1, 0},
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0, 0},
{ XK_Down, ControlMask, "\033[1;5B", 0, 0, 0},
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0, 0},
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1, 0},
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1, 0},
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0, 0},
{ XK_Left, ControlMask, "\033[1;5D", 0, 0, 0},
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0, 0},
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1, 0},
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1, 0},
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0, 0},
{ XK_Right, ControlMask, "\033[1;5C", 0, 0, 0},
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0, 0},
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1, 0},
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1, 0},
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0, 0},
{ XK_Return, Mod1Mask, "\033\r", 0, 0, -1},
{ XK_Return, Mod1Mask, "\033\r\n", 0, 0, +1},
{ XK_Return, XK_ANY_MOD, "\r", 0, 0, -1},
{ XK_Return, XK_ANY_MOD, "\r\n", 0, 0, +1},
{ XK_Insert, ShiftMask, "\033[4l", -1, 0, 0},
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0, 0},
{ XK_Insert, ControlMask, "\033[L", -1, 0, 0},
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0, 0},
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0},
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0},
{ XK_Delete, ControlMask, "\033[M", -1, 0, 0},
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0, 0},
{ XK_Delete, ShiftMask, "\033[2K", -1, 0, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0},
{ XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0},
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0},
{ XK_Home, ShiftMask, "\033[2J", 0, -1, 0},
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0},
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1, 0},
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0},
{ XK_End, ControlMask, "\033[J", -1, 0, 0},
{ XK_End, ControlMask, "\033[1;5F", +1, 0, 0},
{ XK_End, ShiftMask, "\033[K", -1, 0, 0},
{ XK_End, ShiftMask, "\033[1;2F", +1, 0, 0},
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0, 0},
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0, 0},
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0, 0},
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0},
{ XK_Next, ControlMask, "\033[6;5~", 0, 0, 0},
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0, 0},
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0},
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0, 0},
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0, 0},
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0, 0},
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0, 0},
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0, 0},
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0, 0},
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0, 0},
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0, 0},
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0, 0},
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0, 0},
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0, 0},
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0, 0},
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0, 0},
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0, 0},
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0, 0},
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0, 0},
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0, 0},
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0, 0},
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0, 0},
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0, 0},
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0, 0},
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0, 0},
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0, 0},
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0, 0},
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0, 0},
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0, 0},
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0, 0},
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0, 0},
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0, 0},
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0, 0},
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0, 0},
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0, 0},
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0, 0},
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0, 0},
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0, 0},
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0, 0},
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0, 0},
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0, 0},
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0, 0},
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0, 0},
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0, 0},
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0, 0},
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0, 0},
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0, 0},
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0, 0},
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0, 0},
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0, 0},
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0, 0},
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0, 0},
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0, 0},
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0, 0},
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0, 0},
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0, 0},
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0, 0},
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0, 0},
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0, 0},
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0, 0},
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0, 0},
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0, 0},
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0, 0},
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0, 0},
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0, 0},
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0, 0},
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0, 0},
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0, 0},
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0, 0},
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0, 0},
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0, 0},
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0, 0},
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0, 0},
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0, 0},
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0, 0},
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0, 0},
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0, 0},
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0, 0},
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0, 0},
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0, 0},
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0, 0},
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0, 0},
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0, 0},
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0, 0},
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0, 0},
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0, 0},
{ XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0, 0},
{ XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0, 0},
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0, 0},
/* keysym mask string appkey appcursor */
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
{ XK_KP_End, ControlMask, "\033[J", -1, 0},
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_KP_End, ShiftMask, "\033[K", -1, 0},
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0},
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0},
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
{ XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
{ XK_Up, ControlMask, "\033[1;5A", 0, 0},
{ XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
{ XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
{ XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0},
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
{ XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
{ XK_Down, ControlMask, "\033[1;5B", 0, 0},
{ XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
{ XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
{ XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0},
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
{ XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
{ XK_Left, ControlMask, "\033[1;5D", 0, 0},
{ XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
{ XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
{ XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0},
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
{ XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
{ XK_Right, ControlMask, "\033[1;5C", 0, 0},
{ XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
{ XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
{ XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
{ XK_Return, Mod1Mask, "\033\r", 0, 0},
{ XK_Return, XK_ANY_MOD, "\r", 0, 0},
{ XK_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_Insert, ControlMask, "\033[L", -1, 0},
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_Delete, ControlMask, "\033[M", -1, 0},
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
{ XK_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_End, ControlMask, "\033[J", -1, 0},
{ XK_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_End, ShiftMask, "\033[K", -1, 0},
{ XK_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0},
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_Next, ControlMask, "\033[6;5~", 0, 0},
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
{ XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
{ XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
};
/*
@ -360,8 +458,15 @@ static Key key[] = {
* 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{|}~";

View File

@ -1,28 +1,35 @@
# st version
VERSION = 0.5
VERSION = 0.8.4
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
MANPREFIX = $(PREFIX)/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
PKG_CONFIG = pkg-config
# includes and libs
INCS = -I. -I/usr/include -I${X11INC} \
`pkg-config --cflags fontconfig` \
`pkg-config --cflags freetype2`
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil -lXext -lXft \
`pkg-config --libs fontconfig` \
`pkg-config --libs freetype2`
INCS = -I$(X11INC) \
`$(PKG_CONFIG) --cflags fontconfig` \
`$(PKG_CONFIG) --cflags freetype2`
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2`
# flags
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_XOPEN_SOURCE=600
CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS}
LDFLAGS += -g ${LIBS}
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
STLDFLAGS = $(LIBS) $(LDFLAGS)
# OpenBSD:
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
# `$(PKG_CONFIG) --libs fontconfig` \
# `$(PKG_CONFIG) --libs freetype2`
# compiler and linker
CC ?= cc
# CC = c99

129
st.1
View File

@ -3,22 +3,50 @@
st \- simple terminal
.SH SYNOPSIS
.B st
.RB [ \-a ]
.RB [ \-aiv ]
.RB [ \-c
.IR class ]
.RB [ \-f
.IR font ]
.RB [ \-g
.IR geometry ]
.RB [ \-n
.IR name ]
.RB [ \-o
.IR file ]
.RB [ \-t
.IR iofile ]
.RB [ \-T
.IR title ]
.RB [ \-w
.RB [ \-t
.IR title ]
.RB [ \-l
.IR line ]
.RB [ \-w
.IR windowid ]
.RB [ \-v ]
.RB [ \-e
.IR command ...]
.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.
@ -36,33 +64,101 @@ defines the
to use when st is run.
.TP
.BI \-g " geometry"
defines the X11 geometry string, which will fixate the height and width of st.
The form is [=][<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>]. See
defines the X11 geometry string.
The form is [=][<cols>{xX}<rows>][{+-}<xoffset>{+-}<yoffset>]. See
.BR XParseGeometry (3)
for further details.
.TP
.BI \-o " file"
.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 file.
.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
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 " program " [ " arguments " "... ]"
.BI \-e " command " [ " arguments " "... ]"
st executes
.I program
.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
@ -72,7 +168,10 @@ 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 tabbed (1),
.BR utmp (1),
.BR stty (1),
.BR scroll (1)
.SH BUGS
See the TODO file in the distribution.

4080
st.c

File diff suppressed because it is too large Load Diff

125
st.h Normal file
View File

@ -0,0 +1,125 @@
/* 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 != (b).mode || (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 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(char *, char *, 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(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;

52
st.info
View File

@ -1,5 +1,5 @@
st| simpleterm,
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
st-mono| simpleterm monocolor,
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
am,
bce,
bel=^G,
@ -10,7 +10,7 @@ st| simpleterm,
civis=\E[?25l,
clear=\E[H\E[2J,
cnorm=\E[?12l\E[?25h,
colors#8,
colors#2,
cols#80,
cr=^M,
csr=\E[%i%p1%d;%p2%dr,
@ -25,6 +25,7 @@ st| simpleterm,
cuu=\E[%p1%dA,
dch=\E[%p1%dP,
dch1=\E[P,
dim=\E[2m,
dl=\E[%p1%dM,
dl1=\E[M,
ech=\E[%p1%dX,
@ -32,7 +33,7 @@ st| simpleterm,
el=\E[K,
el1=\E[1K,
enacs=\E)0,
flash=\E[?5h\E[?5l,
flash=\E[?5h$<80/>\E[?5l,
fsl=^G,
home=\E[H,
hpa=\E[%i%p1%dG,
@ -142,14 +143,13 @@ st| simpleterm,
khome=\E[1~,
kil1=\E[2;5~,
krmir=\E[2;2~,
kich1=\E[2~,
knp=\E[6~,
kmous=\E[M,
kpp=\E[5~,
lines#24,
mir,
msgr,
ncv#3,
npc,
op=\E[39;49m,
pairs#64,
mc0=\E[i,
@ -158,6 +158,7 @@ st| simpleterm,
rc=\E8,
rev=\E[7m,
ri=\EM,
rin=\E[%p1%dT,
ritm=\E[23m,
rmacs=\E(B,
rmcup=\E[?1049l,
@ -168,13 +169,8 @@ st| simpleterm,
rs1=\Ec,
rs2=\E[4l\E>\E[?1034l,
sc=\E7,
setab=\E[4%p1%dm,
setaf=\E[3%p1%dm,
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
sgr0=\E[0m,
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,
sitm=\E[3m,
sgr0=\E[0m,
smacs=\E(0,
smcup=\E[?1049h,
smir=\E[4h,
@ -183,16 +179,36 @@ st| simpleterm,
smul=\E[4m,
tbc=\E[3g,
tsl=\E]0;,
ul,
xenl,
vpa=\E[%i%p1%dd,
# XTerm extensions
rmxx=\E[29m,
smxx=\E[9m,
# disabled rep for now: causes some issues with older ncurses versions.
# rep=%p1%c\E[%p2%{1}%-%db,
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
Tc,
Ms=\E]52;%p1%s;%p2%s\007,
Se=\E[2 q,
Ss=\E[%p1%d q,
st| simpleterm,
use=st-mono,
colors#8,
setab=\E[4%p1%dm,
setaf=\E[3%p1%dm,
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
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,
use=st,
ccc,
colors#256,
oc=\E]104\007,
pairs#32767,
# Nicked from xterm-256color
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,
@ -211,3 +227,13 @@ st-meta-256color| simpleterm with meta key and 256 colors,
smm=\E[?1034h,
rs2=\E[4l\E>\E[?1034h,
is2=\E[4l\E>\E[?1034h,
st-bs| simpleterm with backspace as backspace,
use=st,
kbs=\010,
kdch1=\177,
st-bs-256color| simpleterm with backspace as backspace and 256colors,
use=st-256color,
kbs=\010,
kdch1=\177,

39
win.h Normal file
View File

@ -0,0 +1,39 @@
/* See LICENSE for license details. */
enum win_mode {
MODE_VISIBLE = 1 << 0,
MODE_FOCUSED = 1 << 1,
MODE_APPKEYPAD = 1 << 2,
MODE_MOUSEBTN = 1 << 3,
MODE_MOUSEMOTION = 1 << 4,
MODE_REVERSE = 1 << 5,
MODE_KBDLOCK = 1 << 6,
MODE_HIDE = 1 << 7,
MODE_APPCURSOR = 1 << 8,
MODE_MOUSESGR = 1 << 9,
MODE_8BIT = 1 << 10,
MODE_BLINK = 1 << 11,
MODE_FBLINK = 1 << 12,
MODE_FOCUS = 1 << 13,
MODE_MOUSEX10 = 1 << 14,
MODE_MOUSEMANY = 1 << 15,
MODE_BRCKTPASTE = 1 << 16,
MODE_NUMLOCK = 1 << 17,
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|MODE_MOUSEMANY,
};
void xbell(void);
void xclipcopy(void);
void xdrawcursor(int, int, Glyph, int, int, Glyph);
void xdrawline(Line, int, int, int);
void xfinishdraw(void);
void xloadcols(void);
int xsetcolorname(int, const char *);
void xsettitle(char *);
int xsetcursor(int);
void xsetmode(int, unsigned int);
void xsetpointermotion(int);
void xsetsel(char *);
int xstartdraw(void);
void xximspot(int, int);

2049
x.c Normal file

File diff suppressed because it is too large Load Diff