Commit Graph

321 Commits

Author SHA1 Message Date
Ahmad Samir
97569b764c Run clang-format on the whole repo
Also install the relevant git hook.

GIT_SILENT
2021-09-06 12:51:39 +02:00
Luis Javier Merino Morán
ed7fe4a2cb Resize lines when clearing to end of line.
clearImage() just clears until _columns.  To prevent characters from
beyond _columns from reappearing, e.g. due to DCH (Delete CHaracters)
requests, make clearImage() resize lines when clearing to the end of
line.

BUG: 432669
2021-07-16 10:55:07 +00:00
Ahmad Samir
38208f94cd Add option to always invert text selection colours
The recent change of blending the background/foreground colours for text
selection doesn't work everywhere, users with vision impairment or
colour-blindness would probably find it hard to distinguish text selection
colours; and the current code can't possibly cover all variations of colour
schemes out there. The same goes with certain displays and viewing angles,
some display types are notoriously awful when viewed at an angle.

BUG: 435309
FIXED-IN: 21.08
2021-06-22 11:56:47 +02:00
Ahmad Samir
4ef7296b94 General code cleanup
- Add a type alias for QPointer<Session>
- Use TerminalDisplay::setSessionController() as early as possible
- Use Screen::setCurrentTerminalDisplay() in TerminalDisplay::mousePressEvent(),
  this matches what's being done in keyPressEvent()
- Add convenience function TerminalDisplay::currentSession()
- More const
2021-06-22 11:52:06 +02:00
Tomaz Canabrava
7f647bac68 Simplify logic 2021-06-18 11:29:20 +00:00
Tomaz Canabrava
17c3b96235 Fix block selection on reflowed lines 2021-06-18 11:29:20 +00:00
Carlos Alves
c0355ccd42 Access changes QList and Add in Screen
Avoid deep copy using 'at()' and '++' before variable instead of after.
2021-06-15 16:10:35 +00:00
Carlos Alves
4ce6ea9132 Change lineProperties to QVector in Screen
Added access changes using 'at()' at reflow code to avoid deep copy.
2021-06-15 16:10:35 +00:00
Carlos Alves
7b2a751b30 Fix Screen::_cuY position inside screen
Keep _cuY position inside max screen lines in AppScreen mode.
2021-05-05 14:11:34 +00:00
Luis Javier Merino Morán
0ecc366c02 Fix crash on resize while doing other things
Commits 9ffe33a27a and
4352df00d9 introduce and use a
getScreenLineColumns(line) method to provide support for DECDWL
(Double-Width) lines.

It turns out that under some conditions on resize Screen::_cuY (the
current cursor Y position) and ScreenWindow::endWindowLine() can have
different ideas of how many lines the terminal has.

A test that asserts:

 - while [ true ]; do echo -e "\e[?1047h";  done
 - Resize the window, making it smaller

BUG: 436327
2021-05-05 14:00:23 +00:00
Luis Javier Merino Morán
d5b290aa48 Fix potential crash in Screen::restoreCursor
Restore Y coordinate before X coordinate, so we make sure Y is in bounds
before trying to access _lineProperties depending on Y.

To test:

 - Go to the last line
 - tput sc
 - Shrink the terminal
 - tput rc
2021-05-05 14:00:23 +00:00
Carlos Alves
2aa61bb994 Change CompactHistory data storage
It is removing the vector of lines storage. Now it is using a similar
idea used in history file.

All chars are stored in a linear way, only the line indexes are
changed when reflowing.

No speed problem found when removing lines.
2021-05-03 19:39:47 +00:00
Luis Javier Merino Morán
05d81656f2 Do not reflow double-height lines
Double height lines are actually two lines, the first with the top part
of the characters, the second with the bottom part. Reflowing could lead
to situations where we render a top part, a double height line with its
top and bottom parts, and a bottom part, which looks weird.
2021-04-17 14:01:06 +00:00
Luis Javier Merino Morán
3cd160f5a0 Prevent selecting beyond last column on double-width lines
There is a difference with xterm behavior: when the screen width is an
odd number of columns, xterm allows selecting up to columns/2+1, we just
allow selecting up to columns/2.
2021-04-17 14:01:06 +00:00
Luis Javier Merino Morán
9771b1d99d Make reflow aware of line rendition attributes
While DECDHL/DECDWL lines are not wrapped at the correct column, now at
least reflowing doesn't clear line rendition attributes, so resizing
Konsole and going back to the original size always recovers the original
content, including double-height/double-width status of each line.

Reflowing double-height lines doesn't make much sense, since a
double-height line actually consists of a top (T) and a bottom (B)
line. Shrinking them could lead to TTBB lines, which look weird. At
least now going back to the original size brings back the original
content in all its glory.
2021-04-17 14:01:06 +00:00
Luis Javier Merino Morán
57ce654da5 Support scrolling double-height/width lines
The scrollback buffer has support for a wrapped property for every line.
Extend it to support the line rendition attributes.
2021-04-17 14:01:06 +00:00
Luis Javier Merino Morán
c61e4cacb6 Allow writing only half of a double-height line
While DECHDL sequences should be used in pairs on adjacent lines, the
first line drawing the top half, and the second line drawing the bottom
half, apparently real VTxxx (or at least the VT220) terminals did draw
only the top or bottom of characters when confronted with an isolated
DECDHL line (https://retrocomputing.stackexchange.com/questions/18023/).
xterm has that same behavior. So behave likewise.
2021-04-17 14:01:06 +00:00
Luis Javier Merino Morán
e1e832f586 Don't clear line rendition on EL and partial ED
EL (Erase Line) should not reset the line rendition attribute to
single-width. ED (Erase Display) should only reset it for completely
cleared lines. ECH (Erase CHaracters) should obviously not reset it.
DECSED and DECSEL (Selective Erase, not supported by Konsole) should not
reset it.

This fixes a vttest test where a line is set to double-height-top and
then EL before writing its text and the double-height-bottom line below.

Can also be tested with:

echo -e "\e[2J\e[4;1HNormal\n\e#6DOUBLE\n\e#6DOUBLE\nNormal" &&
sleep 2; echo -e "\e[5;3H\e[1J\e[8;1H"
2021-04-17 14:01:06 +00:00
Luis Javier Merino Morán
4352df00d9 Use the correct last column for double-width lines
Some control functions special case the last column. When a line has
been set to double-width via DECDWL or DECDHL (double-height and
double-width), the correcr last column for that line should be used.
Control functions which special case the last column include TAB, CUF,
ICH and DECRC.

Can be tested with:

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7l$r";
         $s="L"."\tx"x4 ."\t\tR"; say "\e#3$s\n\e#4$s"'

The above tests that tabs don't travel beyond the last column in
double-width lines.  The last column (below columns 79 and 80 of
the previous line) should have an "R".

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7h$r";
         $s="L"."X"x36 ."\e[6C"."R"; say "\e#3$s\n\e#4$s"'

The above tests that CUF (Cursor Forward) doesn't travel beyond the last
column in double-width lines.  The last column (below columns 79 and 80
of the previous line) should have an "R".

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7h$r";
         $s="L"."X"x22 ."R"."x"x8 ."r"."\e[17D\e[16@";
         say "\e#3$s\n\e#4$s"'

The above tests that ICH (Insert CHaracters; VT200+) doesn't write past
the last column, visible on repaints (switch to another window and
back).

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7h$r";
         $s="L"."X"x38 ."r\e7\e[H\e8R"; say "\e#3$s\n\e#4$s"'

The above tests that DECRC (Restore Cursor) doesn't restore the cursor
to a position beyond the last column on double-width lines.  The last
column should have an "R", "r" should not be visible.

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7l$r";
         $s="L"."X"x38 ."R"; print "\e#6$s"'; sleep 5; echo

The above tests that the cursor stays at the rightmost column. The
cursor should stay over the "R" for 5 seconds.
2021-04-17 14:01:06 +00:00
Luis Javier Merino Morán
9ffe33a27a Fix appending characters at end of line in double width lines
Since double-width/double-height lines have room for just half the
characters, take that into account.

Can be tested with:

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7h$r";
         $s="L"."X"x38 ."RL"; say "\e#6$s"'

The above tests that appending characters to double-width lines in
DECAWM (Auto Wrap Mode) wraps at the correct last column. There should
appear a second line (single-width) with a single "L".

perl -E '$r=join "", map{$_%10}1..80; say "\e<\e[?40h\e[?3l\e[?7l$r";
         $s="L"."X"x42 ." TEST FAILED OUTOFBOUNDS R"; say "\e#6$s"'

The above tests that appending characters to double-width lines in
non-DECAWM (Auto Wrap Mode) doesn't write past the last column (visible
on repaints - switch to another window and back). The last column (below
columns 79 and 80 of prev line) should have an "R".
2021-04-17 14:01:06 +00:00
Ahmad Samir
acd265efab Less delete calls in destructors
- If the QObject has a parent, the parent will take care of deleting it
- Use std::unique_ptr to manage pointer member variable
- Use '= default' with empty destructors
- Fix initialization of QTimer in constructor initialization list
2021-04-04 17:21:22 +00:00
Carlos Alves
3b0a81feed Screen and HistoryScroll pointers to smart pointer
Those Classes are not QObject, so most of it's pointers could be changed
 to smart pointers with no problems.
Problem found when using QList<std::unique_ptr>: it wasn't possible to
use it. I'm using std containers instead.
2021-03-26 06:22:24 -03:00
Kurt Hindenburg
7c38e53290 Fix spelling error 2021-03-10 10:00:19 -05:00
Carlos Alves
25a24bf347 Fix zsh reflow
This will fix most of the zsh themes reflow, still working on other
themes.
zsh command line position is different from other shells, it is not
where the cursor line is. Konsole is correcting this position.
2021-02-20 15:11:31 +00:00
Carlos Alves
9d04122272 Fix ReFlow bug while Splitting View
History content was changing when splitting the view.
2021-02-20 09:15:19 -03:00
Kurt Hindenburg
52a9df577d Comment out auxiliar functions to test Screen
for_each_n() doesn't compile w/ gcc 8.3.x

BUG: 432639
2021-02-18 21:23:06 -05:00
Jan Blackquill
3b06b6f22a Improve appearance of text selection
By blending foreground & background instead of swapping them, you can
get a more visually appealing text selection.
2021-02-10 18:03:05 +00:00
Kurt Hindenburg
6917117079 Correct comments 2021-02-07 22:10:31 -05:00
Carlos Alves
986aed091c Fix moveImage error
While changing some functions with STL, I though it was possible to move
the line from source to destination, but it is causing a problem with
console programs status line (ex: htop).

BUG: 432005
2021-01-25 23:03:10 -03:00
Carlos Alves
e4a0c20821 Move fixed size reflow
Moving the fixed size history reflow code to compactHistoryScroll file.
Screen file will not handle history reflow, unlimited scroll is
completely different from fixed size scroll reflow.
2021-01-22 02:31:36 +00:00
Carlos Alves
0f8d4e0ca7 Fix unlimited history reflow bug
It was joinning the reflowed lines in history but in compact history it
does reflow again. It will now just ignore it and add to history.

BUG: 431624
2021-01-15 12:27:53 +00:00
Carlos Alves
079a73d735 Screen reflow speed and fix history reflow bug 2021-01-07 12:59:19 -03:00
Carlos Alves
07c69ba7a3 Reduce the number of loops to Reflow
Reduce the number of needed loops to reflow the lines to increase
preformance.
2021-01-06 20:02:22 -03:00
Carlos Alves
48aef6abdf Added profile option to enable/disable reflow
As pointed in bug report 196998, some people don't want to use it.
It is in scroolling group.
2021-01-06 20:02:22 -03:00
Carlos Alves
bc2b89c2a6 Fix of visual glitches with Unlimited scroll
Reordering the data flow and change the function
2021-01-06 20:02:22 -03:00
Carlos Alves
5b1aaa657c Reflow lines with unlimited scroll
It is not reflowing unlimited history lines (there is no limit and it
can be very long), it just reflow screenlines and join the lines when it
get to history.
2021-01-06 20:02:22 -03:00
Carlos Alves
4f1864abf2 Reflow lines when Terminal resizes 2021-01-06 20:02:22 -03:00
Tomaz Canabrava
e71df623e4 Revert "Reflow lines when Terminal Shrinks"
Unfortunately the code is still fragile and I froze konsole
a few times in a few minutes. This is something that konsole
really needs, but we need more time to squish all the bugs
we find.
2020-12-31 11:45:53 +00:00
Tomaz Canabrava
dec1ad5d92 Revert "Fixed limits and Urls bugs"
This reverts commit 6d9c1d27a1.
2020-12-31 11:07:47 +00:00
Tomaz Canabrava
37218fe8f0 Revert "Reflow when executing an app"
This reverts commit 876a1752a1.
2020-12-31 11:07:30 +00:00
Carlos Alves
876a1752a1 Reflow when executing an app
The reflow need to guess where the cursor line is when the user change
the konsole window size while executing an app.
2020-12-31 10:52:56 +00:00
Carlos Alves
6d9c1d27a1 Fixed limits and Urls bugs
- Columns and lines limits fixed.
- Verify if it's needed to remove an URL after remove of _history lines.
2020-12-31 10:52:56 +00:00
Carlos Alves
4e10daa261 Fix visual glitches and performance
Some visual glitches with scroll position while changing screen size.
2020-12-31 10:52:56 +00:00
Carlos Alves
a9d5945500 Ident and wait 2020-12-31 10:52:56 +00:00
Carlos Alves
c6eed957df Fix _history limits and increase performance
There was a bug on _history limits, now it is fixed.
Increase the "_screenLines to _history when needed" performance
2020-12-31 10:52:56 +00:00
Carlos Alves
02ba277d0f Reflow current cursor bug
Calculate the current cursor position lines needed.
2020-12-31 10:52:56 +00:00
Carlos Alves
73ed15f215 Reflow from _history to _screenLine
Keep the current cursor position and have a better visual continuity
with _history lines.
2020-12-31 10:52:56 +00:00
Carlos Alves
a0719bbe68 Adjust minimal line and column
Reflow does not work when columns < 17 and/or lines < 3.
Seems to me there is a conflict of the window pixels size limit, the
columns that it can paint within those limits and the mouse position
when adjusting to the minimal window size.
2020-12-31 10:52:56 +00:00
Carlos Alves
14601a86a5 Reflow bug fixes
- Missing properties causing reflow bug.
- _screenLines[0].data() not working as I thoughit would.

TODO:
- Check the bug when columns around less than 25.
- Keep current line and take from _history to _screenLine.
- Check how and if it affects file history.
2020-12-31 10:52:56 +00:00
Carlos Alves
110b36a03a Missing to set property for the new line
It didn't crash or bug, but to be sure it won't.
2020-12-31 10:52:56 +00:00