Commit Graph

321 Commits

Author SHA1 Message Date
Carlos Alves
6bf62a2ae1 Reflow the _history
Reflow the _history when the terminal resizes.
Reflow when a new text goes from _screenLine to _history.
2020-12-31 10:52:56 +00:00
Carlos Alves
6bcc306460 Join line when sending to history
Before adding new lines to history it will check if it is a warpped
line and join it.
2020-12-31 10:52:56 +00:00
Carlos Alves
155cedeca2 Keep the lines property
Instead of assign LINE_DEFAULT to next line, it will keep the current
line property.
2020-12-31 10:52:56 +00:00
Tomaz Canabrava
bccd0a3fcd Fix crash acessing wrong index 2020-12-31 10:52:56 +00:00
Carlos Alves
4d4d70d616 Ignore current cursor line
Don't need to reflow the current cursor line. (it will bug and crash)
2020-12-31 10:52:56 +00:00
Carlos Alves
2be00da524 Changed from 'NewLine' char to _lineProperties
_lineProperties is something that existed before. And in some Terminal
emulators it was used to wrap lines, I'm using it now to wrap lines
while resizing.
And improved the _history flux control when resizing.
2020-12-31 10:52:56 +00:00
Carlos Alves
284ed7aec2 _history management of _screenLines when resizing
Count the aditional lines that will be needed by the new size, if
more than 'new_lines', send to history.
2020-12-31 10:52:56 +00:00
Carlos Alves
ff0681d4c3 Change _screenLines to QVector
It was a fixed size array, as a QVector it will change size faster
without the need of memory allocation.
2020-12-31 10:52:56 +00:00
Carlos Alves
86a486934e Reflow lines when Terminal resizes: both ways
An attempt to resize on both ways: shrink and expand.

Still thinking on how to handle _history
2020-12-31 10:52:56 +00:00
Tomaz Canabrava
5cd00fd885 Reflow lines when Terminal Shrinks
There are plenty of bugs here, this is a *serious* wip.
This is also the biggest feature that is missing from konsole for
years and years.

todo:
- Handle history
- Handle increase of columns in terminal size
- handle new lines
2020-12-31 10:52:56 +00:00
Carlos Alves
bc6517593a Screen cursor position calculation and safeguards
Some improvements in calculations and safeguards when changing
cursor position, using defined value in Vt102Emulation.cpp to
protect the integers.
Added cursor position tests to ScreenTest.
Vt102Emulation MAX_ARGUMENT calculation wasn't correct, it was
sending an argument bigger than max argument.
2020-12-27 17:43:04 +00:00
Carlos Alves
2d58ed0281 Revert 'Fix bold character color paint'
This reverts commit 270d6ea324

Need aditional tests.
2020-12-18 18:46:42 -03:00
Edwin Pujols
8de0e6c78e Screen: Remove superfluous guards.
The code commented with `nowrap!` has no use: `_cuX` and `_cuY` get
updated to this value on image resize. This code also appeared in
functions unrelated to horizontal wrapping.

I also took the liberty to update the conditions which determine whether
to use "default values". Before, the conditions only checked for zero
instead of (invalid) negative numbers (maybe a few Q_ASSERT's are
desired here?).
2020-12-18 17:29:08 +00:00
Gustavo Carneiro
200e910fbc Move decoders to a new library konsoledecoders. 2020-12-13 11:58:04 +00:00
Gustavo Carneiro
86baf22c01 Move ExtendedCharTable to characters library. 2020-12-13 11:58:04 +00:00
Gustavo Carneiro
047449b471 ExtendedCharTable: Remove konsoleprivate dependencies. 2020-12-13 11:58:04 +00:00
Gustavo Carneiro
3afa3482b6 Move PlainTextDecoder to decoders folder. 2020-12-13 11:58:04 +00:00
Gustavo Carneiro
61f7ce0f0c Move HTMLDecoder class to a new folder decoders. 2020-12-13 11:58:04 +00:00
Carlos Alves
270d6ea324 Fix bold character color paint
Konsole was painting 'bold' character as 'faint bold' character.

BUG: 405345
FIXED-IN: 20.12
2020-12-01 03:19:06 +00:00
Kurt Hindenburg
0f656a32ff Remove 'This file is part of' comment lines 2020-11-12 22:35:45 -05:00
Kurt Hindenburg
78a0092522 Convert src to use SPDX license/copyright
https://community.kde.org/Policies/Licensing_Policy#SPDX_Statements
https://community.kde.org/Guidelines_and_HOWTOs/Licensing
2020-11-12 22:17:06 -05:00
Carlos Alves
2285d4ecc5 Fix a memory leak in class Screen 2020-10-10 08:07:47 -03:00
Martin T. H. Sandsmark
2c1ec710df fix moving overlapping lines 2020-10-04 02:17:47 +00:00
Martin T. H. Sandsmark
b6a945e4c9 improve performance of Konsole::Screen::moveImage with more than 2x. 2020-09-18 17:53:27 +00:00
Tomaz Canabrava
faceafcc68 Extract URL from a Escape Sequence and provide a HotSpot for activation
This path adds a new feature for konsole, in the form of URL Escaped
Sequences. It allows programs to embbed URL's on texts much like
the anchor tag in html does

There's a allowed list of possible schemas for links, by default
it only accepts http://, https:// and file:// but the user can
add more if he wants.

The maximum amount of URL's accepted is 200, to prevent OOM

History is taken into account while scrooling
2020-08-12 08:20:58 +00:00
Gustavo Carneiro
9f71cc38f3 Move PlainTextDecode and HTMLDecoder Classes to a new files. 2020-07-28 12:16:59 +00:00
Tomaz Canabrava
0478529c6f Move Profile related classes to it's own folder
This also allowed me to remove a few includes of Profile.h
around the codebase, that used Profile::Ptr. now the compilation
is a bit faster and also does not recompile things as often.
2020-07-27 19:14:53 +02:00
Gustavo Carneiro
fdad2645f1 Move History files to a new folder. 2020-07-22 00:00:33 -03:00
Gustavo Carneiro
616db49e69 Remove unused History.h and History.cpp files." 2020-07-21 23:47:34 -03:00
Kurt Hindenburg
9af85cd2ea Fix integer literal suffix 'u' is not upper-case 2020-07-15 23:53:09 -04:00
Luis Alves
66c830484c Add new ANSI sequences CNL and CPL
- It implements Cursor Next Line (CNL) sequence.
- It implments Cursor Previous Line (CPL) sequence.
- Ex: echo -e "Hello\e[3EWorld" or echo -e "Hello\e[3FWorld"

BUG: 418519
FIXED-IN: 20.08

https://invent.kde.org/utilities/konsole/-/merge_requests/116
2020-07-04 17:12:29 -03:00
Lukasz Kotula
b5d02842fc Fix for a crash caused by buffer-overflow in case of '>=1024' columns
'Konsole::Screen` defined an array of 1024 elements, where user
may resize the konsole to have more columns than this array can handle.
Selecting a row in such case, is going to cause a buffer-overflow.

Bug: 330066
2020-06-19 23:27:32 +00:00
Tomaz Canabrava
56ffdbbb29 Correctly handle selection and opening via clicks
Before we opened a link via mousePress but if we want to make a
selection that will open a file and drag.

Now we check if there is a selection before trying to open something.
So if you click and drag a url, it will not open. If you directly
click and release without dragging, it will open.

FIXED-IN: 20.08

https://invent.kde.org/utilities/konsole/-/merge_requests/9
2020-06-05 22:44:32 -04:00
Kurt Hindenburg
ab0636de8a Q_UNUSED() does not need semi-colon at end 2020-03-28 14:06:25 -04:00
Kurt Hindenburg
180a366d97 Add comment for reference 2020-01-01 17:05:52 -05:00
Kurt Hindenburg
259a11c9f5 Remove unused method writeSelectionToStream 2019-12-22 21:58:13 -05:00
Mariusz Glebocki
ce2029ed75 Keep empty lines when "trim leading spaces" is enabled
BUG: 412479
2019-10-05 19:13:46 +02:00
Mariusz Glebocki
7a1116ccff CSI 2J: Do not append current screen to history
Summary:
This behavior is present in e.g. xterm and linux console.

Currently when using CSI 2J escape sequence, screen contents are
appended to scrollback (including bottom empty lines). This is breaking
`clear` command, which replaces scrollback with current screen contents.

BUG: 384218

Test Plan:
* Start Konsole with a shell
* `clear`

**Expected result:**
Cleared display, empty scrollback.
**Actual result:**
Cleared display, but scrollback contains previous display contents.

---

* Start Konsole with a shell
* seq 1000
* `echo -ne '\033[2J`

**Expected result:**
Cleared display, numbers in last scrollback lines.
**Actual result:**
Cleared display, but scrollback contains previous display contents
(i.e. shell prompt in last lines)

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D21282
2019-06-15 17:03:13 -04:00
Martin T. H. Sandsmark
5006d0e194 Re-introduce bounds check removed in fcea6742c1
https://phabricator.kde.org/D16010

BUG: 398320
2018-10-08 14:19:21 +02:00
Mariusz Glebocki
0f33ee504b Move character width functions to Character class
Summary:
Replaces direct konsole_wcwidth() calls with Character object property
and the class static function, which internally still use
konsole_wcwidth().

The change also prepares the codebase for a new code for determining
character width. This way the change will barely touch existing code.

CCBUG: 396435

Test Plan:
konsole_wcwidth() is still used, just in one central place. Passed
compilation and CharacterWidthTest should be enough.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D15756
2018-09-26 22:46:12 -04:00
Mariusz Glebocki
fcea6742c1 Move search line upper bound check to less generic function
Summary:
When there was at least one search attempt, search box is still opened,
and the screen and/or history is cleared, there is a high chance that
the line number remembered by the search is invalid. The line number is
used as the lines array index, so this can lead to overflow and crash.

This is at this moment fixed with a check in `copyLineToStream()`, which
is a generic function that happens to be used by search function and
where the line number is used. There still is an `assert` which is
triggered in debug builds.

The patch moves the check directly to a search function, where the line
number is initialized before first search.

Test Plan:
You have to do the test in debug build - there is a hack in
`copyLineToStream()` which prevents crash, but `assert` before it
catches an error condition.

* Run `seq 5000`
* Open search box, search for `000`
* Clear screen/history
* Search up/down

Actual result: Crash
Expected result: Search should begin from last/first visible line

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D14106
2018-07-14 13:11:42 -04:00
Mariusz Glebocki
5128781a82 Change internal character type size to 32 bit
Summary:
Currently Unicode uses 0x10FFFF code points. It is possible to represent
all of them with up to two 16 bit values (UTF-16), but this makes it
harder to e.g. check for their width.

Some test cases were changed. Originally they were added with an
assumption that the code point will be truncated to 16 bit value and
as a result changed to another code point.

Test Plan:
* All code points <= 0xFFFF should work as before
  * Start the same tmux session in two Konsoles
  * Change background to fully transparent in one of them and put it in
    front of the other one, so that all text will overlap
  * Generate characters with (you can pipe it to `fold -s | less -r`):
```
perl -XCSDL -e 'print map{chr($_), " "} 1..0xffff'
```
  * Compare output visually.

* Code points > 0xFFFF should not be truncated to 16 bits
  * "𝐀" and "퐀" should be different characters

* Some code points > 0xFFFF should have single width
  * Vertical lines below should align:
```
|𝐀 |
|𠀋|
```

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: konsole-devel, hindenburg, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D12236
2018-05-16 10:03:57 -04:00
Mariusz Glebocki
f65e5a5797 Fix cursor advancement in last column
Summary:
Until now, the cursor was moved from last column to the next column
outside the screen. Since screen array is linear, it partially worked
like it was on the beginning of a next line (as long as it was not the
last line).

Test Plan:
* Run `cat > /dev/null` (shells do their own line wrapping, so will
  not work)
* Move cursor to terminal's last visible line using enter
* Move cursor to terminal's last visible column by typing something
* Type one more character

Expected result: new line should appear with the cursor on the beginning
Actual result: cursor disappears, no new line

* Turn on blinking cursor
* Run `cat > /dev/null`
* Move cursor to terminal's last visible column by typing something
* Type one more character

Expected result: the cursor should move to new line's first column
and blink
Actual result: the cursor "moves" but does not blink

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: konsole-devel, hindenburg, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D12554
2018-05-14 10:46:40 -04:00
Mariusz Glebocki
61069543e0 Do not resize new screen lines
Summary:
The lines are resized when something is put in them. Resizing them
here filled them with spaces (default value), later those trailing
spaces were put into history, and eventually into saved output or
clipboard (because it is assumed lines in history do not contain
trailing spaces).

BUG: 392419

Test Plan:
* Enable "Trim trailing spaces" in Profile Settings → Mouse
* Set window size to about 100x100px
* Clear terminal (Ctrl-Shift-K by default)
* Run:
```
seq $(( $(tput lines) * 2 )); \
printf '*** resize ***'; read -s; printf '\n'; \
seq $(( $(tput lines) * 2 ))
```
* When "resize" show up, resize the window to about 500x500px
* Press enter
* Select and copy lines below `*** resize ***`
* Paste it in a text editor which allows to show trailing spaces

Expected result: lines should not contain trailing spaces
Actual result: lines added when resizing the window have trailing spaces

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11893
2018-04-03 17:14:51 -04:00
Kurt Hindenburg
8b4cbcaf7a Use constuctor initialization list for all members 2018-04-01 11:30:45 -04:00
Kurt Hindenburg
474db53ff7 initialize _currentTerminalDisplay 2018-03-27 20:19:06 -04:00
Kurt Hindenburg
b8a2f0cfd0 Add support for ECMA-48 REP: repeating previous character
Patch by btown using lxde/qtermwidget@60221da by @yan12125

ECMA-48 8.3.103 describes the sequence CSI Pn b for repeating the
previous character in the data stream. This sequence has been present
in XTerm since January 1997 and has been added to the latest terminfo
entry for xterm-new and derived entries such as xterm-256color.

https://phabricator.kde.org/D10064
2018-02-04 14:09:28 -05:00
Kurt Hindenburg
bed548e85a sync declarations with definitions (have .h and .cpp variable names match) 2018-01-06 16:39:16 -05:00
Kurt Hindenburg
43c17379c2 fix a few readability-implicit-bool-cast issues 2018-01-03 08:52:10 -05:00
Kurt Hindenburg
f1d9285316 readability fixes - braces 2018-01-02 11:22:26 -05:00