Commit Graph

145 Commits

Author SHA1 Message Date
Mariusz Glebocki
90b4f33965 Fix token buffer indexing
BUG: 415249
BUG: 415463
2020-01-04 18:23:27 +01:00
Laurent Montel
cd3cfda019 Don't use 0/nullptr as flag 2019-12-09 13:37:41 +01:00
Yuri Chornoivan
7bcf92696b Use URLs with transport encryption 2019-11-16 18:02:41 +02:00
Mariusz Glebocki
324d78c07f Fix OSC sequence parsing
printf '\033]2;aaa\033bbb' prints bbb
printf '\033]2;aaa\033\\bbb' prints bbb
printf '\033]2;aaa\033' prints nothing;
        title is changed when next character is received.
printf '\033]2;aaa\033\\' prints nothing
printf '\033]2;aaa\007bbb' prints bbb
printf '\033]2;aaa\007\\bbb' prints \bbb
printf '\033]2;a\ra\na\033bbb' prints bbb
printf '\033]2;a\ra\na\033\\bbb' prints bbb
printf '\033]2;a\ra\na\007bbb' prints bbb
       In each case the title is set to aaa

BUG: 231405
FIXED-IN: 19.12.0
2019-11-02 12:01:47 -04:00
Mariusz Glebocki
0deb808bbb Use uint for ucs4 characters 2019-11-02 11:58:49 -04:00
Kurt Hindenburg
b792c52f27 Remove old commented out code 2019-02-19 23:28:53 -05:00
Ahmad Samir
c9276130ac Don't change alternate scrolling state after calling reset()
Summary:
Alternate Scrolling shouldn't be reset when calling resetModes(), this
is to maintain the profile alternate scrolling property after reset()
is called, otherwise calling reset() (or clear scrollback and reset)
will always make alternate scrolling get disabled regardless of the
respective profile property.

Also this matches XTerm behavior.

BUG: 402461

Test Plan:
1 - Open a new tab and make sure the alternate scrolling profile property
    is enabled
2 - Run less or any other application that uses the alternate screen,
    scrolling with the mouse should work
3 - Quit the previous application and execute `reset`
4 - Repeat 2, notice that now scrolling doesn't work

After applying the patch, alternate scrolling mode is not changed after
calling reset.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: konsole-devel, hindenburg

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D17781
2018-12-24 20:41:53 -05:00
Martin T. H. Sandsmark
97f101af8a Use DECSCUSR 0 to reset to default
Summary:
This isn't standardized, but matches what VTE does.

printf '\e[0 q'         # reset to default

Ref. https://bugzilla.gnome.org/show_bug.cgi?id=720821 and
https://bug720821.bugzilla-attachments.gnome.org/attachment.cgi?id=291238

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, ahmadsamir, konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D17266
2018-12-15 15:35:51 -05:00
Kurt Hindenburg
ec5c05751c modernize deprecated header 2018-10-27 22:46:50 -04:00
Ahmad Samir
033e20319f Replace setUserTitle() with setSessionAttribute()
Summary:
Session:setUserTitle() changes various attributes of the current
session/tab, not just the title; change the name from "Title" to
"sessionAttribute" as that's more representative of what the function
does. Propagate the change where appropriate throughout the code.

Remove Vt102Emulation::requestWindowAttribute(), as it's not used
anywhere.

Update a couple of links to Qt and XTerm documentation, respectively.

Test Plan:
Every thing should work as before, for example changing the window title:
- "Show window title on the titlebar" must be enabled
- unset PROMPT_COMMAND (in case it already sets the window title)
- Change the window title:
`printf "\033]2;%s\007" "testing"`

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D13147
2018-05-28 14:07:39 -04:00
Ahmad Samir
a2ad2d70d4 Invert the logic for Mouse Tracking events
Summary:
Previously the logic was to set "usesMouse" (Emulation
MODE_Mouse100{0,1,2,3}) to false to indicate that the program running
in the terminal supports handling mouse events itself, i.e. the program
is interested in receiving Mouse Tracking events; or set to true otherwise.

Since this was confusing, use the inverse logic by replacing "usesMouse"
with "usesMouseTracking".

"usesMouseTracking" is set to true when the program running in the shell
indicates it's interested in receiving Mouse Tracking events. Or false
otherwise.

For example, vim indicates it's interested in receiving Mouse Tracking
evnets when using visual mouse mode:
http://vimdoc.sourceforge.net/htmldoc/intro.html#Normal

Mouse Tracking is an XTerm extension, for more information examine:
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking

Test Plan:
Before:
 - Execute `printf '\e[?1003h'` to enable mouse tracking mode in konsole, now when you move the mouse events will be sent to the terminal when you move, click, drag the mouse
 - Pressing and holding the Shift key should let the mouse act as normal

 - Open a new tab or execute `printf 'e[?1003l'`, then open any file in vim, `:set mouse=a` then select some text with the mouse, note that VISUAL is displayed at the bottom of the window; right clicking _doesn't_ show the context menu as you'd expecte
 - Pressing and holding the Shift key should let the mouse act as normal

Apply the diff, build, and try again, everything should work as before.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D13134
2018-05-28 09:27:48 -04:00
Ahmad Samir
d547d1d177 Ignore control characters in the text part of Xpe "ESC]" sequences
Summary:
Ignore control characters in the text part of Xpe (OSC, Operating System
Control) of the form "ESC]Pn;Pt\a" escape sequences; this matches what
XTerm docs say.

If userTitle is an empty string, set the window title to a blank space
when showWindowTitleOnTitleBar is enabled; basically if the user sets
the title to an empty string, leave it as-is.

BUG: 315581
FIXED-IN: 18.08

Test Plan:
- unset PROMPT_COMMAND, in case the shell is configured to set the
   window title via that variable
- Make sure "Show window title on the title bar" is enabled
- Execute:
$ /usr/bin/echo -e 'j\e]2;\n\aj'
- The window title is changed to the tab title text; and the output
    looks like this:
j
j

- Apply the diff, build, and try again, the window title should be
   set to an empty string (really a blank space), and the output
   should look like:
jj

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D13078
2018-05-24 08:34:44 -04:00
Mariusz Glebocki
847b72358d Silence -Wformat-truncation warnings
Summary:
Add a few bytes to a small arrays on stack in order to make compiler
happy. Those warnings are invalid in this context (as long as terminal
width and height are not larger than 8-digits-long number).

BUG: 394565

Test Plan:
* Build Konsole with GCC 8 and `-Wformat-truncation` flag

Expected result: no format-truncation warnings
Actual result: three format-truncation warnings appear

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D13080
2018-05-23 19:42:26 -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
Kurt Hindenburg
cf1ab2cd86 Check for valid currentView before using it for scrolling up/down 2018-05-12 17:05:06 -04:00
Ahmad Samir
7c2a1164be Add support for Set Cursor Style (DECSCUSR) escape sequences
Summary:
This follows the XTerm escape sequences, which include a couple more
shapes than what VT520 supports.

BUG: 347323
FIXED-IN: 18.08

Test Plan:
To test the escape sequences:
printf '\e[ q'		#blinking block
printf '\e[0 q'		# blinking block
printf '\e[1 q'		# blinking block
printf '\e[2 q'		# steady block
printf '\e[3 q'		# blinking underscore
printf '\e[4 q'		# steady underscore
printf '\e[5 q'		# blinking ibeam/bar
printf '\e[6 q'		# steady ibeam/bar

Executing `reset` in terminal will reset the cursor shape and blinking
settings to the current profile values.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D12193
2018-04-19 09:38:09 -04:00
Ahmad Samir
2a80b02dae Support XTerm Alternate Scroll Mode escape sequences
Summary:
This mimics the XTerm Alternate Scroll Mode 1007

The h (set), l (reset), s (save), r (restore) modes depend on the profile
setting Mouse->Enable Alternate Screen buffer scrolling.

Depends on D12139

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D12140
2018-04-14 05:59:00 -04:00
Kurt Hindenburg
f9d3b79bb2 convert the token parsing from #define to constexpr 2018-04-06 10:35:58 -04:00
Kurt Hindenburg
8b4cbcaf7a Use constuctor initialization list for all members 2018-04-01 11:30:45 -04:00
Mariusz Glebocki
c0a46e2b08 Process key event even without active TerminalDisplay
Summary:
There are (more or less) valid cases when currentTerminalDisplay can be
not set:
* konsole started with `--background-mode`, `sendText` called via D-Bus
* text send through KPart's `sendInput()`

It can be assumed read-only is not set in this case.

This patch should also fix TerminalInterfaceTest. Currently the shell
probably doesn't get commands send through sendInput.

Test Plan:
* Run `konsole --background-mode --nofork & ; sleep 2; qdbus org.kde.konsole-$! /Sessions/1 sendText $'echo test\n'`
* Press Ctrl+Shift+F12
* The terminal should show `echo test` command and its result

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11762
2018-03-27 22:25:06 -04:00
Kurt Hindenburg
98b05633b6 add check for valid screen; fixes test 2018-03-27 20:22:27 -04:00
Mariusz Glebocki
2e086c852e Allow view-controlling keys in read-only mode
Summary:
Allow to use scrolling (Shift+Up/Down/PgUp/PgDown/Home/End) and a key
for showing URL hints when the view is in read-only mode.

Test Plan:
* Prepare
  * Turn on scrollback
  * Set at least one modifier key for "Show URL hints" (edit profile → advanced)
  * Generate a few screens of text in Konsole
  * Display some URL (e.g. `echo 'www.kde.org'`)
  * Display current time every second: `while sleep 1; do printf '\r%s' "$(date)"; done`
  * Turn on read-only mode
* Patch tests
  * Hold down URL hint key - the URL should be underlined with square and a digit on the left
  * Press <URL-hint-key>+1 - the URL should open in a web browser
  * Scroll the view with Shift+Up/Down/PgUp/PgDown/Home/End - the view should scroll
  * Split the view, do previous test in each split - only currently active split should scroll
* Regressions tests
  * Press different keys (including Ctrl+C, Ctrl+Z, etc; skip those mapped to Konsole actions) - nothing in terminal should happen
  * Press Ctrl+S - the time should not stop updating
  * Use IME to enter text - nothing in terminal should be shown

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11668
2018-03-27 09:53:51 -04:00
Kurt Hindenburg
1f2128ead7 Partial revert of "Allow view-controlling keys in read-only mode"
This reverts the Ctrl+S/Q/C not sending to a read-only/locked session.
This portion is causing tests to fail on ASAN; which might be the tests
fault, but for now revert.
2018-03-25 11:13:17 -04:00
Mariusz Glebocki
6635190c12 Allow view-controlling keys in read-only mode
Summary:
Allow to use scrolling (Shift+Up/Down/PgUp/PgDown/Home/End) and a key
for showing URL hints when the view is in read-only mode.

Test Plan:
* Prepare
  * Turn on scrollback
  * Set at least one modifier key for "Show URL hints" (edit profile → advanced)
  * Generate a few screens of text in Konsole
  * Display some URL (e.g. `echo 'www.kde.org'`)
  * Display current time every second: `while sleep 1; do printf '\r%s' "$(date)"; done`
  * Turn on read-only mode
* Patch tests
  * Scroll the view with Shift+Up/Down/PgUp/PgDown/Home/End - the view should scroll
  * Hold down URL hint key - the URL should be underlined with square and a digit on the left
  * Press <URL-hint-key>+1 - the URL should open in a web browser
* Regressions tests
  * Press different keys (including Ctrl+C, Ctrl+Z, etc; skip those mapped to Konsole actions) - nothing in terminal should happen
  * Press Ctrl+S - the time should not stop updating

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11668
2018-03-25 09:45:13 -04:00
Ahmad Samir
7934bcff27 Reset rendition attributes to default when switching to alternate screen
Summary:
Call setDefaultRendition() before switching to the alternate screen

Quitting vim after using a color scheme which sets the character
background color doesn't clear that attribute in the alternate screen.
This affects other programs which use the alternate screen when run
right after quitting vim, e.g. less.

This issue appears to only happen with certain graphics cards/drivers.

BUG: 328287
FIXED-IN: 18.04

Reviewers: hindenburg, #konsole

Reviewed By: hindenburg, #konsole

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11246
2018-03-12 08:58:12 -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
a8842603c2 readability fixes - braces 2018-01-02 21:56:34 -05:00
Albert Astals Cid
6dc09a36c1 Ignore xterm-DCS messages
Summary:
Would be ideal to process them too, but they seem kind of corner
case and ignoring them fixes vim having $q q written on the first
line on startup

BUGS: 383976

Test Plan:
Ran vim, looks good

Should this go to 17.08 or master?

Reviewers: hindenburg

Reviewed By: hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D7644
2017-09-02 10:54:28 +02:00
Kurt Hindenburg
2a2a56d73c modernize use nullptr 2017-07-15 23:28:32 -04:00
Kurt Hindenburg
50352c6e5d uncrustify using kf5 config 2017-06-27 21:39:51 -04:00
Kurt Hindenburg
4ed43e23e6 More changes to QLatin1String, QLatin1Char and QStringLiteral 2017-05-08 10:15:44 -04:00
Kurt Hindenburg
7a41b73b46 Correct ANSI string terminator
Use the correct decimal value 27

In bash, PS1="\e]0;<title>\e\\" or PS1="\e]0;<title>\033"

BUG: 231405

Differential Revision: https://phabricator.kde.org/D5576
2017-05-05 08:11:29 -04:00
Kurt Hindenburg
eade05a4bd Do not specify Qt modules in includes 2017-04-26 21:33:34 -04:00
Kurt Hindenburg
e45db26792 Add () around '& Qt flags' 2017-04-22 00:23:15 -04:00
Kurt Hindenburg
a540e6fdd0 Fix readability-implicit-bool-cast issues using nullptr 2017-04-21 10:51:31 -04:00
Kurt Hindenburg
29382cc62e Fix readability-implicit-bool-cast issues 2017-04-21 10:17:12 -04:00
Kurt Hindenburg
869c361602 constructors/decontructors use =default instead of {} 2017-04-01 14:01:41 -04:00
Kurt Hindenburg
dfafff97d4 remove QDebug/qWarning and use QCDebug 2017-03-31 21:06:18 -04:00
Kurt Hindenburg
ba6e758833 fix 2 issues of macro argument should be enclosed in parentheses 2017-03-27 23:34:37 -04:00
Kurt Hindenburg
89d6d2d2ba remove redundant void 2017-03-27 21:09:59 -04:00
Kurt Hindenburg
369f990540 Fix numerous clazy issues
container-anti-pattern, detaching-temporary, incorrect-emit
2017-02-05 16:09:23 -05:00
Kurt Hindenburg
bfa28220ea Fix clazy-detaching-temporary issue - change [] to .at() 2017-01-28 11:42:55 -05:00
Kurt Hindenburg
5601e995bd Allow ANSI string terminator to work
Treat "\e]0;<title>\e\\" (set window title) the same way
it interprets "\e]0;<title>\007".

It seems that Konsole does not recognize the standard string terminator
sequence "\e\\" (ESC \). Everything works fine if I use "\007" (BEL).

<http://invisible-island.net/xterm/xterm.faq.html#how2_title>

Thanks to Aniketh Girish anikethgireesh gmail com and Martin Sandsmark
martin sandsmark kde org for patch/review

BUG:231405
REVIEW:129895
2017-01-28 10:22:52 -05:00
Kurt Hindenburg
84b43dfb21 Add rendition flags SGRs 2, 8, 9, 53
Adds faint intensity, strikeout, conceal and overline support.

echo -e 'D\e[2mD\e[9mD\e[53mD\e[8mD'

Thanks to Antonio Russo antonio e russo gmail com for patch

REVIEW: 128405
BUG: 362171
2016-07-16 12:34:24 -04:00
Kurt Hindenburg
296cfc4233 remove unneeded #includes and forward classes 2015-10-15 18:45:11 -04:00
Kurt Hindenburg
0bca1e15b5 Add sequence for FocusGained and FocusLost
<esc>\[O      Focus gained            send
<esc>\[I      Focus lost              send
<esc>\[?1004h Enable focus reporting  recv
<esc>\[?1004l Disable focus reporting recv

Patch by Gerhard Gappmeier gerhard gappmeier ascolab com

REVIEW: 124898
2015-10-03 18:09:58 -04:00
Kurt Hindenburg
9076c3af47 Implement xterm's background color request/reply
vim uses control sequence 'echo -e "\033]11;?\a"' to request real
background color -- to detect whether terminal has dark or light
background.

Thanks to Pavel Raiskup praiskup redhat com
REVIEW: 125333
BUG: 352945
FIXED-IN: 15.12
2015-10-03 15:26:58 -04:00
Kurt Hindenburg
9d062f1f52 Make Ctrl+Space work again
Qt5.4 appears to have caused this issue. Test using showkey, mc, emacs

Thanks to Chirag Anand anand chirag gmail com for fix

BUG: 341157
REVIEW: 122711
2015-03-07 09:42:19 -05:00
Montel Laurent
8182ac8edc Port to QDebug 2014-10-17 09:09:20 +02:00
Alex Richardson
a3ce74d4eb Convert to Qt5 signal slot syntax
REVIEW: 117482
2014-04-30 19:16:54 +02:00