ANSI 이스케이프 코드

ANSI 이스케이프 시퀀스(ANSI escape sequences)는 비디오 텍스트 터미널터미널 에뮬레이터에서 커서 위치, 색, 글꼴 스타일, 그 밖의 옵션을 제어하는 대역 내 신호 방식을 위한 표준이다. 대부분 ASCII 이스케이프 문자와 괄호 문자로 시작하는 특정 바이트 시퀀스들은 텍스트에 임베디드된다. 터미널은 이 시퀀스들을 텍스트가 아닌 명령으로 해석한다.

ANSI X3.64 (ISO 6429)
ncurses 기반 애플리케이션 시스템 모니터 htop의 출력. SGR 및 기타 ANSI/ISO 컨트롤 시퀀스를 사용한다.
표준
분류ISO/IEC 2022 기반 컨트롤 코드 및 컨트롤 시퀀스 세트
그 밖의 관련 인코딩기타 컨트롤 기능 표준: ITU T.101, JIS X 0207, ISO 6630, DIN 31626, ETS 300 706

ANSI 시퀀스는 1970년대에 벤더 특화 시퀀스를 대체하기 위해 도입되었으며 1980년대 초 컴퓨터 장비 시장에서 널리 보급되었다. 이들은 표준화된 기능을 제공할 수 있도록 전자 게시판뿐 아니라 개발, 과학, 상업용 텍스트 기반 애플리케이션에 사용된다.

하드웨어 텍스트 터미널이 21세기에 증가하고 있음에도 ANSI 표준의 타당성은 지속되고 있는데 그 이유는 대부분의 터미널 에뮬레이터들과 명령 콘솔들이 적어도 ANSI 표준의 일부를 해석하고 있기 때문이다.

설명 편집

제어 문자 편집

^ C0 Abbr Name
^G 7 BEL Bell
^H 8 BS Backspace
^I 9 HT Tab
^J 0xA LF Line Feed
^L 0xC FF Form Feed
^M 0xD CR Carriage Return
^[ 0x1B ESC Escape

Fe 이스케이프 시퀀스 편집

C1 Abbr Name
ESC N 0x8E SS2 Single Shift Two
ESC O 0x8F SS3 Single Shift Three
ESC P 0x90 DCS Device Control String
ESC [ 0x9B CSI Control Sequence Introducer
ESC \ 0x9C ST String Terminator
ESC ] 0x9D OSC Operating System Command
ESC X 0x98 SOS Start of String
ESC ^ 0x9E PM Privacy Message
ESC _ 0x9F APC Application Program Command

CSI (Control Sequence Introducer) 시퀀스 편집

Abbr Name
CSI n A CUU Cursor Up
CSI n B CUD Cursor Down
CSI n C CUF Cursor Forward
CSI n D CUB Cursor Back
CSI n E CNL Cursor Next Line
CSI n F CPL Cursor Previous Line
CSI n G CHA Cursor Horizontal Absolute
CSI n ; m H CUP Cursor Position
CSI n J ED Erase in Display
CSI n K EL Erase in Line
CSI n S SU Scroll Up
CSI n T SD Scroll Down
CSI n ; m f HVP Horizontal Vertical Position
CSI n m SGR Select Graphic Rendition
CSI 5i AUX Port On
CSI 4i AUX Port Off
CSI 6n DSR Device Status Report

비공개 시퀀스

Abbr Name
CSI s SCP, SCOSC Save Current Cursor Position
CSI u RCP, SCORC Restore Saved Cursor Position
CSI ? 25 h DECTCEM
CSI ? 25 l DECTCEM
CSI ? 1049 h
CSI ? 1049 l
CSI ? 2004 h
CSI ? 2004 l

SGR (Select Graphic Rendition) 파라미터 편집

Name
0 Reset or normal
1 Bold or increased intensity
2 Faint, decreased intensity, or dim
3 Italic
4 Underline
5 Slow blink
6 Rapid blink
7 Reverse video or invert
8 Conceal or hide
9 Crossed-out, or strike
10 Primary (default) font
11–19 Alternative font
20 Blackletter font
21 Doubly underlined; or: not bold
22 Normal intensity
23 Neither italic, nor blackletter
24 Not underlined
25 Not blinking
26 Proportional spacing
27 Not reversed
28 Reveal
29 Not crossed out
30–37 Set foreground color
38 Set foreground color
39 Default foreground color
40–47 Set background color
48 Set background color
49 Default background color
50 Disable proportional spacing
51 Framed
52 Encircled
53 Overlined
54 Neither framed nor encircled
55 Not overlined
58 Set underline color
59 Default underline color
60 Ideogram underline or right side line
61 Ideogram double underline, or double line on the right side
62 Ideogram overline or left side line
63 Ideogram double overline, or double line on the left side
64 Ideogram stress marking
65 No ideogram attributes
73 Superscript
74 Subscript
75 Neither superscript nor subscript
90–97 Set bright foreground color
100–107 Set bright background color

Fs 이스케이프 시퀀스 편집

Abbr Name
ESC c RIS Reset to Initial State

Fp 이스케이프 시퀀스 편집

Abbr Name
ESC 7 DECSC DEC Save Cursor
ESC 8 DECRC DEC Restore Cursor

nF 이스케이프 시퀀스 편집

Abbr Name
ESC SP F
  • ACS6
  • S7C1T
  • Announce Code Structure 6
  • Send 7-bit C1 Control Character to the Host
ESC SP G
  • ACS7
  • S8C1T
  • Announce Code Structure 7
  • Send 8-bit C1 Control Character to the Host

터미널 입력 시퀀스 편집

vt sequences:
<esc>[1~    - Home        <esc>[16~   -             <esc>[31~   - F17
<esc>[2~    - Insert      <esc>[17~   - F6          <esc>[32~   - F18
<esc>[3~    - Delete      <esc>[18~   - F7          <esc>[33~   - F19
<esc>[4~    - End         <esc>[19~   - F8          <esc>[34~   - F20
<esc>[5~    - PgUp        <esc>[20~   - F9          <esc>[35~   - 
<esc>[6~    - PgDn        <esc>[21~   - F10         
<esc>[7~    - Home        <esc>[22~   -             
<esc>[8~    - End         <esc>[23~   - F11         
<esc>[9~    -             <esc>[24~   - F12         
<esc>[10~   - F0          <esc>[25~   - F13         
<esc>[11~   - F1          <esc>[26~   - F14         
<esc>[12~   - F2          <esc>[27~   -             
<esc>[13~   - F3          <esc>[28~   - F15         
<esc>[14~   - F4          <esc>[29~   - F16         
<esc>[15~   - F5          <esc>[30~   -

xterm sequences:
<esc>[A     - Up          <esc>[K     -             <esc>[U     -
<esc>[B     - Down        <esc>[L     -             <esc>[V     -
<esc>[C     - Right       <esc>[M     -             <esc>[W     -
<esc>[D     - Left        <esc>[N     -             <esc>[X     -
<esc>[E     -             <esc>[O     -             <esc>[Y     -
<esc>[F     - End         <esc>[1P    - F1          <esc>[Z     -
<esc>[G     - Keypad 5    <esc>[1Q    - F2       
<esc>[H     - Home        <esc>[1R    - F3       
<esc>[I     -             <esc>[1S    - F4       
<esc>[J     -             <esc>[T     - 

외부 링크 편집