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/9a61ac71dc0db8bb04db2028f2635779https://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.
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.
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.
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
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]>
* 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
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