src/extras/pyrepl/dumbcurses.py
changeset 0 ca70ae20a155
equal deleted inserted replaced
-1:000000000000 0:ca70ae20a155
       
     1 #
       
     2 # Curses stub to provide minimal functions required by SocketConsole.
       
     3 #
       
     4 # Copyright (c) 2005 Nokia Corporation
       
     5 #
       
     6 # Licensed under the Apache License, Version 2.0 (the "License");
       
     7 # you may not use this file except in compliance with the License.
       
     8 # You may obtain a copy of the License at
       
     9 #
       
    10 #     http://www.apache.org/licenses/LICENSE-2.0
       
    11 #
       
    12 # Unless required by applicable law or agreed to in writing, software
       
    13 # distributed under the License is distributed on an "AS IS" BASIS,
       
    14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    15 # See the License for the specific language governing permissions and
       
    16 # limitations under the License.
       
    17 
       
    18 
       
    19 # Grabbed from vt100. The original codes had delay expressions ($<xx>)
       
    20 # in them, which have been removed.
       
    21 _capabilities={ 
       
    22     'bel': '\x07',
       
    23     'civis': None,
       
    24     'clear': '\x1b[H\x1b[J',
       
    25     'cnorm': None,
       
    26     'cub': '\x1b[%dD',
       
    27     'cub1': '\x08',
       
    28     'cud': '\x1b[%dB',
       
    29     'cud1': '\n',
       
    30     'cuf': '\x1b[%dC',
       
    31     'cuf1': '\x1b[C',
       
    32     'cup': '\x1b[%d;%dH',
       
    33     'cuu': '\x1b[%dA',
       
    34     'cuu1': '\x1b[A',
       
    35     'dch': None,
       
    36     'dch1': None,
       
    37     'el': '\x1b[K',
       
    38     'hpa': None,
       
    39     'ich': None,
       
    40     'ich1': None,
       
    41     'ind': '\n',
       
    42     'pad': None,
       
    43     'kcuu1': '\x1b[A',
       
    44     'kcud1': '\x1b[B',
       
    45     'kcuf1': '\x1b[C',
       
    46     'kcub1': '\x1b[D',
       
    47     'kdch1': '\x1b[3~',
       
    48     'knp': '\x1b[6~',
       
    49     'kpp': '\x1b[5~',
       
    50     'ri': '\x1bM',
       
    51     'rmkx': '\x1b[?1l\x1b>',
       
    52     'smkx': '\x1b[?1h\x1b='}
       
    53 
       
    54 def tigetstr(cap):
       
    55     '''Return terminal capability string for given capability'''
       
    56     if _capabilities.has_key(cap):
       
    57         return _capabilities[cap]
       
    58     else:
       
    59         return None
       
    60 
       
    61 def tparm(str,*args):
       
    62     return str%(args)
       
    63