st.git
4 years agoAdd terminfo entries for backspace mode
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:50:23 +0000 (22:50 +0200)]
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.

4 years agoFix style issue
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:26:12 +0000 (22:26 +0200)]
Fix style issue

4 years agottyread: test for EOF while reading tty
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:25:46 +0000 (22:25 +0200)]
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.

4 years agoAdd support for scroll(1)
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:06:32 +0000 (22:06 +0200)]
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.

4 years agomake argv0 not static, fixes a warning with tcc
Hiltjo Posthuma [Fri, 10 Apr 2020 10:12:43 +0000 (12:12 +0200)]
make argv0 not static, fixes a warning with tcc

Reported by Aajonus, thanks!

4 years agomouseshortcuts: fix custom modifier on release
Avi Halachmi (:avih) [Thu, 2 Apr 2020 08:43:22 +0000 (11:43 +0300)]
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.

4 years agoRemove explicit XNFocusWindow
Ivan Tham [Tue, 18 Feb 2020 15:28:47 +0000 (23:28 +0800)]
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.

4 years agox: fix XIM handling
Quentin Rameau [Sun, 2 Feb 2020 20:47:19 +0000 (21:47 +0100)]
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.

4 years agox: check we still have an XIC context before accessing it
Quentin Rameau [Sun, 2 Feb 2020 16:38:36 +0000 (17:38 +0100)]
x: check we still have an XIC context before accessing it

4 years agox: do not instantiate a new nested list on each cursor move
Quentin Rameau [Sun, 2 Feb 2020 14:38:08 +0000 (15:38 +0100)]
x: do not instantiate a new nested list on each cursor move

4 years agox: move IME variables into XWindow ime embedded struct
Quentin Rameau [Sun, 2 Feb 2020 14:37:29 +0000 (15:37 +0100)]
x: move IME variables into XWindow ime embedded struct

4 years agoIncrease XmbLookupString buffer
Ivan Tham [Sat, 18 Jan 2020 07:52:25 +0000 (15:52 +0800)]
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)
あなたは家のように感じる

5 years agoupdate FAQ
Hiltjo Posthuma [Sun, 17 Nov 2019 19:04:52 +0000 (20:04 +0100)]
update FAQ

- add common question about the w3m image drawing hack.
- remove some bad advise about $TERM.
- change some links to https.

5 years agoOSC 52 - copy to clipboard: don't limit to 382 bytes
Avi Halachmi (:avih) [Wed, 16 Oct 2019 09:55:53 +0000 (12:55 +0300)]
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.

5 years agoCSIEscape, STREscape: use size_t for buffer length
Hiltjo Posthuma [Wed, 16 Oct 2019 09:38:43 +0000 (12:38 +0300)]
CSIEscape, STREscape: use size_t for buffer length

5 years agoSTREscape: don't trim prematurely
Avi Halachmi (:avih) [Wed, 16 Oct 2019 09:19:49 +0000 (12:19 +0300)]
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.

5 years agobase64dec: don't read out of bounds
Avi Halachmi (:avih) [Wed, 16 Oct 2019 08:17:23 +0000 (11:17 +0300)]
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).

5 years agoFix tmux terminfo extensions Se and Ss
Sebastian J. Bronner [Tue, 5 Nov 2019 17:16:39 +0000 (18:16 +0100)]
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
https://github.com/tmux/tmux/blob/eeedb43ae847a0a692ceea965f7556e84bca4fd0/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.

5 years agoapply hints before initial mapping (ICCCM)
Ingo Lohmar [Fri, 31 May 2019 20:25:35 +0000 (22:25 +0200)]
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.

5 years agomouse shortcuts: allow using forcemousemod (e.g. shift)
Avi Halachmi (:avih) [Thu, 24 Oct 2019 12:42:07 +0000 (15:42 +0300)]
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.

5 years agomouse shortcuts: don't hardcode selpaste
Avi Halachmi (:avih) [Thu, 10 Oct 2019 23:26:10 +0000 (02:26 +0300)]
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.

5 years agomouse shortcuts: allow override for all shortcuts
Avi Halachmi (:avih) [Thu, 10 Oct 2019 20:42:30 +0000 (23:42 +0300)]
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.

5 years agomouse shortcuts: allow same functions as kb shortcuts
Avi Halachmi (:avih) [Thu, 10 Oct 2019 20:02:26 +0000 (23:02 +0300)]
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.

5 years agoconfig.def.h: remove crlf value section
Hiltjo Posthuma [Mon, 26 Aug 2019 15:58:47 +0000 (17:58 +0200)]
config.def.h: remove crlf value section

this is not used anymore.

patch sent as an ed script using RFC2549 by k0ga.

5 years agoFAQ: add entry about color emoji Xft bug
Hiltjo Posthuma [Fri, 17 May 2019 11:00:10 +0000 (13:00 +0200)]
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.

5 years agoselection: fix view to match actual selection on first cell
Avi Halachmi (:avih) [Tue, 9 Apr 2019 22:54:43 +0000 (01:54 +0300)]
selection: fix view to match actual selection on first cell

5 years agorevert part of commit add0211522737b79dad990ccd65c8af63b5cc1dd
Hiltjo Posthuma [Fri, 15 Mar 2019 19:40:16 +0000 (20:40 +0100)]
revert part of commit add0211522737b79dad990ccd65c8af63b5cc1dd

"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.

5 years agodont print color warning on color reset OSC 104 without parameter
Hiltjo Posthuma [Fri, 15 Mar 2019 13:44:28 +0000 (14:44 +0100)]
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'

5 years agominor code-style, initialize var at the top of function
Hiltjo Posthuma [Fri, 15 Mar 2019 13:42:50 +0000 (14:42 +0100)]
minor code-style, initialize var at the top of function

5 years agoconfig.def.h: tweak extra worddelimiters
Hiltjo Posthuma [Fri, 15 Mar 2019 11:31:54 +0000 (12:31 +0100)]
config.def.h: tweak extra worddelimiters

This changes the selection more like xterm.
To test try: "find /" and select a path.

5 years agouse iswspace()/iswpunct() to find word delimiters
Lauri Tirkkonen [Wed, 13 Mar 2019 15:15:04 +0000 (17:15 +0200)]
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.

5 years agoreplace utf8strchr with wcschr
Lauri Tirkkonen [Wed, 13 Mar 2019 17:40:52 +0000 (19:40 +0200)]
replace utf8strchr with wcschr

5 years agobe silent about explicitly unhandled mouse modes
Lauri Tirkkonen [Wed, 13 Mar 2019 15:08:50 +0000 (17:08 +0200)]
be silent about explicitly unhandled mouse modes

5 years agosimplify (greedy) font caching allocating a bit
Hiltjo Posthuma [Sun, 3 Mar 2019 10:29:43 +0000 (11:29 +0100)]
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."

5 years agostyle: remove double empty newlines
Hiltjo Posthuma [Sun, 3 Mar 2019 10:23:54 +0000 (11:23 +0100)]
style: remove double empty newlines

5 years agofix use after free in font caching algorithm
magras [Thu, 28 Feb 2019 01:56:01 +0000 (04:56 +0300)]
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.

5 years agobetter Input Method Editor (IME) support
Ivan Tham [Tue, 12 Feb 2019 17:41:41 +0000 (18:41 +0100)]
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

5 years agobump version to 0.8.2
Hiltjo Posthuma [Sat, 9 Feb 2019 11:48:39 +0000 (12:48 +0100)]
bump version to 0.8.2

5 years agoconfig: add Shift+Insert as selpaste() again
Hiltjo Posthuma [Thu, 10 Jan 2019 17:16:17 +0000 (18:16 +0100)]
config: add Shift+Insert as selpaste() again

This was changed before in:
commit 20f713548de451b67db3306cf8cf7b2f38fee05c on Wed Jan 25 19:17:38 2017

5 years agoLet the user specify CPPFLAGS
Paride Legovini [Thu, 10 Jan 2019 12:36:09 +0000 (13:36 +0100)]
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.

5 years agoSet the path of pkg-config in a variable instead of hardcoding it
Paride Legovini [Fri, 4 Jan 2019 08:48:37 +0000 (09:48 +0100)]
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.

5 years agoMakefile: fix dependencies on config.h
Hiltjo Posthuma [Fri, 4 Jan 2019 11:33:01 +0000 (12:33 +0100)]
Makefile: fix dependencies on config.h

patch by Younes Khoudli (changed slightly). Thanks

5 years agooutput child WEXITSTATUS/WTERMSIG on abnormal termination
Lauri Tirkkonen [Tue, 11 Dec 2018 09:43:03 +0000 (11:43 +0200)]
output child WEXITSTATUS/WTERMSIG on abnormal termination

6 years agofix memory leak in xloadcols()
Hiltjo Posthuma [Sun, 4 Nov 2018 13:35:07 +0000 (14:35 +0100)]
fix memory leak in xloadcols()

reported by Avi Halachmi (:avih)" <avihpit@yahoo.com>

patch slightly changed by me.

6 years agost: small typofix in comment
Hiltjo Posthuma [Sun, 4 Nov 2018 13:30:56 +0000 (14:30 +0100)]
st: small typofix in comment

6 years agosmall code-style fix
Hiltjo Posthuma [Tue, 11 Sep 2018 17:06:35 +0000 (19:06 +0200)]
small code-style fix

6 years agoRemove the ISO 14755 feature
Quentin Rameau [Tue, 11 Sep 2018 11:11:28 +0000 (13:11 +0200)]
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!

6 years agoRevert "Simplify cursor color handling"
Hiltjo Posthuma [Tue, 17 Jul 2018 18:01:58 +0000 (20:01 +0200)]
Revert "Simplify cursor color handling"

This reverts commit 1911c9274d9b03f3d7999c6ce26e2d5169642d26.

6 years agoRevert "Make cursor follow text color"
Hiltjo Posthuma [Tue, 17 Jul 2018 18:01:57 +0000 (20:01 +0200)]
Revert "Make cursor follow text color"

This reverts commit b51bcd5553af3db394014efbd78acf7828fa48ff.

6 years agoRevert "Fix crash when cursor color is truecolor"
Hiltjo Posthuma [Tue, 17 Jul 2018 18:01:54 +0000 (20:01 +0200)]
Revert "Fix crash when cursor color is truecolor"

This reverts commit 5535c1f04c665c05faff2a65d5558246b7748d49.

6 years agoFix crash when cursor color is truecolor
Jules Maselbas [Sun, 15 Jul 2018 11:53:37 +0000 (13:53 +0200)]
Fix crash when cursor color is truecolor

Reported-by: Ivan Tham <pickfire@riseup.net>
6 years agoMake cursor follow text color
Jules Maselbas [Sat, 14 Jul 2018 09:16:37 +0000 (11:16 +0200)]
Make cursor follow text color

6 years agoSimplify cursor color handling
Jules Maselbas [Sat, 14 Jul 2018 09:16:36 +0000 (11:16 +0200)]
Simplify cursor color handling

6 years agoFix crash on resize
Jules Maselbas [Wed, 27 Jun 2018 15:08:30 +0000 (17:08 +0200)]
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.

6 years agoconfig.mk: remove extra newline before EOF
Hiltjo Posthuma [Sat, 2 Jun 2018 15:11:14 +0000 (17:11 +0200)]
config.mk: remove extra newline before EOF

6 years agocode-style for pledge(2)
Hiltjo Posthuma [Fri, 25 May 2018 11:04:09 +0000 (13:04 +0200)]
code-style for pledge(2)

feedback from Klemens, thanks

6 years agoPledge on OpenBSD
Hiltjo Posthuma [Fri, 25 May 2018 09:59:28 +0000 (11:59 +0200)]
Pledge on OpenBSD

6 years agoerror message style and use strerror in a few places
Hiltjo Posthuma [Thu, 29 Mar 2018 16:30:05 +0000 (18:30 +0200)]
error message style and use strerror in a few places

6 years agost -v: remove years and copyright text
Hiltjo Posthuma [Thu, 29 Mar 2018 16:18:30 +0000 (18:18 +0200)]
st -v: remove years and copyright text

6 years agoset sel.alt in selstart instead of selextend
Daniel Tameling [Wed, 28 Mar 2018 19:27:58 +0000 (21:27 +0200)]
set sel.alt in selstart instead of selextend

6 years agobump version to 0.8.1
Hiltjo Posthuma [Tue, 20 Mar 2018 20:29:10 +0000 (21:29 +0100)]
bump version to 0.8.1

6 years agofix regression by selecting clipboard text
Hiltjo Posthuma [Tue, 20 Mar 2018 20:25:30 +0000 (21:25 +0100)]
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!

6 years agodon't modify argv, use a counter
Hiltjo Posthuma [Tue, 20 Mar 2018 20:22:27 +0000 (21:22 +0100)]
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.

6 years agoselextend: clarify: !sel.mode == SEL_IDLE
Hiltjo Posthuma [Sat, 17 Mar 2018 12:48:29 +0000 (13:48 +0100)]
selextend: clarify: !sel.mode == SEL_IDLE

6 years agoclipcopy: no need to check for free(NULL), set to NULL after free
Hiltjo Posthuma [Sat, 17 Mar 2018 12:48:10 +0000 (13:48 +0100)]
clipcopy: no need to check for free(NULL), set to NULL after free

6 years agominor code-style: whitespace fixes
Hiltjo Posthuma [Fri, 16 Mar 2018 15:45:58 +0000 (16:45 +0100)]
minor code-style: whitespace fixes

6 years agoFix title initialization
Quentin Rameau [Fri, 16 Mar 2018 15:19:18 +0000 (16:19 +0100)]
Fix title initialization

6 years agoFix regression from 69e32a6 when setting title.
Quentin Rameau [Fri, 16 Mar 2018 14:03:10 +0000 (15:03 +0100)]
Fix regression from 69e32a6 when setting title.

6 years agoLICENSE: fix a few years
Hiltjo Posthuma [Wed, 14 Mar 2018 19:06:42 +0000 (20:06 +0100)]
LICENSE: fix a few years

6 years agoupdate LICENSE: major contributors
Hiltjo Posthuma [Wed, 14 Mar 2018 19:00:35 +0000 (20:00 +0100)]
update LICENSE: major contributors

6 years agoMakefile: add all files to make dist
Hiltjo Posthuma [Wed, 14 Mar 2018 18:54:50 +0000 (19:54 +0100)]
Makefile: add all files to make dist

6 years agobump version to 0.8
Hiltjo Posthuma [Wed, 14 Mar 2018 18:50:37 +0000 (19:50 +0100)]
bump version to 0.8

6 years agouse math.h for ceilf
Hiltjo Posthuma [Fri, 9 Mar 2018 14:36:38 +0000 (15:36 +0100)]
use math.h for ceilf

6 years agoxhints: no need to initialize sizeh
Hiltjo Posthuma [Fri, 9 Mar 2018 14:36:25 +0000 (15:36 +0100)]
xhints: no need to initialize sizeh

6 years agoregression: include termios.h for tcsendbreak etc
Hiltjo Posthuma [Fri, 9 Mar 2018 14:35:34 +0000 (15:35 +0100)]
regression: include termios.h for tcsendbreak etc

6 years agoGeneral cleanup
Devin J. Pohly [Sat, 24 Feb 2018 23:09:13 +0000 (17:09 -0600)]
General cleanup

Simplifies logic in a couple places and removes a redundant function
call.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
6 years agoClean up #includes
Devin J. Pohly [Sat, 24 Feb 2018 22:45:42 +0000 (16:45 -0600)]
Clean up #includes

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
6 years agoReduce visibility wherever possible
Devin J. Pohly [Sat, 24 Feb 2018 22:32:20 +0000 (16:32 -0600)]
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>
6 years agoLimit usage of extern to config.h globals
Devin J. Pohly [Sat, 24 Feb 2018 22:16:12 +0000 (16:16 -0600)]
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>
6 years agoRemove x.c dependency on term
Devin J. Pohly [Sat, 24 Feb 2018 21:32:48 +0000 (15:32 -0600)]
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>
6 years agoPull term references out of xdrawcursor
Devin J. Pohly [Sat, 24 Feb 2018 20:58:54 +0000 (14:58 -0600)]
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>
6 years agoMove win-agnostic parts of draw/drawregion to st.c
Devin J. Pohly [Sat, 24 Feb 2018 20:53:23 +0000 (14:53 -0600)]
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>
6 years agoSplit mode bits between Term and TermWindow
Devin J. Pohly [Fri, 23 Feb 2018 20:16:52 +0000 (14:16 -0600)]
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>
6 years agoMove CRLF input processing into ttywrite
Devin J. Pohly [Thu, 22 Feb 2018 07:05:12 +0000 (01:05 -0600)]
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>
6 years agoMove terminal echo logic into st.c
Devin J. Pohly [Thu, 22 Feb 2018 06:42:23 +0000 (00:42 -0600)]
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>
6 years agoMove remaining selection mode logic into selextend
Devin J. Pohly [Thu, 22 Feb 2018 05:54:29 +0000 (23:54 -0600)]
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>
6 years agoMove terminal-related selection logic into st.c
Devin J. Pohly [Thu, 22 Feb 2018 05:29:41 +0000 (23:29 -0600)]
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>
6 years agoMove X-specific selection info into XSelection
Devin J. Pohly [Thu, 22 Feb 2018 04:56:02 +0000 (22:56 -0600)]
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>
6 years agoHave selected() check whether selection exists
Devin J. Pohly [Thu, 22 Feb 2018 04:48:28 +0000 (22:48 -0600)]
Have selected() check whether selection exists

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
6 years agoRely on ttyresize to set tty size
Devin J. Pohly [Thu, 22 Feb 2018 04:28:41 +0000 (22:28 -0600)]
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>
6 years agoRemove X and fontconfig from st.c
Devin J. Pohly [Tue, 7 Nov 2017 00:30:45 +0000 (18:30 -0600)]
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>
6 years agoRemove Time argument from xsetsel
Devin J. Pohly [Tue, 7 Nov 2017 00:25:58 +0000 (18:25 -0600)]
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>
6 years agoMake win variable internal to x.c
Devin J. Pohly [Mon, 6 Nov 2017 23:57:45 +0000 (17:57 -0600)]
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>
6 years agoMove X-related config.h types into x.c
Devin J. Pohly [Tue, 17 Oct 2017 21:46:26 +0000 (16:46 -0500)]
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>
6 years agoRemove unneeded array-length variables
Devin J. Pohly [Tue, 17 Oct 2017 20:46:31 +0000 (15:46 -0500)]
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>
6 years agoInline clipboard functions
Devin J. Pohly [Tue, 17 Oct 2017 20:43:32 +0000 (15:43 -0500)]
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>
6 years agoMove config.h include from st.c to x.c
Devin J. Pohly [Tue, 17 Oct 2017 20:21:04 +0000 (15:21 -0500)]
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>
6 years agoFactor out equivalent code from ttyread/ttysend
Devin J. Pohly [Mon, 16 Oct 2017 01:35:48 +0000 (20:35 -0500)]
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>
6 years agoMove opt_* into same file as main()/run()
Devin J. Pohly [Fri, 13 Oct 2017 03:25:49 +0000 (22:25 -0500)]
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>
6 years agoMove key-matching functions into x.c
Devin J. Pohly [Wed, 11 Oct 2017 13:47:14 +0000 (08:47 -0500)]
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>