Giter Site home page Giter Site logo

imdaveho / tuitty-core Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 2.34 MB

A cross platform, interoperable, simplfied terminal library that is meant to be wrapped by multiple languages.

License: MIT License

Rust 100.00%
cross-platform terminal console tty unix windows macos multiple-languages rust-ffi

tuitty-core's People

Contributors

imdaveho avatar

Stargazers

 avatar  avatar

Watchers

 avatar

tuitty-core's Issues

Bug: Not closing HANDLE properly in multiple locations

Problem to Solve
Currently, in multiple locations:

  • cursor.rs (let handle = Handle::conout()? ln 33, ln 69, ln 83, ln 93)
  • mouse.rs(let handle = Handle::conin()? ln 11, ln 19)
  • output.rs
  • screen.rs
  • style.rs
  • windows/parser/mod.rs

Handle is being called but never closed. This creates multiple hanging Handles that needs to be cleaned up.

Repro

  • lookup Handle:: in project to find all locations where this is the case

Tasks

  • ensure that Handles are closed after requesting them in locations above
  • (optional) look at #309 to modify windows input thread polling to prevent multiple calls to create Handle without closing
    • this might be able to be done by creating a single CONIN$ handle that is cleaned up properly on close

Backlog: Detect window resize events

Problem to Solve
If the user resizes the terminal window, there is nothing to detect how the contents should reflow, and more specifically, nothing to handle the changes in length and capacity for the contents in the stored screen buffer. It would also impact how we are recalculating internal cursor position, etc.

Tasks

  • detect and handle SIGWINCH on Unix
  • detect window resize events on Windows
  • A. modify dispatch to specifically listen for this event
    • meaning that Dispatcher must init already listening to input_handler thread (ie. no need to call .listen()
  • B. as an InputEvent these changes can be handled by the User
    • might be more preferable as applications may want to handle the signal differently

Distrib: Provide an Action-only cdynlib

Description
Perhaps the target library simply wants the basics. Could we build a shared library that only contained the abstractions over Actions?

Task

  • create a build of strictly the Actions for each platform and os

Backlog: Provide buffer scrolling when on main screen (not alternate)

Problem to Solve
Currently, we ignore carriage returns and prevent the buffer from scrolling down. This is in line with the idea that the screen is "a canvas". The assumption at the time is that "scrolling" can be implementing "virtually"--which is just a repaint of the existing screen with the next line.

However! While this works for the alternate screen, it is a different story on the main screen. In the main screen's case, we want to maintain typical console/terminal behaviour.

Tasks

  • test to see if this is actually an issue for main screen (both raw and cook modes)
  • provide support to maintain regular terminal behavior in the main screen

Fetch `char` that the current cursor is on.

Description: On Unix systems, because the input buffer is not held in memory, there is no way to get the character underneath the cursor on the screen.

Task: Leverage the ScreenCache module on Unix to be able to do this.

Reason: Sometimes you want to toggle the background color of the current cursor location. (eg. to "mark" a cursor for multi cursor edits or to manually create a cursor instead of using the system one). This is not possible unless you can fetch the same char at the cursor location and print it with the new style.

KeyEvent::Esc is capturing all esc seqs (including mouse events)

Repro:

loop {
  if let Some(evt) = stdin.next() {
    match evt {
      InputEvent::Keyboard(k) => match k {
        KeyEvent::Char(c) => ...,
        KeyEvent::Esc => return false,
      },
      InputEvent::Mouse(m) => match m {
        MouseEvent::Press(btn, col, row) => match btn {
          MouseButton::Left => {
            ... // <- gets skipped when press occurs because of escape sequence that returns false
          }
        }
      }
    }
  }
}

Fix: check windows > parser > keyboard_events.rs

Backlog: Wrap Actions in a struct

Problem to Solve
Right now, every time we call wincon::<some_action> we have to pass in this vt-enabled boolean value to notify the function whether or not the terminal in question supports ANSI-sequences or not. This creates a lot of repetition.

This also is the case for terminal defaults from get_mode and get_attrs. These can also be included.

Proposal
We initially made wincon functions accept a boolean parameter so that we don't have to call is_ansi_enabled every time the function ran OR allocate additional memory in a struct to store the initial boolean value. This was an issue previously when we the only way to allow new threads to act upon the terminal was to create a new object to execute terminal commands. However, since moving to the Dispatcher pattern. We only need to create this once which is a lot more efficient.

This would then allow a single function call taking in only the parameters necessary for that function to work. This would simplify posix and win32 calls in the actions module.

This can also help with #8 and #13.

Tasks

  • create a wrapper struct to abstract is_ansi_enabled into a struct
  • do the same for initial, defaults, reset, etc. values for both unix and windows

Bug: SwitchTo main screen is should not clear out the screen

Problem to Solve
When switching to the main screen: SwitchTo(0), it seems this is clearing the screen. Is this appropriate behavior?

Repro

  • call SwitchTo(0) from another screen that was created after Switch

Task

  • determine if this is desired behavior and fix if not

Backlog: Implement a way to set cells in the buffer without printing to the screen

Problem to Solve
With prints and printf, we not only update the internal buffer, we also write to stdout. This creates a moment when the cursor hops to the end of the printed content and leaves it up to the implementer to hop the cursor back to where it was. This little "flash" is not great, as it leaks out implementation details to the end user of the application.

Proposal
At one point we toyed around with having the screen redraw the contents of the buffer every time. This proved to be quite inefficient (as flushes are expensive). However, on thing we can do, is to make set_cell public and to make render into another Signal. This way, there might be moments when you want to update the internal buffer, and when ready, render it on the screen at once, to prevent the cursor from hopping all around.

The goal is to render the output to the screen without the cursor going crazy. The implementation can vary. The above is the initial thought that can be tested.

Tasks

  • expose set_cell in cells.rs publically
  • create a Render Signal
  • experiment and gauge performance

Backlog: Toggle cursor visual states and behavior

Problem to Solve
In most text editing use cases, there should be some visual indicator to shift from insert mode to overtype mode. Having the ability to change the look of the cursor can create that visual indication to a user. This can be changing the shape: box, I-beam, underscore or the blink frequency.

Tasks

  • A. add an Action that changes the cursor shape
  • B. add an Action that updates the cursor blink frequency (blink / noblink)

Backlog: Output whitespace escape chars when dumping screen buffer contents

Problem to Solve
There are situations where a user might simply want to store exactly what is on the screen. Currently, the handling for \n, \r\n, and \t characters simply moves the cursor -- there is no concept of a <TAB>, <CR> (carriage return), <LF> (linefeed / newline).

Tasks

  • update Store to be aware of tabs, carriage returns, and linefeed characters in screen buffer

Backlog: Add change-scroll-region (CSR) and re-introduce scroll commands

Problem to Solve
Scrolling puts too many things into the buffer and often, will flush due to the input buffer reaching capacity. This, not only causes unwanted behavior, but also needlessly renders too many things at once. Similar to issue #11 this will attempt to minimize the amount of "work" that flush() has to do, and only output the necessary parts of the terminal that needs to change.

Tasks

  • add back scrolling ( ^[ Pn T (down) and ^[ Pn S (up) )
  • add change scroll region ( ^[ Pn; Pn r to set row start and row end as scrollable and ^[r to reset )
  • insert line and delete line to account for the clipped portions (this will reduce the amount written to stdout)
  • implement an efficient horizontal scrolling renderer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.