Coder Social home page Coder Social logo

chalk's People

Contributors

rudranilbasu avatar satyamvats5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chalk's Issues

Refactor keyboard input

Read low-level keypresses from the keyboard in two separate functions like:
editorReadKey(): whose job will be to wait for one keypress and return it
editorProcessKeypress(): waits for a keypress and handles it
and stop printing the keypress as of now

Hiding the cursor while repaintng

Cursor appearance in the middle of the screen while the screen is being drawn may cause flicker effect.
So,hide the cursor while repainting. And clear each line separately (Not all at once).

Turn of ECHO on terminal

  • Enable raw mode on entering the program

  • Disable ECHO

  • Disable Raw mode on program termination.

Turn off ctrl-c and ctrl-z signals

By,defauult ctrl-c sends a signal to the current process which causes it to terminate, amnd ctrl-z sends a signal ti current process which causes it to suspend. We need to turn off the sending of both the signals for proper functioning of our text viewer(text editor in original).

Error handling.

We are going to add some error handling to our program such that , if anything unexpected happens, our program will give a brief error message and will terminate.

Time out for read.

currently , what is happening is that read(), is waiting for infinite period of time for input from keyboard before it returns.
We need to set a timeout, so that read() will terminate if input is not provided for certain period of time.

Reposition the cursor

Reposition the cursor at the top left corner of the screen , on the execution of the program.

Quit and clear the screen.

The program is terminating as soon as we are are entering 'q', but program should quit whenever we will type ctrl-Q instead of 'q'.
The screen should be cleared both at the starting and termination of the program.

Turn off canonical mode.

As , we are working in canonical mode, so the inpur we are providing is processed line by line. It means that the input is processed only after the line is completed( when \n or EOF is found). But we want to process our input word by word. so we need to turn off the canonical mode.๐Ÿ‘

Global state

Store the state of the terminal, mainly the width and the height

Draw tildes

Draw tildes on the left hand side of the screen , just as the vim does

Disable all cntrl signals

We need to disable all other ctrl signals which have their own instructions to the terminal.

  1. disable ctrl-S and ctrl-Q as ctrl-S stops data from being transmitted to the terminal until we press ctrl-Q

  2. disable ctrl-V as ctrl-V when typed, makes to terminal to wait for user to type another character and then sends the characters literally.

  3. disable ctrl-M.

Append Buffer

We are using small write() functions each time we are refreshing the screen. We have to add all this small write() functions to a buffer and then we will write this buffer at the end.It will help preventing annoying flicker effect.

Turn off all output processing and miscellaneous flags.

Terminal translates each new line we print ("\n") into a carriage return followed by a new line("\r\n").
we need to turn off all output processing such that in order in print new line we will have to use carriage return followed by new line("\r\n"), instead of new line("\n") only. And we need to turn off all other miscellaneous flags, although these do not have any visible effect on these modern days terminals.

Move cursor

Upto now our cursor is stable at a point where we have initialized it. Now we need to work on moving it.

Disable raw mode on exit

Currently, we enter the raw mode whenever the program starts, but it needs to be disabled when
the program terminates, either via the main() method or via an exit() call. The initial properties of
the terminal should be stored on entering the raw mode and it should be reset when the program exits.

[docs] Update sending patches

Change:
git add . to git add <files> to avoid adding the unnecessary files (if any)

For git commit --signoff , add the additional option:

git commit --signoff -v 

which also displays the diff of the commit to be made

after "add the commit message" add a link to the Contributing Guidlines

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.