Code Monkey home page Code Monkey logo

Comments (5)

glenux avatar glenux commented on June 5, 2024 1
  1. Thank you for your clarification and updates.

  2. Can you create a more detailed issue with your thoughts and explaining what you expect when reading the terminal state? I confess I'm still figuring out the interactions between terminfo, tput, tcgetattr, etc. but given what I understand, I'll probably come across the state reading issue soon (I'm developing a project that incorporates something similar to fzf) and I would love to contribute with a PR then :)

  3. Yes, you can close the current issue.

from tput.cr.

docelic avatar docelic commented on June 5, 2024 1

I added a longer description in #4. Feel free to comment there if you are interested.

Regarding your project -- sounds interesting and like it could benefit both you and tput.cr. Feel free to open tickets for any discussion or help you'd need from me. Thanks!

from tput.cr.

glenux avatar glenux commented on June 5, 2024

I tried a variant without the listen() loop that works perfectly. Same thing with break instead of exit.

It seems that exiting from the listen loop creates the terminal state corruption (maybe because of a raw mode access to the terminal for reading events ?)

from tput.cr.

docelic avatar docelic commented on June 5, 2024

Heya, let me check and I will report back shortly.

from tput.cr.

docelic avatar docelic commented on June 5, 2024

Hey,

Yes, you are right, break helps a lot because it properly ends the with_raw_input block which returns the terminal mode back to what it was. So that solves the first part of the issue.

The second part is that even after mode is restored, cursor color remains red, and not even reset helps. Obviously that's because reset doesn't touch the cursor itself. Unfortunately tput.cr currently does not support any escape sequences that read data from the terminal -- including the one which reads the complete terminal state.
(I am referring to some equivalent of function _bindResponse in Blessed's file https://github.com/chjj/blessed/blob/master/lib/program.js , on line 1040).

(I would be very much interested in receiving a PR that adds this; that would be amazing!)

In any case, because of inability to read terminal state, it is not possible to return the cursor color and blink to what it was before running the program; what we can do is just assume that the color before was white, and set it to white.

I've updated the README example to show this, and to fix some other things -- for example, terminal type and features were printed at the top of example, but weren't visible on screen because after print the screen was switched to alternate buffer. And I've made a number of smaller clarifications/improvements in code comments.

Hope it helps and thanks for the report!

Feel free to continue the discussion, or close the ticket if your question was adequately covered.

from tput.cr.

Related Issues (4)

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.