187 Commits
wchar ... 0.7

Author SHA1 Message Date
6e79e8357e 0.7 release 2016-08-11 16:25:58 +02:00
308bfbf6be Change who's expanding tabs. 2016-07-20 13:56:15 +02:00
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
2251f6465a Add comment about tabspaces.
st.info needs to be changed too, when tabspaces are changed.
2016-07-20 13:00:43 +02:00
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
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
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
66556d9670 Remove stupid assignation in memcpy() 2016-04-15 07:58:26 +02:00
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
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
6d8f85232e I like empty lines. 2016-03-08 13:55:22 +01:00
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
30440295bc xtermclear() is now done by xdrawglyphfontspecs()
Thanks Ton van den Heuvel for the proposal!
2016-03-07 14:33:05 +01:00
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
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
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
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
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
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
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
9031e228ce Height is height. 2016-01-14 23:19:03 +01:00
610723a58f Bump year. 2016-01-01 14:18:43 +01:00
ff241199ed Fixing the XClassHint setting in st. 2015-12-20 01:43:32 +01:00
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
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
00873e65ee Introduce lim in all ttywrite() checks. 2015-11-06 20:46:23 +01:00
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
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
e2aa03e6b7 Now the Shortcuts are more consistent.
Keep the debile happy.
2015-10-31 09:29:04 +01:00
f56c58a968 fix bug where first selection snaps to lines 2015-10-11 11:44:34 +02:00
293f573efd Fix the cursor colors selection
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-10-06 17:36:02 +02:00
2ea02c937e Normalize the whole color selection in xdrawcursor. 2015-10-06 00:21:44 +02:00
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
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
52d0e82df7 Snowman is everywhere. 2015-10-05 22:59:04 +02:00
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
f7b80caebe The definition of the reverse cursor is now up to the user. 2015-10-05 22:38:19 +02:00
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
91c70213d1 When the cursor is moved, clear the selection. 2015-10-05 21:18:34 +02:00
2677296147 Reverse the cursor on selection. 2015-10-05 21:06:42 +02:00
5ece2b5f4a More style changes. We forgot some switches. 2015-10-05 20:48:24 +02:00
2bef36ab81 Small style change. 2015-10-05 20:08:21 +02:00
1682484327 There's no need for libXext to compile st. 2015-09-28 20:08:58 +02:00
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
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
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
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
a1ed5071e5 Change Pause to Break in shortcut for serial break 2015-09-08 17:02:15 +02:00
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
1f087aa8b7 Add key to send a break to the serial line 2015-09-08 12:10:11 +02:00
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
aa5d4c3b34 Making st.1 more descriptive about -l and fix -l in st.c. 2015-09-07 22:59:05 +02:00
080a5ae425 Fix the st manpage for -l line. 2015-09-07 20:00:49 +02:00
9eeb4e1ea2 Reordering and adding control codes.
For completeness and documentation add all C1 control codes.
2015-08-31 15:26:21 +02:00
0c94f8621b Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-08-30 11:29:23 +02:00
0d838b7243 Don't read if we chunked the input data. 2015-08-30 11:28:35 +02:00
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
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
ee5cad439b Adding mouse colour/shape settings 2015-07-28 12:21:11 +02:00
dc33d1d66e Adding -T to the usage too. 2015-07-24 18:25:33 +02:00
b5e29cce52 Add -T, as recommended by Dmitrij D. Czarkoff 2015-07-24 18:24:10 +02:00
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
1d348e98e3 added note about the low precedence of shell to config.def.h 2015-07-24 08:15:55 +02:00
62756fdb49 Fix style in execsh 2015-07-24 07:44:34 +02:00
d032b61597 Make the comment for the IM XFilter more understandable. 2015-07-10 14:31:40 +02:00
684c72d05e Return style unification. 2015-07-10 14:30:37 +02:00
b823f57fa0 Aligning the macros. 2015-07-10 14:21:52 +02:00
684f0a0729 Unix end of file. 2015-07-10 14:19:52 +02:00
d3c7b6fb73 No inline declarations please. 2015-07-10 14:19:31 +02:00
41f70a1cff Typo and the missing incr atom from the patches. 2015-07-10 14:17:51 +02:00
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
f8c6e7d041 Implement INCR transfers in the clipboard. 2015-07-10 14:10:17 +02:00
539afe3af1 Update LICENSE
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-07-10 13:59:08 +02:00
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
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
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
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
92e092efe6 Commit to push the 0.6 release. 2015-07-07 22:26:44 +02:00
5f48e89716 Revert "Remove unnecessary XFilterEvent call."
This reverts commit d2937b05aed9cee8d6651cd806d31682a853c773.
2015-07-02 11:11:55 +02:00
bdd649a102 do not truncate font size when zooming 2015-06-19 11:49:13 +02:00
71fa10f613 Revert "Optimize memory footprint of line buffers"
This reverts commit 7ab6c92e18d468968811256e808b02309c160a22.
We need 32 bits for real color support.
2015-06-03 08:07:55 +02:00
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
c03548750b Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-05-15 07:51:58 +02:00
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
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
980991fa6e Fix the new -e handling. An empty cmd has to work for backwards compatibility. 2015-05-10 15:19:48 +02:00
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
38af006b5e Changed type for UTF-32 codepoints from long to uint_least32_t 2015-05-06 08:15:41 +02:00
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
3cb7f27afe Fix indentation. 2015-05-04 12:00:10 +02:00
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
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
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
765bb0fd14 Remove first argument of selsnap. 2015-05-04 11:16:08 +02:00
07ce96a3a0 Fix sigchld
Only wait for termination of the shell.
2015-05-04 10:57:40 +02:00
190b94c7a2 len assignment is never used
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2015-04-27 10:10:30 +02:00
4f21c41a1c Clarify calculation precedence for '&' and '?'
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2015-04-27 10:09:49 +02:00
3a5053f6c1 Use %u for uint
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2015-04-27 10:09:15 +02:00
7ab6c92e18 Optimize memory footprint of line buffers 2015-04-27 10:05:14 +02:00
0622ad9bad Make tputc, tsetchar and techo accept unicode 2015-04-27 09:50:40 +02:00
21f765426c Change internal character representation. 2015-04-27 09:50:01 +02:00
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
61c35cd246 Use utf8len instead of utf8decode. 2015-04-27 08:58:37 +02:00
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
f36dd277a2 Merge remote-tracking branch 'origin/master' 2015-04-23 17:59:39 +02:00
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
b17aa18f7c Uses a &[] pointer loop instead of + pointer loop 2015-04-23 17:59:10 +02:00
736685d641 Do not set terminal title based on stty arguments. 2015-04-23 17:59:10 +02:00
89807ed453 Move common code to xloadcolor 2015-04-21 09:48:33 +02:00
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
2fdcc5e5f6 Remove WIN_REDRAW flag.
WIN_REDRAW flag was not used since introduction of Xdbe
in commit 94771d05886fbdd2422e66b7c0256ab27fa375cb
2015-04-21 07:49:07 +02:00
ab69ea89b7 Place memset arguments in the correct order. 2015-04-20 09:29:24 +02:00
5528280fae Remove explicit 'return' from 'void' functions. 2015-04-20 09:28:14 +02:00
6dc2b546ec Increment accuaracy in drawtime calculation
This way is a bit more accurate.
2015-04-20 09:20:35 +02:00
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
6ee56d6590 Place tlinelen type on separate line. 2015-04-20 08:30:49 +02:00
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
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
83e73c6242 Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-04-14 09:47:19 +02:00
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
23ed12857f Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-04-13 22:01:40 +02:00
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
9619760e12 tresize: remove unnecessary if 2015-04-13 17:12:49 +02:00
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
b94ad75e5d Remove 'titles' variable.
We do not free it until exit anyway.
2015-04-13 17:00:08 +02:00
e6dd0f825d Remove useless if in tstrsequence. 2015-04-13 15:17:24 +02:00
b0310fba5d Simplify tmoveto.
LIMIT returns value. This fact is already used in x2col and y2row.
2015-04-13 15:15:47 +02:00
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
c569e3146e Remove 'slide' variable in tresize. 2015-04-13 10:18:08 +02:00
39ae1a4de5 Move tresize comments around. 2015-04-13 09:26:03 +02:00
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
b9390a5496 Simplify loop condition. 2015-04-13 09:20:00 +02:00
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
d3e0f3444b Use do..while in window mapping loop. 2015-04-13 09:15:42 +02:00
ecac5ee35e Make DECSCUSR thickness configurable 2015-04-10 23:43:05 +02:00
93b54cfcc4 Use MAX macro where possible. 2015-04-10 23:34:06 +02:00
6f5f770186 Remove 'xloadfontset' function.
It was used only once and its return value was ignored.
2015-04-10 23:31:53 +02:00
6524f022f7 Remove keywords from function definitions. 2015-04-10 23:28:21 +02:00
9305f3c184 Remove variable names from function declarations. 2015-04-10 23:28:16 +02:00
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
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
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
c9357a8edf Merge remote-tracking branch 'origin/master' 2015-03-19 08:36:50 +00:00
580302f317 Support the DECSCUSR CSI escape sequence 2015-03-19 05:36:54 +00:00
246c3481d7 arg.h wasn't used for dist. 2015-03-16 22:17:30 +01:00
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
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
c7e24e44c8 TODO: Fix fontconfig 2015-03-14 08:53:41 +01:00
5406e655da Add the new selection shortcuts to the manpage. 2015-03-14 08:52:37 +01:00
72d2accc22 Glibc wants me to use _DEFAULT_SOURCe. I do obey. 2015-03-14 08:43:57 +01:00
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
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
4f60751440 FAQ: fix wording 2015-03-11 17:27:55 +00:00
f5075a9e9d Backspace value shouldn't depend on keypad state 2015-03-11 17:25:48 +00:00
c87d45466b Merge branch 'master' of ssh://suckless.org/gitrepos/st 2015-03-10 21:59:41 +01:00
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
adeb2e95d6 FAQ: fix wording 2015-03-10 20:56:25 +00:00
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
cf1fcc4d96 Change the FAQ for the new Backspace behaviour. 2015-03-10 00:20:28 +01:00
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
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
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
29619a1a35 Small improvements to the FAQ 2015-02-28 16:15:16 +00:00
b8804f9f67 document keys in man page 2015-02-23 11:14:21 +01:00
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
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
ac11bbb03b Update dates in LICENSE 2015-02-22 10:58:37 +00:00
c5f1d74fd8 Update year in usage() 2015-02-15 17:46:15 +01:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
a7eef8f230 Removing an extra space. 2014-09-29 15:41:10 +02:00
63a07eb19c Minor style changes for the last patch. 2014-09-29 15:40:37 +02:00
dc8c5c82aa Implementing xzoomreset.
Thanks mvdan@mvdan.cc for proposing this.
2014-09-29 15:38:21 +02:00
10 changed files with 1783 additions and 1178 deletions

18
FAQ
View File

@ -51,7 +51,7 @@ solution for them is to use the following command:
$ printf '\033[?1h\033=' >/dev/tty $ printf '\033[?1h\033=' >/dev/tty
or 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: manpage about this issue:
@ -92,16 +92,20 @@ Putting these lines into your .zshrc will fix the problems.
## I cannot compile st in OpenBSD ## I cannot compile st in OpenBSD
OpenBSD lacks of librt, despite it begin mandatory in POSIX OpenBSD lacks librt, despite it being mandatory in POSIX
<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_13>. <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 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 st will compile without any loss of functionality, because all the functions are
included in libc on this platform. included in libc on this platform.
## Backspace key does not work ## 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 This is an issue that was discussed in suckless mailing list
<http://lists.suckless.org/dev/1404/20697.html>: <http://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 Well, I am going to comment why I want to change the behaviour
of this key. When ASCII was defined in 1968, communication of this key. When ASCII was defined in 1968, communication
@ -155,3 +159,9 @@ This is an issue that was discussed in suckless mailing list
[1] http://www.ibb.net/~anne/keyboard.html [1] http://www.ibb.net/~anne/keyboard.html
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.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] http://st.suckless.org/patches/delkey

View File

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

View File

@ -34,7 +34,7 @@ clean:
dist: clean dist: clean
@echo creating dist tarball @echo creating dist tarball
@mkdir -p st-${VERSION} @mkdir -p st-${VERSION}
@cp -R LICENSE Makefile README config.mk config.def.h st.info st.1 ${SRC} st-${VERSION} @cp -R LICENSE Makefile README config.mk config.def.h st.info st.1 arg.h ${SRC} st-${VERSION}
@tar -cf st-${VERSION}.tar st-${VERSION} @tar -cf st-${VERSION}.tar st-${VERSION}
@gzip st-${VERSION}.tar @gzip st-${VERSION}.tar
@rm -rf st-${VERSION} @rm -rf st-${VERSION}

2
TODO
View File

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

19
arg.h
View File

@ -10,8 +10,8 @@ extern char *argv0;
/* use main(int argc, char *argv[]) */ /* use main(int argc, char *argv[]) */
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ #define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
argv[0] && argv[0][1]\ argv[0] && argv[0][0] == '-'\
&& argv[0][0] == '-';\ && argv[0][1];\
argc--, argv++) {\ argc--, argv++) {\
char argc_;\ char argc_;\
char **argv_;\ char **argv_;\
@ -28,26 +28,11 @@ extern char *argv0;
break;\ break;\
argc_ = argv[0][0];\ argc_ = argv[0][0];\
switch (argc_) 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 ARGEND }\
} }
#define ARGC() argc_ #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][1] == '\0' && argv[1] == NULL)?\
((x), abort(), (char *)0) :\ ((x), abort(), (char *)0) :\
(brk_ = 1, (argv[0][1] != '\0')?\ (brk_ = 1, (argv[0][1] != '\0')?\

View File

@ -5,10 +5,20 @@
* *
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html * 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 int borderpx = 2;
/*
* What program is execed by st depends of these precedence rules:
* 1: program passed with -e
* 2: utmp option
* 3: SHELL environment variable
* 4: value of shell in /etc/passwd
* 5: value of shell in config.h
*/
static char shell[] = "/bin/sh"; static char shell[] = "/bin/sh";
static char *utmp = NULL; static char *utmp = NULL;
static char stty_args[] = "stty raw pass8 nl -echo -iexten -cstopb 38400";
/* identification sequence returned in DA and DECID */ /* identification sequence returned in DA and DECID */
static char vtiden[] = "\033[?6c"; static char vtiden[] = "\033[?6c";
@ -29,7 +39,7 @@ static unsigned int doubleclicktimeout = 300;
static unsigned int tripleclicktimeout = 600; static unsigned int tripleclicktimeout = 600;
/* alt screens */ /* alt screens */
static bool allowaltscreen = true; static int allowaltscreen = 1;
/* frames per second st should at maximum draw to the screen */ /* frames per second st should at maximum draw to the screen */
static unsigned int xfps = 120; static unsigned int xfps = 120;
@ -41,18 +51,37 @@ static unsigned int actionfps = 30;
*/ */
static unsigned int blinktimeout = 800; 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 * bell volume. It must be a value between -100 and 100. Use 0 for disabling
* it * it
*/ */
static int bellvolume = 0; static int bellvolume = 0;
/* TERM value */ /* default TERM value */
static char termname[] = "st-256color"; static 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
*/
static unsigned int tabspaces = 8; static unsigned int tabspaces = 8;
/* Terminal colors (16 first used in escape sequence) */ /* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = { static const char *colorname[] = {
/* 8 normal colors */ /* 8 normal colors */
@ -79,16 +108,34 @@ static const char *colorname[] = {
/* more colors can be added after 255 to use with DefaultXX */ /* more colors can be added after 255 to use with DefaultXX */
"#cccccc", "#cccccc",
"#555555",
}; };
/* /*
* Default colors (colorname index) * Default colors (colorname index)
* foreground, background, cursor * foreground, background, cursor, reverse cursor
*/ */
static unsigned int defaultfg = 7; static unsigned int defaultfg = 7;
static unsigned int defaultbg = 0; static unsigned int defaultbg = 0;
static unsigned int defaultcs = 256; static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
/*
* Default shape of cursor
* 2: Block ("█")
* 4: Underline ("_")
* 6: Bar ("|")
* 7: Snowman ("☃")
*/
static unsigned int cursorshape = 2;
/*
* Default colour and shape of the mouse cursor
*/
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
/* /*
* Colors used, when the specific fg == defaultfg. So in reverse mode this * Colors used, when the specific fg == defaultfg. So in reverse mode this
@ -98,9 +145,11 @@ static unsigned int defaultcs = 256;
static unsigned int defaultitalic = 11; static unsigned int defaultitalic = 11;
static unsigned int defaultunderline = 7; static unsigned int defaultunderline = 7;
/* Internal mouse shortcuts. */ /*
/* Beware that overloading Button1 will disable the selection. */ * Internal mouse shortcuts.
static Mousekey mshortcuts[] = { * Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
/* button mask string */ /* button mask string */
{ Button4, XK_ANY_MOD, "\031" }, { Button4, XK_ANY_MOD, "\031" },
{ Button5, XK_ANY_MOD, "\005" }, { Button5, XK_ANY_MOD, "\005" },
@ -111,13 +160,17 @@ static Mousekey mshortcuts[] = {
static Shortcut shortcuts[] = { static Shortcut shortcuts[] = {
/* mask keysym function argument */ /* mask keysym function argument */
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
{ ControlMask, XK_Print, toggleprinter, {.i = 0} }, { ControlMask, XK_Print, toggleprinter, {.i = 0} },
{ ShiftMask, XK_Print, printscreen, {.i = 0} }, { ShiftMask, XK_Print, printscreen, {.i = 0} },
{ XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, { XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
{ MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} }, { MODKEY|ShiftMask, XK_Prior, xzoom, {.f = +1} },
{ MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} }, { MODKEY|ShiftMask, XK_Next, xzoom, {.f = -1} },
{ MODKEY|ShiftMask, XK_Home, xzoomreset, {.f = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} }, { MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} },
{ MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} },
{ MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} },
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} }, { MODKEY, XK_Num_Lock, numlock, {.i = 0} },
}; };
@ -158,11 +211,17 @@ static KeySym mappedkeys[] = { -1 };
*/ */
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
/* Override mouse-select while mask is active (when MODE_MOUSE is set). /*
* Override mouse-select while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other * Note that if you want to use ShiftMask with selmasks, set this to an other
* modifier, set to 0 to not use it. */ * modifier, set to 0 to not use it.
*/
static uint forceselmod = ShiftMask; static uint forceselmod = ShiftMask;
/*
* This is the huge key array which defines all compatibility to the Linux
* world. Please decide about changes wisely.
*/
static Key key[] = { static Key key[] = {
/* keysym mask string appkey appcursor crlf */ /* keysym mask string appkey appcursor crlf */
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1, 0}, { XK_KP_Home, ShiftMask, "\033[2J", 0, -1, 0},
@ -202,7 +261,7 @@ static Key key[] = {
{ XK_KP_Delete, ShiftMask, "\033[2K", -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, 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[P", -1, 0, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\177", +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_Multiply, XK_ANY_MOD, "\033Oj", +2, 0, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +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, "\033OM", +2, 0, 0},
@ -257,7 +316,9 @@ static Key key[] = {
{ XK_Delete, ShiftMask, "\033[2K", -1, 0, 0}, { XK_Delete, ShiftMask, "\033[2K", -1, 0, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +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[P", -1, 0, 0},
{ XK_Delete, XK_ANY_MOD, "\177", +1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0},
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0, 0},
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0, 0},
{ XK_Home, ShiftMask, "\033[2J", 0, -1, 0}, { XK_Home, ShiftMask, "\033[2J", 0, -1, 0},
{ XK_Home, ShiftMask, "\033[1;2H", 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[H", 0, -1, 0},
@ -372,3 +433,12 @@ static uint selmasks[] = {
[SEL_RECTANGULAR] = Mod1Mask, [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,5 +1,5 @@
# st version # st version
VERSION = 0.5 VERSION = 0.7
# Customize below to fit your system # Customize below to fit your system
@ -14,15 +14,15 @@ X11LIB = /usr/X11R6/lib
INCS = -I. -I/usr/include -I${X11INC} \ INCS = -I. -I/usr/include -I${X11INC} \
`pkg-config --cflags fontconfig` \ `pkg-config --cflags fontconfig` \
`pkg-config --cflags freetype2` `pkg-config --cflags freetype2`
LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXext -lXft \ LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft \
`pkg-config --libs fontconfig` \ `pkg-config --libs fontconfig` \
`pkg-config --libs freetype2` `pkg-config --libs freetype2`
# flags # flags
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_XOPEN_SOURCE=600 CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600
CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS} CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS}
LDFLAGS += -g ${LIBS} LDFLAGS += -g ${LIBS}
# compiler and linker # compiler and linker
CC ?= cc # CC = cc

119
st.1
View File

@ -3,23 +3,50 @@
st \- simple terminal st \- simple terminal
.SH SYNOPSIS .SH SYNOPSIS
.B st .B st
.RB [ \-a ] .RB [ \-aiv ]
.RB [ \-c .RB [ \-c
.IR class ] .IR class ]
.RB [ \-f .RB [ \-f
.IR font ] .IR font ]
.RB [ \-g .RB [ \-g
.IR geometry ] .IR geometry ]
.RB [ \-i ] .RB [ \-n
.IR name ]
.RB [ \-o .RB [ \-o
.IR file ] .IR iofile ]
.RB [ \-T
.IR title ]
.RB [ \-t
.IR title ]
.RB [ \-l
.IR line ]
.RB [ \-w
.IR windowid ]
.RB [[ \-e ]
.IR command
.RI [ arguments ...]]
.PP
.B st
.RB [ \-aiv ]
.RB [ \-c
.IR class ]
.RB [ \-f
.IR font ]
.RB [ \-g
.IR geometry ]
.RB [ \-n
.IR name ]
.RB [ \-o
.IR iofile ]
.RB [ \-T
.IR title ]
.RB [ \-t .RB [ \-t
.IR title ] .IR title ]
.RB [ \-w .RB [ \-w
.IR windowid ] .IR windowid ]
.RB [ \-v ] .RB \-l
.RB [ \-e .IR line
.IR command ...] .RI [ stty_args ...]
.SH DESCRIPTION .SH DESCRIPTION
.B st .B st
is a simple terminal emulator. is a simple terminal emulator.
@ -45,12 +72,18 @@ for further details.
.B \-i .B \-i
will fixate the position given with the -g option. will fixate the position given with the -g option.
.TP .TP
.BI \-o " file" .BI \-n " name"
defines the window instance name (default $TERM).
.TP
.BI \-o " iofile"
writes all the I/O to writes all the I/O to
.I file. .I iofile.
This feature is useful when recording st sessions. A value of "-" means This feature is useful when recording st sessions. A value of "-" means
standard output. standard output.
.TP .TP
.BI \-T " title"
defines the window title (default 'st').
.TP
.BI \-t " title" .BI \-t " title"
defines the window title (default 'st'). defines the window title (default 'st').
.TP .TP
@ -58,15 +91,77 @@ defines the window title (default 'st').
embeds st within the window identified by embeds st within the window identified by
.I windowid .I windowid
.TP .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/ttySO 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 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
parenb parodd 115200'. Set the number of bits by using for example 'st -l cs7
115200'. See
.BR stty(1)
for more arguments and cases.
.TP
.B \-v .B \-v
prints version information to stderr, then exits. prints version information to stderr, then exits.
.TP .TP
.BI \-e " program " [ " arguments " "... ]" .BI \-e " command " [ " arguments " "... ]"
st executes st executes
.I program .I command
instead of the shell. If this is used it instead of the shell. If this is used it
.B must be the last option .B must be the last option
on the command line, as in xterm / rxvt. on the command line, as in xterm / rxvt.
This option is only intended for compability,
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 Alt-Shift-Page Up
Increase font size.
.TP
.B Alt-Shift-Page Down
Decrease font size.
.TP
.B Alt-Shift-Home
Reset to default font size.
.TP
.B Shift-Insert
Paste from primary selection (middle mouse button).
.TP
.B Alt-Shift-Insert
Paste from clipboard selection.
.TP
.B Alt-Shift-c
Copy the selected text to the clipboard selection.
.TP
.B Alt-Shift-v
Paste from the clipboard selection.
.SH CUSTOMIZATION .SH CUSTOMIZATION
.B st .B st
can be customized by creating a custom config.h and (re)compiling the source can be customized by creating a custom config.h and (re)compiling the source
@ -76,7 +171,9 @@ See the LICENSE file for the authors.
.SH LICENSE .SH LICENSE
See the LICENSE file for the terms of redistribution. See the LICENSE file for the terms of redistribution.
.SH SEE ALSO .SH SEE ALSO
.BR tabbed (1) .BR tabbed (1),
.BR utmp (1),
.BR stty (1)
.SH BUGS .SH BUGS
See the TODO file in the distribution. See the TODO file in the distribution.

1918
st.c

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
st| simpleterm, st| simpleterm,
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
am, am,
bce, bce,
bel=^G, bel=^G,
@ -32,7 +32,7 @@ st| simpleterm,
el=\E[K, el=\E[K,
el1=\E[1K, el1=\E[1K,
enacs=\E)0, enacs=\E)0,
flash=\E[?5h\E[?5l, flash=\E[?5h$<80/>\E[?5l,
fsl=^G, fsl=^G,
home=\E[H, home=\E[H,
hpa=\E[%i%p1%dG, hpa=\E[%i%p1%dG,
@ -53,7 +53,7 @@ st| simpleterm,
ka3=\E[5~, ka3=\E[5~,
kc1=\E[4~, kc1=\E[4~,
kc3=\E[6~, kc3=\E[6~,
kbs=\010, kbs=\177,
kcbt=\E[Z, kcbt=\E[Z,
kb2=\EOu, kb2=\EOu,
kcub1=\EOD, kcub1=\EOD,
@ -73,7 +73,7 @@ st| simpleterm,
kri=\E[1;2A, kri=\E[1;2A,
kclr=\E[3;5~, kclr=\E[3;5~,
kdl1=\E[3;2~, kdl1=\E[3;2~,
kdch1=\0177, kdch1=\E[3~,
kich1=\E[2~, kich1=\E[2~,
kend=\E[4~, kend=\E[4~,
kf1=\EOP, kf1=\EOP,
@ -150,6 +150,7 @@ st| simpleterm,
mir, mir,
msgr, msgr,
ncv#3, ncv#3,
npc,
op=\E[39;49m, op=\E[39;49m,
pairs#64, pairs#64,
mc0=\E[i, mc0=\E[i,