74 Commits
Author SHA1 Message Date
Miguel de Icaza 35f80d52cc Brings to Mac the same bounds fix that I did to iOS, where I was queuing
the wrong chunk of data.

Starting with BigSur any screen updates will invoke the draw() method
with the whole region, regardless of how much changed.

Added a new `disableFullRedrawOnAnyChanges` property that by default
will make the Terminal avoid this new behavior.   It can be controlled
by client code.

Setting this to true, will disable this OS behavior, setting it to
false, will keep the original BigSur behavior to redraw the whole
region.

For more details on this see:

https://gist.github.com/lukaskubanek/9a61ac71dc0db8bb04db2028f2635779
https://developer.apple.com/forums/thread/663256?answerId=646653022#646653022

Added an NSView.rectsBeingDrawn method to get the exposed areas - also
sort of worthless on BigSur an older if the flag is not set.
2021-06-18 19:56:18 -04:00
Miguel de Icaza 3cbda01601 Sixel progress: I do like this approach a lot more. Now, when an
image has bee completed, it is the job of the front-end to insert
it in a way that is suitable.

In the Mac+iOS cases, I divide the image in bands, and attach each
band to the display, this ensures that images work when scrolling
and that no odd repaint side effect happens when we update portions
that were not the "reference" row that contained the image.   Now,
every row has the image it needs to display.

Leveraged the Bufferline structure, and placed an optional array of
images there.   The images contain the column where they were
attached, so the front-end can iterate over the images (typically,
no more than one) to redraw.

Fixed also the HLS to RGB conversion, and does this without requiring
the core of the terminal to rely on UIKit or AppKit, so this should
be finally back to reusable on non-Apple platforms.
2021-04-21 22:23:52 -04:00
Miguel de Icaza 86afcff06c Much faster sixel parser, HSL parsing is not working 2021-04-20 23:33:53 -04:00
Miguel de Icaza 51da63c8b0 More work on Sixel, large images are not scaled, nor do they render when they are out of the screen, since there is no backreference to the image that sourced this 2021-04-19 23:29:26 -04:00
Miguel de Icaza 63dc5508a9 Restructured a bit how the Sixel image loading will take place, rather
than embedding platform specific information inside Terminal
(AppKit/UIKit), the handling of the image is delegated to the platform
specific part.

Made some of the delegate methods of Terminal follow the same convention
than the rest already had.

Started to think about how I am going to render the sixel data.   It
looks like the image is in the wrong place, and it is too large, I think
I might need to scale it.

Also, currently this has a side-effect, the buildAttributedString is poking
at a global `images` array, which I do not like.  I need a better system
to render, but I want to avoid walking the terminal buffer twice, so a
variation of this is still needed.

The code is currently disabled.
2021-04-17 23:35:41 -04:00
Miguel de Icaza 905d816cd8 Bring the changes and improvements from https://github.com/migueldeicaza/SwiftTerm/pull/168 2021-04-17 21:39:22 -04:00
Miguel de Icaza 6e2e3e72c9 Due to internal dependencies between the Terminal class and various of its
helper classes, the code created a strong cycle, that prevented the
Terminal resources from being disposed.

This patch makes it so that the various helper classes use weak references
to the container Terminal, and also makes the TerminalDelegate weak
2021-04-17 19:55:49 -04:00
Anders Borum 118648c1af avoid buffer overflow when changing terminal size 2021-04-16 22:31:04 -04:00
Miguel de Icaza 73e8777044 Make bracketed paste mode public, style 2021-03-30 22:50:48 -04:00
Miguel de Icaza 4a262c048a Ignore slow/fast scroll mode 2021-03-28 22:14:50 -04:00
Miguel de Icaza 8da1cb73b9 Expose LocalProcess.running 2021-03-27 23:12:06 -04:00
Miguel de Icaza 49cbc823d9 New terminal.currentAttribute, small docs 2021-03-27 22:20:01 -04:00
Miguel de Icaza 29e203d9c8 LocalProcess: expose childFd 2021-03-27 15:56:59 -04:00
Miguel de Icaza 0487b865b3 These constants feel more at home as UInt8 2021-03-27 15:18:54 -04:00
Marcin Krzyzanowski 6c5a299898 Stretch last col/row to full frame size (#165) 2021-01-23 17:18:38 -05:00
Artur HellmannandArtur Hellmann a7e176c8c3 There is no need to draw the cursor in the draw method, as it is drawn later by updateDisplay(...). (#162)
This is removed because of some crash when a terminal is used inside of a SwiftUI `VSplitView` (maybe also others)

When the `updateCursorPostion` method is called in the drawDirtyRect method, it causes a crash at `addSubview(caretView)` in line 628. The message is:
"The window has been marked as needing another Update Constraints in Window pass, but it has already had more Update Constraints in Window passes than there are views in the window"

Co-authored-by: Artur Hellmann <[email protected]>
2021-01-12 22:16:08 -05:00
lvht d1235c28eb Make ctrl-6 works for vim (#160) 2020-12-24 14:20:11 -05:00
Miguel de Icaza 12ce12a779 Launch bash as a login shell; Set startup directory to be the home directory 2020-12-07 17:56:06 -05:00
Miguel de Icaza 4787eadad3 Fix truecolor support: the values are stored 0..255 not 0..65535, fix by @lvht 2020-12-07 10:27:37 -05:00
Anders Borum 6c0e1f3b07 avoid buffer overflow in selectCharset (#154) 2020-12-07 10:16:00 -05:00
Miguel de Icaza 1ed974b5c6 Mac app: export buffer, export selection; Library: API to expose contents as Data; Update localhost testing address 2020-11-30 21:56:30 -05:00
Miguel de Icaza 5aa0a77ec8 Fixes triple-click on selection, and makes the usage of notification more consistent 2020-11-29 22:41:13 -05:00
Miguel de Icaza 7df537a2ac Fixes the selection bug with the last-character issue, fixes the first item from #50 2020-11-29 22:34:05 -05:00
Miguel de Icaza 4abff67a68 Wire up the OSC current-directory command to the Mac sample app 2020-11-27 14:57:21 -05:00
Miguel de Icaza c3ec9c4485 Move more terminal state to the buffer state, fixes #140; Switches TERM to xterm-256color 2020-11-27 14:32:20 -05:00
Miguel de Icaza dcb3c8d0e0 Better background processing (#147)
* Exploration on making the input parsing a background task - and let the UI run free

* The multi-threaded renderer idea works.

The general idea is to move away from the idea that the view is
updated after text is fed into the TerminalView, as this can hang the
UI when large amounts of data are fed into the terminal (this happens
with an ssh connection when a command sends too much data over the
connection).

The idea is instead to run a CADisplayLink that updates the display
at discrete intervals and send the data to the terminal on a
background thread.

For this to work, the queue that I was using for SSH needs to be
serialized, and I had it configured as concurrent in
UIKitSshTerminalView, so that should also be fixed on master.

Some challenges with this approach, which prevent this from being
merged right now.

1. The messages posted from the terminal into the delegate are done
from the background thread (the one that is calling parse).   Either,
I provide an explicit queue to deliver messages, or the terminal could
pick the queue on which it was created to deliver messages on.

2. The CADisplayLink can be expensive when nothing is happening, so
probably it should be turned off when no data has been pushed, or have
a small boolean that indicates whether any data has been fed,
otherwise, to return immediately.

* Multi-threading: Pause the display update when there are no changes, currently only iOS has been wired up

* Two performance optimization: preload the content of self.buffer to avoid multiple nested calls in insertCharacter, and copyFrom can rely on Swift's array copy-on-write semantics instead of copy data like a troglodyte

* EscapeSequenceParser: while it took a slice, it was iterating not over the startIndex..endIndex, but startIndex..len which could have been smaller, so it was not really working with slices

* Undo the locking-based multi-threading, and instead buffer output in chunks from SSH data receiver

* Update comments to reflect the two bugs fixes, and the now desired pattern to use it

* Make multithreading build on Mac
2020-10-27 17:17:46 -04:00
Miguel de Icaza 056d80e24d Add the changedLines() method to Terminal that returns an unsorted Set<Int> that contains the changed lines 2020-10-20 11:46:39 -04:00
Miguel de Icaza 1656605ad4 getTrimmedLength can return 0, which could make ec smaller than startCol: fix crash, from @lunixbochs 2020-10-20 09:33:29 -04:00
Miguel de Icaza 3be62ea6b9 Pull 138 modified (#139)
Authored-by: Anders Borum <[email protected]>
Co-authored-by: Miguel de Icaza <[email protected]>

These are changed contributed by @palmin during his work to make SwiftTerm usable with a new front-end UI.   It contains both changes to support this as well as some bug fixes.   Some of the changes that Anders did included a notification for line changes - that change is not part of this PR, instead a separate issue is tracking this (https://github.com/migueldeicaza/SwiftTerm/issues/142)

This also brings Sixel rendering support, it is a first pass, but I am tracking some additional changes to properly isolate the work on this issue: https://github.com/migueldeicaza/SwiftTerm/issues/141

The summary of the changes in this PR include:

* Extract Terminal lines in scroll invariant way
* Avoid array overflow when index >= data.count
* Nicer debug description for CharData
* Normal buffer resize adjusts savedY alongside y
* Update tab stops on both buffers when resizing terminal
* Add getScrollInvariantCharData for getting character data independent of scrolling
* Fix lines beyond scrollback
* Fix reuse of lines
* Faster reading of lines by exposing BufferLine outside of SwiftTerm
* Add support for OSC 6 "hostCurrentDocument"
* Avoid adjusting top row for buffer without scrollback
* Reset margin when starting alt buffer (fix emacs insert mode) and improve logging
* Only avoid printing outside margin when in margin mode
* TinyAtom has been extended now to track images, and a garbage collector has been added
* Sixel parser is able to handle palette changes mixed with pixel data
* Sixel parser no longer assumes color pick before pixel data
* Remember that we are using inline images to allow more flexible scrolling behaviour
* better way to avoid newline for last line

Additionally, I modified the original PR to:

* Compile on Mac
* Fix a handful of regressions
* Undid some variable renames
* Removed some debug helpers/warnings
* Documentation, an additional API to mirror the Invariant get lines API, some formatting changes
2020-10-06 13:17:01 -04:00
Miguel de Icaza 212a4c7a9f Two performance optimization: preload the content of self.buffer to avoid multiple nested calls in insertCharacter, and copyFrom can rely on Swift's array copy-on-write semantics instead of copy data like a troglodyte 2020-08-29 23:46:51 -04:00
Miguel de Icaza 52bab6322d Small API update 2020-06-16 23:51:23 -04:00
Miguel de Icaza 10e8fdcc13 Selection: Add convenience entry point 2020-06-11 13:31:12 -04:00
Miguel de Icaza d64a5058f0 Properly propagate collect 2020-06-11 13:30:51 -04:00
Miguel de Icaza 9e567c763c Flush color cache when updating nativecolors 2020-06-08 23:35:41 -04:00
Miguel de Icaza 0924973c42 iOS/Mac: Make the the frame overridable 2020-06-07 22:52:51 -04:00
Miguel de Icaza 25c8cbd7a3 iOS/Mac: Make the the frame overridable 2020-06-07 22:52:19 -04:00
Miguel de Icaza b21b92a96a This moves the global color state into the Terminal itself 2020-06-06 12:29:25 -04:00
Miguel de Icaza 9b100886c2 Make a couple of colors configurable, surface Backspace mapping 2020-06-05 23:28:49 -04:00
Miguel de Icaza 3350820980 Without this, changing the font size leaves some odd ghosting 2020-06-05 00:08:41 -04:00
Miguel de Icaza e15afadd1c Usability: make the TerminalView font settable by the native font, not via our internal font structure; Mac terminal app - hook up the zoom in/out/magnification/reset size events 2020-06-04 20:18:46 -04:00
Miguel de Icaza 0d099506e2 Make font a property that can be configured at any time, not just at startup 2020-05-30 23:38:21 -04:00
Miguel de Icaza c698ec83b5 Proxy the bell on the TerminalViews, and make Color hashable 2020-05-30 23:14:02 -04:00
Miguel de Icaza 91e4a0b5fa Add support for transparent backgrounds to Mac and iOS 2020-05-29 20:03:43 -04:00
Miguel de Icaza 74783a6e0b Simple API to install a new color palette 2020-05-28 23:52:09 -04:00
Miguel de Icaza 26c194094c Fuzzer bug fixes: The reflow code did not expect getTrimmedLenght to be actually the visible length, and crashed; There was an off-by-one error in the parsing of an escape sequence 2020-05-25 13:35:21 -04:00
pancake 3bbe5ef21c Fix an index out of bounds crash when using ansi256 color + bold (#125) 2020-05-24 09:42:45 -04:00
Miguel de Icaza 9b144c174c iOS: Some gestures 2020-05-12 00:15:10 -04:00
Miguel de Icaza d5cc9f640c Merge pull request #122 from migueldeicaza/ios-keyboard-accessory
iOS Keyboard accessory
2020-05-11 22:10:03 -04:00
Miguel de Icaza 5b91f4e290 Proper fix for the color parser, this was hanging the test suite 2020-05-11 21:59:43 -04:00
Miguel de Icaza 38b67af7eb iOS: implement cursor keys autorepeat on inputAccessoryView, clicksound, fix build 2020-05-11 21:57:23 -04:00