Commit Graph

780 Commits (e7ef3c4ce95a21cfcd0988d493f636e1d0115871)

Author SHA1 Message Date
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 65976c1a29 Move config.h include from st.c to x.c
config.h includes references to KeySyms and other X stuff.  Until we
come up with a cleaner way to separate configuration, it is simpler
(leads to more code removal) to have this here.

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Suraj N. Kurapati ee5cc8e903 base64dec: skip non-printable characters like \r\n
Non-printable characters, such as line breaks, in a base64 encoded
string violate the "string length must be a multiple of four" rule.

This patch pads the result buffer by one extra unit of four bytes,
and skips over non-printable characters found in the input string.
2017-09-15 11:13:17 +02:00
Quentin Rameau 8dacdfbab1 Revert "Add bold off SGR"
This reverts commit 6cb6d61525.
This wasn't a useful thing after all.
2017-07-12 13:29:31 +02:00
Quentin Rameau 6cb6d61525 Add bold off SGR 2017-06-03 22:28:35 +02:00
Alexander Krotov 149c0d3aed Fix commented out code 2017-03-29 18:46:20 +02:00
osandov@osandov.com e7ed326d2e Support xterm Ms feature to set clipboard
This is used by, e.g., tmux.
2017-03-19 20:32:22 +01:00
Michael Forney e2ee5ee611 Split X-specific code into x.c 2017-01-20 19:42:26 -08:00
fpqc c63a87cd93 Move column and row default numbers into config.h 2016-12-16 10:50:23 +01:00
Roberto E. Vargas Caballero e44832408b Revert "Initial font size issue."
This reverts commit 424202798b.
2016-11-24 20:21:19 +01:00
Spencer Phippen fa9a459972 Fixed 'missing glyph doesn't use fontconfig config substitutions' bug
XftFontMatch does display-specific font configuration (commit 528241a).
Nice. Unfortunately, when we switched from FcFontMatch, we also stopped
storing the post-Fc{Config,Default}Substitute FcPattern for future
lookups. The result is that if a glyph isn't found in the primary font,
secondary font lookups use the original FcPattern, not the configured
one. If you have custom fontconfig rules (like me), this can be
disappointing.

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

[1]: https://cgit.freedesktop.org/xorg/lib/libXft/tree/src/xftfont.c
2016-11-24 20:20:45 +01:00
ian@remmler.org 424202798b Initial font size issue.
Hi,

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

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

I found that adding the pixel size (acquired from the initial font load) to the
pattern then reloading the font fixes the problem.  I'm not sure if this is a
proper fix, though.
2016-11-14 19:27:55 +01:00
pl@ninthfloor.org 902a392b90 Make strdump(), csidump(), print to stderr
The two functions strdump(), csidump() are called to show errors and
their output is introduced by a message printed to stderr. Thus, it it
more consistent to have them print to stderr.

Moreover stderr is unbuffered (at least on Linux), making problems
immediately visible.
2016-11-14 18:36:38 +01:00
Quentin Rameau 8c99915608 Do not use color when font attributes are supported
If fontconfig gives us a font without the attributes we asked for,
display an alternative color instead.
2016-10-23 17:56:46 +02:00
Quentin Rameau 68bae9c7b1 Add support for iso14755
We launch dmenu for getting a codepoint, then convert it and send it to
the terminal.
2016-10-18 13:32:36 +02:00
Roberto E. Vargas Caballero f7398434b8 Add parsing of DCS q sequences
These sequences are used to operate with sixels, but they are still
str sequences, so they are finished with \a, ST or with a C1 control
code. This patch also disables utf8 handling for the case of sixels.
2016-09-14 08:27:32 +02:00
Roberto E. Vargas Caballero f0e2d28732 Add support for enabling/disabling utf
There are some ocasions where we want to disable the enconding/decoding of utf8, mainly
because it adds an important overhead. This is partial patch for ESC % G and ESC % @,
where they modified the way that st reads and write from/to the serial line, but it does
not modifies how it interacts with the X window part.
2016-09-13 14:01:18 +02:00
Christoph Lohmann 528241aa38 Use XftFontMatch in place of FcFontMatch.
git am -s didn't like your patch:

From: Mark Edgar <medgar123@gmail.com>

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

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

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

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

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

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

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

Signed-off-by: Ton van den Heuvel <tonvandenheuvel@gmail.com>
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-03-08 15:43:52 +01:00