Commit Graph

1039 Commits (30ce2cc002585409b36c630512c6ca4db8f88f15)

Author SHA1 Message Date
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