00001 #ifndef __VT100_H__ 00002 #define __VT100_H__ 00003 /* ============================================================================= 00004 00005 Copyright (c) 2008 Pieter Conradie [www.piconomic.co.za] 00006 All rights reserved. 00007 00008 Redistribution and use in source and binary forms, with or without 00009 modification, are permitted provided that the following conditions are met: 00010 00011 * Redistributions of source code must retain the above copyright 00012 notice, this list of conditions and the following disclaimer. 00013 00014 * Redistributions in binary form must reproduce the above copyright 00015 notice, this list of conditions and the following disclaimer in 00016 the documentation and/or other materials provided with the 00017 distribution. 00018 00019 * Neither the name of the copyright holders nor the names of 00020 contributors may be used to endorse or promote products derived 00021 from this software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00029 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00030 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00031 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00032 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 POSSIBILITY OF SUCH DAMAGE. 00034 00035 Title: VT100 Terminal Support 00036 Author(s): Pieter Conradie 00037 Creation Date: 2008/08/04 00038 Revision Info: $Id: vt100.h 116 2010-06-20 21:52:14Z pieterconradie $ 00039 00040 ============================================================================= */ 00041 00042 /** 00043 * @ingroup PROTOCOL 00044 * @defgroup VT100 vt100.h : VT100 terminal helper module 00045 * 00046 * Implements a command line parser using the ANSI/VT100 terminal protocol. 00047 * 00048 * Files: vt100.h & vt100.c 00049 * 00050 * @see 00051 * - http://en.wikipedia.org/wiki/ANSI_escape_code 00052 * - http://www.termsys.demon.co.uk/vtansi.htm 00053 * 00054 * Example: 00055 * @include test/cmd_line_test.c 00056 * 00057 * @{ 00058 */ 00059 00060 /* _____STANDARD INCLUDES____________________________________________________ */ 00061 00062 /* _____PROJECT INCLUDES_____________________________________________________ */ 00063 #include "common.h" 00064 00065 /* _____DEFINITIONS _________________________________________________________ */ 00066 00067 /* _____TYPE DEFINITIONS_____________________________________________________ */ 00068 /* 00069 * Definition for a pointer to a function that will be called to 00070 * send a character 00071 */ 00072 typedef void (*vt100_put_char_t)(char data); 00073 00074 /// @name Special ASCII values 00075 //@{ 00076 #define VT100_NONE 0 00077 #define VT100_BEL 0x07 00078 #define VT100_BS 0x08 00079 #define VT100_TAB 0x09 00080 #define VT100_CR 0x0D 00081 #define VT100_LF 0x0A 00082 #define VT100_ESC 0x1B 00083 #define VT100_DEL 0x7F 00084 #define VT100_ARROW_UP 0x80 00085 #define VT100_ARROW_DN 0x81 00086 #define VT100_ARROW_LEFT 0x82 00087 #define VT100_ARROW_RIGHT 0x83 00088 //@} 00089 00090 /* _____GLOBAL VARIABLES_____________________________________________________ */ 00091 00092 /* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */ 00093 /** 00094 * Initialise VT100 module. 00095 * 00096 * @param put_char Pointer to a function that will be called to send a character 00097 */ 00098 extern void vt100_init(vt100_put_char_t put_char); 00099 00100 /** 00101 * Process a received character byte. 00102 * 00103 * If the special VT100 command sequence is detected, VT100_NONE will be 00104 * returned to indicate that received character should be ignored, otherwise 00105 * the received character is returned. 00106 * 00107 * If up, down, left or right arrow sequence is received, it is indicated with 00108 * the special ASCII sequence. 00109 * 00110 * @param data Received character 00111 * 00112 * @return char VT100_NONE if character should be ignored, otherwise the 00113 * received character. 00114 * 00115 */ 00116 extern char vt100_process_rx_char(char data); 00117 00118 /** 00119 * Send 'clear screen' command to terminal 00120 */ 00121 extern void vt100_clear_screen(void); 00122 00123 /** 00124 * Send 'erase line' command to terminal 00125 */ 00126 extern void vt100_erase_line(void); 00127 00128 /* _____MACROS_______________________________________________________________ */ 00129 00130 /** 00131 * @} 00132 */ 00133 #endif
1.6.3