shell 文本编辑器是如何工作的? [英] How do shell text editors work?

查看:40
本文介绍了shell 文本编辑器是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程还很陌生,但我想知道 vim、emacs、nano 等 shell 文本编辑器如何能够控制命令行窗口.我主要是一名 Windows 程序员,所以可能在 *nix 上有所不同.据我所知,只能将文本打印到控制台,并要求输入.文本编辑器如何在命令行环境中创建可导航、可编辑的窗口?

解决方案

通过使用如下库,进而使用转义字符序列

<前>姓名ncurses - CRT 屏幕处理和优化包概要#包括描述ncurses 库例程为用户提供了一个独立于终端的通过合理优化更新字符屏幕的方法.这个实现是新的诅咒"(ncurses)并且是批准的替代品对于 4.4BSD 经典诅咒,已停产.[...剪断....]ncurses 包支持:整体屏幕、窗口和垫操纵;输出到窗口和垫;读取终端输入;控制在终端和诅咒输入和输出选项;环境查询例行公事;颜色处理;使用软标签键;terminfo 能力;并访问低级终端操作例程.

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?

解决方案

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.

这篇关于shell 文本编辑器是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆