Commit Graph
123 Commits
Author SHA1 Message Date
Miguel de Icaza d3c594e87c Change of plans, Work in progress 2021-06-29 23:44:45 -04:00
Miguel de Icaza 29e132a363 The "allowMouseReporting" inputAccessoryItem is no longer surfaced
here, instead, took the space for the auxiliary keyboard input, which
is now requested from a client app - the only reason is that the
prototype I wrote uses SwiftUI, and I need a UIViewController to do
the view rehosting, and that is not possible on the library itself.

Maybe I could rewrite the keyboard with UIKit, but it just does not
seem remotely as fun.

iOSAccessoryView: the referece to the parent terminal and the
terminalView are now properly weak.

Moved extensions for the UIKit and AppKit into their separate files.
2021-06-29 22:24:46 -04:00
Miguel de Icaza 6070699470 Small usability tune up: hide the menu on a tap 2021-06-26 00:03:35 -04:00
Miguel de Icaza 8617159525 Fix Mac Build 2021-06-25 23:51:15 -04:00
Miguel de Icaza 4ee1baefa8 iOS TerminalView: change the way selection works in a few ways. Now,
it behaves more like a text input control in iOS.  A long-press will
add a "Select" option.

New selection markers are rendered, which can be used to adjust the
selection and these will scroll the view as well if they are near the
edge.

fuzzyHasSelectionBackground: Fixes the selection rendering on iOS, the
logic to return always true was wrong, it has to be true in one case,
false in the other.

Some behavioral changes to better match the iOS behavior:

- Long press will open a context menu, where it is possible to start a
  selection.

- Selecting "Select" after a long press, shows a new menu with
  additional context options.

- Menu is shown at the end of a pan operation when selection is on.

Additional property to control the color handles for the selection
2021-06-25 23:41:30 -04:00
Miguel de Icaza 0945f8b47b Expose EscapeSequences 2021-06-20 22:53:19 -04:00
Miguel de Icaza dddefcdde6 Unify the code that handles a terminal surface size changed across
Mac and iOS, into a new function processSizeChange, which additionally
reports whether the underlying terminal size has changed, which we
use to avoid unnecessary redraws while resizing

Early test to prevent rendering lines that we do not need, still needs
some testing.

Interesting observation, on iOS, `bounds` is the method that gets
called, but `frame` is not, when the size changes.  On macOS, it is
the other way around.
2021-06-19 12:31:39 -04:00
Miguel de Icaza da143adc08 AppleTerminal: pageUp/pageDown methods send page up/page escape sequences when on the alternate screen, rather than scrolling 2021-06-19 12:23:12 -04:00
Miguel de Icaza 13d535f108 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-19 12:22:53 -04:00
Miguel de Icaza 9b3321c836 Hook up to bounds, not frame, as the former is called when autolayout computes our size, and the latter is not. 2021-06-09 18:17:37 -04:00
Miguel de Icaza bf3a243436 Clear the colors cache when installing all colors, but do not override other individual actions 2021-05-23 00:13:06 -04:00
Miguel de Icaza 57d509dbc1 Clear the colors cache when installing all colors, but do not override other individual actions 2021-05-23 00:12:52 -04:00
Miguel de Icaza 8774d386e2 AppleTerminalView: after color changes, trigger a redisplay, otherwise, we had to trigger some input for the display to change after a theme change. Additionally, clear the color cache when a new set of colors have been installed, otherwise it would keep the old color settings 2021-05-23 00:11:22 -04:00
Miguel de Icaza b72c83e205 Important to set the textContenType, the familyName told iOS to auto-complete with your name, which you do not want on a terminal 2021-05-07 00:21:48 -04:00
Miguel de Icaza 063b5c5657 Dispatch events from the background to the main queue 2021-05-07 00:05:26 -04:00
Miguel de Icaza c9cd1482e9 Dispatch events from the background to the main queue 2021-05-06 23:47:13 -04:00
Miguel de Icaza 251612b4bd Merge main 2021-05-02 22:11:39 -04:00
Miguel de Icaza 80088184cc Merge 2021-05-02 22:08:27 -04:00
Miguel de Icaza 98c1f1e03b Make open 2021-04-30 14:33:47 -04:00
Miguel de Icaza 70a3af884c Improve color parsing, add some tests 2021-04-29 22:13:51 -04:00
Miguel de Icaza fcefefd991 Colors: add a mechanism to resolve the ambiguity between the two ways of representing colors that were conflicting with each other due to mistakes made over the years in the community. Various fixes from Fuzzing 2021-04-29 20:14:07 -04:00
Miguel de Icaza 34e94a021f Fix the rendering: the row is relative to the buffer, not visual. This caused the selection bugs, and the rendering problems with the backgrounds 2021-04-29 20:08:43 -04:00
Miguel de Icaza c0175913df Bug fixes from fuzzing SwiftTerm 2021-04-28 21:47:57 -04:00
Miguel de Icaza bc716ff432 iTerm image support (#178)
* Rename createImage to createImageFromBitmap.

Introduce createImage that is a more general purpose facility that
expects the front-end to decode the image (could be a PNG or JPEG
file), and that takes a width and height specification that contain
a payload.

On the Apple View implementation, this takes care of scaling based on
the iTerm2 rules the image, based on these inputs, and based on the
PreserveRatio attribute.

The Terminal delegate method iTermContent is no longer a general
purpose handler, but instead merely a fallback that receives the data
if it was not handled before - this means that the image is
pre-processed during the "1337" iTerm handler, and is not delivered to
the iTerm2 custom handler.   The parsing is now done centraly, and a
UI should implement the createImage method.

* Make the code compile for both AppKit and UIKit

* AppleTerminalView: rather than duplicating code between createImage
and createImageFromBitmap, abstract the actual rendering into a shared
insertImage method.  This means that sixel graphics now can support
scaling by default.

This also fixes also the inverted image problem for sixels that was
introduced in the move from CGImage to TTImage (the proxy to
NSImage/UIImage)
2021-04-27 23:32:47 -04:00
Miguel de Icaza 3961216c1b Turns out that we should not set the automatic conversion of newlines
into newline + carriage return by default.  This broke Emacs rendering, and it
is not the baseline setting that we should have.

For some reason, this has been carried for a while, a bug I introduced
in 2019 in XtermSharp when I commited the change in
0281d198c596063c40c5f1de514ed1bc9dff7def with the message "Small
fixes".   This code did not appear on xterm.js as far as I can tell.
2021-04-27 14:38:18 -04:00
Miguel de Icaza b7e6c6a216 Render images after the text, fixes sixel rendering inside SwiftTermApp that changes defaults colors, and also simplifies the TerminalImage protocol 2021-04-23 21:47:58 -04:00
Miguel de Icaza f2156280dc Report Sixel through the proper channels 2021-04-23 18:28:15 -04:00
Miguel de Icaza ed210c425b Provide a way of setting COLORTERM=truecolor 2021-04-22 22:30:26 -04:00
Miguel de Icaza da965ea7ef Make the arrow keys easier to hit, and prepare to have a custom keyboard for additional input 2021-04-22 20:32:41 -04:00
Miguel de Icaza 1570c7b69d Do not use safeAreaInsets.bottom for computing the terminal size, as that just adds another row of padding 2021-04-22 20:14:58 -04:00
Miguel de Icaza 5a986a8a15 Resolve a few issues from reviewing the patch 2021-04-22 15:57:24 -04:00
Miguel de Icaza f83d75aa73 Merge branch 'main' into uitextinput-strategy-3 2021-04-22 10:51:20 -04:00
Miguel de Icaza c2b9ba7b2b Fix iOS build 2021-04-21 22:41:34 -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 01b44e56c9 Merge branch 'master' into uitextinput-strategy-3 2021-04-05 22:46:52 -04:00
Miguel de Icaza febd49ba33 This fixes a very dumb mistake, I was keeping two independent selection tracking systems for UITextInput separately, and also deals with what appears to be an old selection point that is passed later to replace some text, but it would be out of bounds, causing the second dictation to fail 2021-04-05 22:46:50 -04:00
Miguel de Icaza d45154283e This commit merely cleans things up, and does not really introduce any fundamental changes 2021-04-05 22:19:37 -04:00
Miguel de Icaza aaa2298aef Finally, both dictation and international input mechanism are working.
There is still a pending crash, with chinese input, I seem to be
creating an invalid text range, and can crash, to reproduce: dictate
"hello world", then enter some multi-character chinese characters,
then press delete.  This creates an invalid range that ends up
requesting an invalid range of text.

A defensive check would work, but we should get to the root of it, so
I am keeping the abort for now.
2021-04-03 23:44:18 -04:00
Miguel de Icaza 46d14b1aa0 Progress: chinese input renders and works, but now the issue is that dictation does the empty string insertion and then the actual data; Rendering the foreign keyboard input was done by implementing firstRect(), and sending the chinese input was done by flushing the output on unmarkText() 2021-04-03 15:44:20 -04:00
Miguel de Icaza 8b558580ad Some debug aids 2021-04-03 15:17:25 -04:00
Miguel de Icaza 582ad80209 New strategy to implement UITextInput and family.
The previous code never managed to get any strings to be sent during
insertion, and I am not quite sure what caused this.   The new approach
rather than trying to map the terminal dimensions to the screen, instead
uses an offline char array called 'storage' that is used during things like
the dictation and where both the UITextInput selection and marked text
are applied - which is independent of the "selection" SelectionService field
in the TerminalView itself.

This makes dicatation work.

Currently this seems to regress international input (in particular the
Chinese input) but I am not sure if the reason is the accessorView and
AutoLayout (I do get a warning error about a conflict), or something
else (setting autoresizemask on the inputAccessoryView did not seem to
fix this).

Some hard earned lessons:

- insertText (text: String) sometimes get a bunch of spaces, but those
  are ok, because we need to track
  _markedTextRange/_selectedTextRange, and remove the text from the
  storage before applying the text.

  This solves the mysterious 10 white spaces, followed by the dictated content.

- The new logic that keeps storage elsewhere, sadly, has the
  disadvantage of not sending chiense input to the target.  So this
  approach regresses this part (this is handled by the setMarkText
  code).

- the logic in insertText currently sets sendData to either the text in storage,
  or the text being sent, and this is not right, and regresses some basic functionality.

Seems like I made a bunch of progress in dictation, but regressed the
input methods.
2021-04-02 23:27:05 -04:00
Miguel de Icaza f4ef3c6cbb More debugging aids 2021-03-30 23:07:18 -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