Commit Graph

145 Commits

Author SHA1 Message Date
John Hood fa9335f737 Fix issue with incorrect true-color background erase colors. 2017-11-06 18:07:54 -05:00
John Hood 88bb01a50a Make Renditions::sgr() more compact in both code and output. 2017-11-06 10:28:10 -05:00
John Hood ce7ba37ad4 Overlays were getting set to the wrong colors. Fix. 2017-11-06 09:30:57 -05:00
John Hood e8331437d3 Minor SGR printf type signedness fixes. 2017-11-04 14:37:11 -04:00
John Hood cf493da7b4 Make Terminal::Renditions smaller, and its members private. 2017-11-04 14:37:11 -04:00
Kang.Jianbin 6cfa4aef59 Add true color support.
Implement true color support define in:
https://en.wikipedia.org/wiki/ANSI_escape_code

The sequence is:
ESC[ … 38;2;;; … m Select RGB foreground color
ESC[ … 48;2;;; … m Select RGB background color
2017-10-29 20:20:03 -04:00
John Hood b11d524bb7 Restore asserts and error handling
A couple of them got improved out of existence.
2017-08-23 15:09:43 -04:00
Keith Winstein 790b479f8a terminalframebuffer.cc: ignore unknown renditions
(revert assert(false) added by 4835dcf)
(fixes #918)
2017-08-17 13:14:52 -07:00
John Hood a40b67691a Remove various assert(constant) calls
These cause warnings from static checkers, and seem to lead to spurious
GCC7 -Wmaybe-uninitialized.
2017-08-06 23:12:05 -04:00
John Hood 93daa5ac3b Fix Debian GCC7 FTBFS: remove default constructors 2017-08-06 23:09:07 -04:00
John Hood 9663edb7c7 Do not set function parameters. 2017-08-06 22:22:32 -04:00
John Hood 2b3034b320 Remove private static class methods. 2017-08-06 22:22:29 -04:00
John Hood 4835dcf5ee Various switch statement fixes. 2017-08-06 22:22:25 -04:00
John Hood 3346419724 Remove excessive parentheses
There are many more.
2017-08-06 22:22:20 -04:00
John Hood 1ae23b4dcc Prefer early exit/break to large conditional blocks.
Some of these are large and contain smaller unrelated refactors.
2017-08-06 22:22:09 -04:00
John Hood b1a6f7c144 Eliminate unnecessary, trailing else conditional blocks. 2017-08-06 22:22:05 -04:00
John Hood 43785eb820 Collapse nested conditionals. 2017-08-06 22:21:56 -04:00
Anders Kaseorg 271e8ba318 Remove unused Action::operator==
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2017-08-02 22:59:42 -04:00
John Hood 42d2b5d029 Use shared_ptr and references for Actions.
This slows terminal emulation slightly.
2017-08-02 22:07:02 -04:00
Alex Cornejo 4b240ac033 support osc 52 clipboard copy integration.
This feature is particularly relevant for mosh for chrome (which also
used in windows I believe).
2017-07-31 23:17:24 -04:00
John Hood 72199ffc0b Do not move cursor for SCROLL UP and SCROLL DOWN
This fixes #881, corrupted display of man pages with tables in tmux
2.4.
2017-05-06 11:15:43 -04:00
John Hood 2873def506 Work around JuiceSSH rendering bug
JuiceSSH apparently has a bug where ECH for one character (ESC [ 1 X) does
not actually erase the character, in its code that receives and interprets
Mosh state updates.  This was hidden before because Mosh <= 1.2.5 never sent
this sequence, it sent ESC [ X instead as an optimization.

Do the better optimization of sending spaces for short sequences of blanks
instead.
2017-04-24 22:40:31 -04:00
John Hood c1d85f04fc Eliminate dead code to placate GCC 7's -Wformat-truncation. 2017-01-31 23:08:03 -05:00
John Hood 8fcfb3a587 Fix Coverity "missing move operator" (copy to rvalue).
Also makes this bit of code more readable, but the overall handling of
Unicode characters in Actions and Transitions is messy, and may get
reworked later.
2016-11-20 01:27:51 -05:00
John Hood e8f1004f94 append_move(): improve awkward control flow, naming 2016-11-19 17:14:37 -05:00
John Hood 302c7deb41 Describe Cell width as a narrow/wide boolean.
A character cell can only be either narrow or wide.  It's more
convenient to represent that as an int containing 1 or 2, but slightly
more correct to represent it as a "boolean" single-bit integer.
2016-11-17 00:56:31 -05:00
John Hood 71fe4441ef Shrink Cell to its prior size by using bitfields. 2016-11-17 00:56:05 -05:00
John Hood e4aed30d30 Fix broken wrap behavior causing broken copy/paste.
The terminal framebuffer was not resetting the wrap state of a row
when a previously-wrapping line was overwritten by a non-wrapping
line.  Restore previous, subtle behavior of line wrap.  Fix wrap
verification bug now exposed by emulation-wrap-across-frames.test.

Also hoist some getters, mostly for clarity.

Fixes #820.
2016-11-17 00:50:46 -05:00
John Hood dd9ee1c4b7 Remove unused include 2016-11-06 02:47:20 -05:00
John Hood c1ca7e46a5 Coverity fixes: do { ...; continue; ... } while (false)
This is more stylistic than substantial, but it's bad enough
style to be worth fixing.
2016-05-11 00:03:37 -04:00
John Hood ed92637f25 Use snprintf(), not sprintf()
Found by OpenBSD build.
2016-03-30 23:52:19 -04:00
John Hood 6abd4739de Const correctness and const-ref in Crypto and elsewhere. 2016-03-30 23:52:19 -04:00
Keith Winstein e7303e0b66 Eliminated "handled" field in Parser::Action
This field was used during development to measure the
coverage of the ANSI terminal parser against typical
terminal input sequences.

The "handled" field has not been read by any code since
commit 1ee54cd7 (February 2011). Eliminating the field
by popular request (closes #723).
2016-02-10 22:06:18 -08:00
John Hood 2ac3bbeb9b Fix prediction unicode bug. Make all Cell members private.
Fixes #702.
2015-12-24 22:27:17 -05:00
John Hood 1d71895ff4 Add support for back tab (CSI CBT), and forward tab (CSI CHT) too.
Resolves #539.
2015-12-06 22:38:19 -05:00
John Hood 551b77f27e Remove display-posterizing code. It's been dead 3 years.
Signed-off-by: John Hood <cgull@glup.org>
2015-12-06 19:03:36 -05:00
John Hood e0f6eb78ef Improve roundtrip verification tests and debug dump.
Add another round-trip verification.  For both original and generated
state, generate a diff from an initial, empty state.  Verify that
these two diffs are the same.
2015-12-06 17:42:34 -05:00
John Hood 66634eb97c Move grapheme printing from FrameState::append_cell() to Framebuffer::Cell::print_grapheme(). 2015-12-06 17:42:34 -05:00
John Hood 0b51260540 Fix for UTF-8 roundtrip verification bug.
The problem was that the round-trip verification code copies the
current state, which may contain intermediate Parser state for
multibyte characters and ANSI escape sequences.  It then applies diffs
to that copy, which may appear as badly formed input.

Also removes some dead, never-used code.
2015-12-06 17:42:34 -05:00
john hood e4a99256cb Avoid wcwidth(), wcrtomb() and mbrtowc() on ASCII/ISO8859-1 characters.
ASCII <-> UTF has trivial mappings.  Avoid wcrtomb() and mbrtowc().

ISO-8859-1 is all narrow characters, and cheap to test for.  It might
be possible to cheaply test other popular UTF blocks and/or planes as
well.

These two changes get 2-3x faster input processing on Linux and
FreeBSD.  Performance improvement in actual usage is more modest but
still significant.
2015-12-06 17:42:34 -05:00
John Hood f5d814a9c4 Reduce character cell lookups in Emulator::print(). 2015-12-06 17:42:34 -05:00
John Hood 589d21bbf2 Add make_shared emulation for std::tr1::shared_ptr; use make_shared 2015-12-06 17:42:34 -05:00
John Hood b41bad918d Make Terminal::Framebuffer::Rows shared and copy-on-write.
* Support both std:: and std::tr1:: shared_ptr. FreeBSD 10 now uses C++11 by default.
* Remove Framebuffer pointers in STMClient
2015-12-06 17:42:34 -05:00
John Hood c090d257f2 Rework Terminal::Display to improve performance and treat passed Framebuffers as const.
* Refactor put_cell() and parts of new_frame(), and associated state, into put_row().
* Optimize display and line wrap handling code/output.
* Make last_frame a const ref, to eliminate a costly copy of the framebuffer on every screen refresh.
* In new_frame()'s scroll optimization, don't copy rows, use pointers instead.
* Don't check entire frame buffer for scrolling if first line hasn't scrolled.
* Add a generation counter on Row objects to allow quicker/better identification of scroll regions
* Use at() for bounds-checking on framebuffers, because they can be resized.
* Copy and resize scroll buffer on window resize.
2015-12-06 17:42:34 -05:00
John Hood 32afa96111 Change Framebuffer's containers/methods to improve performance.
* Reduce the size of Terminal::Cell.
* Change colors and attributes in Terminal::Rendition to bitfields/bitmask.
* Change Cells to use UTF-8 strings instead of vector<wchar_t>.  Store Rows in a vector instead of a deque.
* Add various Framebuffer::append() methods for more efficient passing of single and repeated characters.
* Change title/icon strings from deques to a vector typedef-- this is more for tidiness than any real performance.
2015-12-06 17:42:34 -05:00
John Hood 8fdcdc88cd Isolated algorithmic improvements.
* Fix inefficient STL use around Parser::UTF8Parser.
* Reduce typeid() usage, change some of it to a virtual method
* Do multiple-line scrolls as a single move
2015-12-06 17:42:34 -05:00
Keith Winstein 7ec19a5bed terminal.cc: Remove overly-strong assertion on Unicode fallback
Fixes #667
2015-08-24 09:52:39 -07:00
John Hood 8acee95c02 Resolve Coverity issue with Parser::Transition's ownership of Action *.
This commit is somewhat subtle; it informs Coverity that
Parser::Transition only holds an Action* temporarily, and should never
create/delete one.  I believe runtime checkers should also understand
this OK.

Signed-off-by: John Hood <cgull@glup.org>
2015-06-10 23:52:25 -04:00
John Hood 026a3f0346 Resolve cppcheck issues.
Signed-off-by: John Hood <cgull@glup.org>
2015-06-10 23:50:56 -04:00
John Hood 543f346ac7 Fix various new compiler warnings.
terminalfunctions.cc: set_if_available() was undeclared.
Fix printf() wint_t/wchar_t warnings.
mosh-server.cc: Fix warning for side effects inside typeid().

Signed-off-by: John Hood <cgull@glup.org>
2015-06-06 13:12:32 -04:00