1 / 9

ANSI command-sequences

ANSI command-sequences. A look at some terminal emulation features utilized in the “console-redirection” mechanism. Clearing the screen. Here is an ANSI command-sequence that clears the terminal’s display-screen: char cmd[] = “33[2J”; int len = strlen( cmd ); write( 1, cmd, len );.

marsham
Download Presentation

ANSI command-sequences

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ANSI command-sequences A look at some terminal emulation features utilized in the “console-redirection” mechanism

  2. Clearing the screen • Here is an ANSI command-sequence that clears the terminal’s display-screen: char cmd[] = “\033[2J”; int len = strlen( cmd ); write( 1, cmd, len );

  3. Reposition the cursor • Here is an ANSI command-sequence that moves the cursor to row 12, column 40: char cmd[] = “\033[12;40H”; int len = strlen( cmd ); write( 1, cmd, len );

  4. ANSI color-codes 0 = black 1 = red 2 = green 3 = brown 4 = blue 5 = magenta 6 = cyan 7 = gray

  5. Setting text attributes • Here is an ANSI command-sequence that sets foreground and background colors: char cmd[] = “\033[32;44m”; int len = strlen( cmd ); write( 1, cmd, len );

  6. Cursor visibility commands • Here are ANSI command-sequences that will ‘hide’ or ‘show’ the terminal’s cursor: char hide[] = “\033[?25l”; // lowercase L char show[] = “\033[?25h”; // lowercase H

  7. Demo-program • We created a boot-time program (called ‘emitinfo.s’) that shows how a protected-mode exception-handler can send some diagnostic information via the serial null-modem cable to a remote machine that is running a ‘terminal emulator’ application

  8. In-class exercise • Modify this simple C++ program so that it will print its “Hello” message in colors and be located in the center of the screen: #include <stdio.h> int main( void ) { printf( “Hello, world! \n” ); }

  9. In-class exercise #2 and #3 • Modify the ‘emitinfo.s’ program so that it will also display the FS and GS registers • Modify the ‘emitinfo.s’ program so that its ‘isrGPF’ exception-handler will execute in 64-bit mode (on your ‘anchor’ machine)

More Related