Giter Club home page Giter Club logo

Comments (9)

anseki avatar anseki commented on June 1, 2024

Hi @dineshkumar02, thank you for the comment.
Sorry, my English is poor.
What is the keystore?
Do you mean that you want to add colors in the terminal window?

from readline-sync.

dineshkumar02 avatar dineshkumar02 commented on June 1, 2024

Hi @anseki ,

I am sorry for the typo in my question.

I mean, whenever a user press a KEY on the keyboard(This is what keystroke) .

A simple readline example here.


  process.stdin.on("keypress", (c, k) => {
   if (k.name=='space'||k.name=='tab') {
    // setTimeout is needed otherwise if you call console.log
    // it will include the prompt in the output
    setTimeout(() => {
      **rl._refreshLine();**
   }, 1);
  } else if(k.name=='c' && k.ctrl) {
    console.log('\nbye');
    exit();
  }
  });

  rl._writeToOutput = function _writeToOutput(stringToWrite) {
    **rl.output.write(highlight(stringToWrite, { language: "html" }));**
  };

Here, whenever the user types the HTML tags, We use highlightjs to process it, and print the color.
But, we are doing this for every KEYPRESS, which is refreshing the entire line.

Shall we achieve the syntax highlight, whenever the user type the command, which is something like "fishshell" (https://fishshell.com/).

Thanks in advance for your help.

from readline-sync.

anseki avatar anseki commented on June 1, 2024

Umm...
Sorry, I couldn't understand the topic.
Your example seems to be not using readlineSync. The rl has methods that I don't know.
Maybe, you are talking about "readline", not "readlineSync".
I am sorry that I could not be of any help to you.

from readline-sync.

dineshkumar02 avatar dineshkumar02 commented on June 1, 2024

Hi @anseki ,

I am sorry, let me put my question in this way.

By using readline-sync, shall we achieve the syntax color.
For example, in prompt user actually types the HTML code. Whenever he types the html code, we have to give the color.

Prompt> "< some tag > < / some tag > " ---This what user types in the prompt, and we have to give the syntax highlight instantly

Regards,
Dinesh Kumar

from readline-sync.

anseki avatar anseki commented on June 1, 2024

Do you mean that you want to add the syntax highlight (e.g. colors) before user pressing Enter key?

from readline-sync.

dineshkumar02 avatar dineshkumar02 commented on June 1, 2024

Yes @anseki,

Exactly, before pressing the enter we want to have the syntax highlight(colors).

from readline-sync.

anseki avatar anseki commented on June 1, 2024

You seem to be making TUI app. Then, you need TUI library, not CUI (CLI) library such as readlineSync.
In CUI (CLI), the "readline" reads a line via TTY. That is, the line is made by Enter key.
Therefore, readlineSync is not required for your app.
For example, Vim text editor that is very famous TUI app supports the syntax-highlight with TUI base library.

from readline-sync.

dineshkumar02 avatar dineshkumar02 commented on June 1, 2024

Thanks @anseki,

I will take your suggestions, and will look for the TUI libraries.

from readline-sync.

anseki avatar anseki commented on June 1, 2024

😄

from readline-sync.

Related Issues (20)

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.