Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do shell text editors work?

I'm fairly new at programming, but I've wondered how shell text editors such as vim, emacs, nano, etc are able to control the command-line window. I'm primarily a Windows programmer, so maybe it's different on *nix. As far as I know, it's only possible to print text to a console, and ask for input. How do text editors create a navigable, editable window in a command line environment?

like image 736
user25870 Avatar asked Oct 07 '08 16:10

user25870


1 Answers

By using libraries such as the following which, in turn, use escape character sequences

NAME
       ncurses - CRT screen handling and optimization package

SYNOPSIS
       #include 

DESCRIPTION
       The  ncurses library routines give the user a terminal-independent 
method of updating character screens with reasonable optimization.  This 
implementation is ‘‘new curses’’ (ncurses) and is the approved replacement 
for 4.4BSD classic curses, which has been discontinued.

[...snip....]

       The ncurses package supports: overall screen, window and pad 
manipulation; output to windows and pads; reading terminal input; control 
over terminal and curses input and output  options;  environment query 
routines; color manipulation; use of soft label keys; terminfo capabilities; 
and access to low-level terminal-manipulation routines.

like image 140
Vinko Vrsalovic Avatar answered Oct 11 '22 15:10

Vinko Vrsalovic