"Fossies" - the Fresh Open Source Software Archive

Member "rdesktop-1.9.0/keymaps/convert-map" (5 Jul 2016, 1820 Bytes) of package /linux/privat/rdesktop-1.9.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env python2
    2 # -*-Python-*-
    3 #
    4 # Copyright 2001 Peter ├ůstrand <astrand@cendio.se> for Cendio AB
    5 # 
    6 # This program is free software; you can redistribute it and/or modify
    7 # it under the terms of the GNU General Public License as published by
    8 # the Free Software Foundation; version 2 of the License. 
    9 # 
   10 # This program is distributed in the hope that it will be useful,
   11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 # GNU General Public License for more details.
   14 # 
   15 # You should have received a copy of the GNU General Public License
   16 # along with this program; if not, write to the Free Software
   17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   18 
   19 import sys
   20 
   21 def main():
   22     f = open(sys.argv[1])
   23     while 1:
   24         line = f.readline()
   25         if not line: break
   26 
   27         if line.startswith("#") or line.startswith("include"):
   28             print line,
   29             continue
   30 
   31         fields = line.split()
   32 
   33         if line.startswith("map"):
   34             print "map 0x%s" % fields[1]
   35             continue
   36 
   37         scancode = fields[0]
   38         for pos in range(1, len(fields)):
   39             keysym = fields[pos]
   40 
   41             if pos == 1:
   42                 modifiers = ""
   43             elif pos == 2:
   44                 modifiers = "shift"
   45             elif pos == 3:
   46                 modifiers = "altgr"
   47             elif pos == 4:
   48                 modifiers = "shift altgr"
   49             else:
   50                 raise("Invalid line: %s" % line)
   51             
   52             print "%s 0x%s %s" % (keysym, scancode, modifiers)
   53 
   54 
   55 
   56 if __name__ == "__main__":
   57     if len(sys.argv) < 2:
   58         print "Convert old-style keymaps to new style"
   59         print "Usage: %s <old-style-keymap>" % sys.argv[0]
   60         sys.exit(1)
   61     else:
   62         main()