32 Commits

Author SHA1 Message Date
Kovid Goyal
68cf9f7514
Switch to tracking linewrap on the last cell in a line
This allows us to have newline not affect the wrap status of a line.

Now a lines wrapping status is changed only when the last cell
in the line is changed. This actually matches the behavior of many other
terminal emulators so is probably a good thing from a ecosystem
compatibility perspective.

The fish shell expects this weird behavior of newline not changing
wrapping status, for unknown reasons, which is the actual motivation for
doing all this work.

Fixes #5766
2022-12-26 20:26:21 +05:30
Kovid Goyal
16b322616a
Fix cursor position at x=0 changing to x=1 on resize
Fixes #5635
2022-10-31 08:03:42 +05:30
Kovid Goyal
c43637f6cc
Dont copy prompt start bits to multiple lines when resizing the screen
This makes it unnecessary to modify the prompt marking protocol to
distinguish consecutive prompts without output in between
2021-11-07 18:00:06 +05:30
Kovid Goyal
28914d4450
Remove a macro that is not really needed anymore 2021-08-18 10:06:09 +05:30
Kovid Goyal
4000cce81c
DRYer 2021-08-18 10:06:09 +05:30
Kovid Goyal
35ad366427
Fix incorrect prompt marking on screen resize
Forgot to initialize line attrs for src lines in the LineBuf
2021-08-18 10:06:09 +05:30
Kovid Goyal
b260a61c8f
Get rid of bits from LineAttrs 2021-08-18 10:06:08 +05:30
Kovid Goyal
1f5fa03015
Use a union for line attrs
Allows faster construction of Line objects without needing to set
individual booleans. And cleaner code.
2021-08-18 10:06:08 +05:30
Kovid Goyal
196200d03f
Dont reflow the current prompt when resizing
This ensures that there is no leftover line when the shell redraws the prompt,
by making the prompt a simple single character prompt before rewrapping.
2021-08-18 10:06:04 +05:30
Kovid Goyal
f2ca0424a0
Use correct src_line for attrs copy when rewrapping 2021-08-18 10:06:04 +05:30
Kovid Goyal
4a9a021b2c
DRYer 2021-08-18 10:06:04 +05:30
Kovid Goyal
d4dd226d8f
Preserve prompt markings when copying lines and rewrapping them 2021-08-18 10:06:04 +05:30
Kovid Goyal
c60a941d1b
Allow rewrap_inner to track multiple positions 2021-06-03 12:29:27 +05:30
Kovid Goyal
a78515e5bf
Remove the max size limit for line_as_ansi
Needed for output of hyperlinks, also more efficient, since avoids
malloc per line. Also fix pagerhist not having SGR reset at the start of
every line.
2020-09-20 11:26:59 +05:30
Kovid Goyal
b4693dc1b3
Fix some lines in the scrollback buffer not being properly rendered after a window resize/font size change
Fixes #2619
2020-09-18 08:26:50 +05:30
Kovid Goyal
6a31909557
Make the MIN and MAX macros typesafe 2019-07-01 17:03:47 +05:30
Kovid Goyal
16542e96bf
Fix resizing window smaller and then restoring causing some wrapped lines to not be properly unwrapped
Fix #1206
2018-12-06 12:56:24 +05:30
Kovid Goyal
8dea5b3e3e
Reduce data sent to GPU per draw by 30%
Split up the Cell structure into a CPUCell and a GPUCell. Only the
GPUCell part needs to be sent to the GPU. Should make kitty use even
less system resources and make a performance difference on systems where
the GPU bandwidth is constrained.

Also allows adding more CPU only data in the future without affecting
GPU bandwidth. For example, hyperlinks or more combining characters.
2018-05-27 21:25:09 +05:30
Kovid Goyal
1fe936dbbc
Fix off by one when restoring cursor position after resize. Fixes #344 2018-02-25 09:15:48 +05:30
Kovid Goyal
2ee9844c2b
Track cursor position explicitly during rewrap
Instead of using heuristics to position the cursor after a resize, track
the position during re-wrapping and place the cursor at the re-wrapped
position. Fixes #242 (I hope)
2018-02-02 13:06:18 +05:30
Kovid Goyal
0fcce6ec58
Remove trailing whitespace from native code files 2017-12-20 08:44:47 +05:30
Kovid Goyal
0277be5856
Track line dirty status in the line buffer 2017-11-09 16:55:45 +05:30
Kovid Goyal
3ca45ab241
Fix cursor moving one line up when resizing 2017-09-20 10:59:31 +05:30
Kovid Goyal
a92b3c605f
Move the text attributes out of the char type
This means that more text attributes can be added in the future (there
are 8 bits available) and there is no need to keep bit twiddling when
accessing the chars themselves. Also means less data needs to be sent to
the GPU. Cell size does not change since there were currently 2 unused
bytes because of alignment.
2017-09-16 11:02:42 +05:30
Kovid Goyal
bc97cfa024
Use a null to represent a blank rather than a space
This has performance benefits when clearing (can use a single
memset). Also allows detecting trailing whitespace on lines correctly.
2017-09-15 10:45:16 +05:30
Kovid Goyal
e8b5a72c96
Remove GIL management code since it is no longer needed 2017-09-15 10:45:11 +05:30
Kovid Goyal
4fd8c7cfaa
DRYer 2017-09-15 10:45:08 +05:30
Kovid Goyal
0cbd3a2820
Start work on using a struct for the cell
Should eventually allow the screen buf to be sent directly to the GPU
without a serialization step.

Migrates line-buf.c
2017-09-15 10:45:07 +05:30
Kovid Goyal
69b187a743
Split up the color field into fg/bg colors
Avoid a lot of unnecessary masking as well as unaligned read/writes
2017-05-15 12:06:06 +05:30
Kovid Goyal
271e3360ff Fix top lines appearing at bottom when resizing a screen that seen more lines than the number of lines available 2016-12-12 10:58:18 +05:30
Kovid Goyal
f8403d4dec Fix screen being deleted on resize
Also fix crash when resizing the altbuf
2016-11-21 09:34:16 +05:30
Kovid Goyal
5dccb91996 Make the rewrap algorithm re-useable for rewrapping of HistoryBuf as well 2016-11-20 22:22:39 +05:30