Nut/OS  4.10.3
API Reference
vt100.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2009 by egnite GmbH
00003  *
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the copyright holders nor the names of
00016  *    contributors may be used to endorse or promote products derived
00017  *    from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00023  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00028  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00029  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  * For additional information see http://www.ethernut.de/
00033  */
00034 
00035 /*
00036  * \file gorp/edline/vt100.c
00037  * \brief VT100 key mapping.
00038  *
00039  * \verbatim
00040  * $Id$
00041  * \endverbatim
00042  */
00043 
00044 #include <gorp/edline.h>
00045 
00050 
00082 int EdLineKeyMapVt100(int key, int *seq)
00083 {
00084     if (*seq > 0) {
00085         if (*seq == 1 && key == '[') {
00086             key = EDIT_KEY_IGNORE;
00087             *seq = 2;
00088         } else {
00089             /* Right arrow. */
00090             if (key == 'C') {
00091                 key = EDIT_KEY_RIGHT;
00092             }
00093             /* Left arrow. */
00094             else if (key == 'D') {
00095                 key = EDIT_KEY_LEFT;
00096             }
00097 #ifndef EDIT_DISABLE_HISTORY
00098             /* Up arrow. */
00099             else if (key == 'A') {
00100                 key = EDIT_KEY_UP;
00101             }
00102             /* Down arrow. */
00103             else if (key == 'B') {
00104                 key = EDIT_KEY_DOWN;
00105             }
00106 #endif
00107             *seq = 0;
00108         }
00109     }
00110     else if (key == 0x1b) {
00111         (*seq) = 1;
00112         key = EDIT_KEY_IGNORE;
00113     }
00114     else {
00115         key = EdLineKeyMap(key, seq);
00116     }
00117     return key;
00118 }
00119