Author: esr
Date: Fri Feb 29 22:11:35 2008
New Revision: 24158

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24158&view=rev
Log:
Enrich the editor theme markup for hotkeys by adding a description= attribute.
A new script, data/tools/extractbindings, uses this to automatically generate
an up-to-date list of editor keybindings in a form suitable for the wiki.  

Added:
    trunk/data/tools/extractbindings   (with props)
Modified:
    trunk/data/themes/editor.cfg
    trunk/data/tools/Makefile

Modified: trunk/data/themes/editor.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/themes/editor.cfg?rev=24158&r1=24157&r2=24158&view=diff
==============================================================================
--- trunk/data/themes/editor.cfg (original)
+++ trunk/data/themes/editor.cfg Fri Feb 29 22:11:35 2008
@@ -11,9 +11,23 @@
 [theme]
     name=editor
 
-#ifdef APPLE
+    # description attributes are not used by the game engine;
+    # they're here to enable generating a correct keybing list.
+    # The following are canned bindings to be prepended to the list.
+
+    #! Arrow keys=Scroll (if map scrolling is enabled)
+    #! Left click=On map: Paint foreground terrain. On right panel: select 
foreground terrain
+    #! Right click=On map: Paint background terrain. On right panel: select 
background terrain
+    #! shift-left click=Mark terrain
+    #! shift-alt-left click=Mark connected terrain
+    #! ctrl-left click=Select the terrain under the cursor as foreground 
terrain
+    #! ctrl-right click=Select the terrain under the cursor as background 
terrain
+    #! Click and drag marked terrain=Move the marked terrain 
+
+    # Common key definitions
     [hotkey]
         command="zoomin"
+        description="Zoom in"
         key="+"
         cmd=no
         alt=no
@@ -21,7 +35,26 @@
     [/hotkey]
 
     [hotkey]
+        command="zoomout"
+        description="Zoom out"
+        key="-"
+        cmd=no
+        alt=no
+        shift=no
+    [/hotkey]
+
+    [hotkey]
+        command="zoomdefault"
+        description="Zoom default"
+        key="0"
+        cmd=no
+        alt=no
+        shift=no
+    [/hotkey]
+
+    [hotkey]
         command="undo"
+        description="Undo"
         key="u"
         cmd=no
         alt=no
@@ -30,6 +63,7 @@
 
     [hotkey]
         command="redo"
+        description="Redo"
         key="r"
         cmd=no
         alt=no
@@ -37,63 +71,73 @@
     [/hotkey]
 
     [hotkey]
-        command="zoomout"
-        key="-"
-        cmd=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="zoomdefault"
-        key="0"
-        cmd=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
         command="togglegrid"
-        key="g"
-        cmd=yes
+        description="Toggle hex grid"
+        key="g" 
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="mousescroll"
+        description="Toggle mouse scrolling"
         key="l"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editsavemap"
+        description="Save map"
         key="s"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editsaveas"
+        description="Save map as"
         key="s"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=yes
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editquit"
+        description="Quit map editor"
         key="q"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editsetstartpos"
+        description="Set the starting position of a player"
         key="t"
         cmd=no
         alt=no
@@ -102,22 +146,33 @@
 
     [hotkey]
         command="editnewmap"
+        description="New map"
         key="n"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editloadmap"
+        description="Load map from file"
         key="l"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editfloodfill"
+        description="Flood fill with selected terrain"
         key="f"
         cmd=no
         alt=no
@@ -126,6 +181,7 @@
 
     [hotkey]
         command="editfillselection"
+        description="Flood map selection with selected terrain"
         key="f"
         cmd=no
         alt=yes
@@ -134,6 +190,7 @@
 
     [hotkey]
         command="editrotateselection"
+        description="Rotate selected map terrain"
         key="r"
         cmd=no
         alt=no
@@ -142,94 +199,150 @@
 
     [hotkey]
         command="editcut"
+        description="Cut selection from map"
         key="x"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editcopy"
+        description="Copy selection from map"
         key="c"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editpaste"
+        description="Paste selection to map"
         key="v"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editrevert"
+        description="Revert map from file"
         key="r"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="preferences"
+        description="Set map preferences"
         key="p"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editresize"
+        description="Resize map"
         key="r"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=yes
         shift=no
     [/hotkey]
 
     [hotkey]
         command="fullscreen"
+        description="Toggle fullscreen"
         key="f"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editselectall"
+        description="Select entire map"
         key="a"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editflip"
+        description="Flip the map"
         key="f"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=yes
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editdraw"
+        description="Set draw mode"
         key="d"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editrefresh"
+        description="Refresh map display"
         key="e"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="editupdate"
+        description="Redraw/update terrain transitions"
         key="b"
         cmd=no
         alt=no
@@ -238,261 +351,25 @@
 
     [hotkey]
         command="editautoupdate"
+        description="Delay terrain transitions"
         key="t"
-        cmd=yes
+#ifdef APPLE
+        cmd=yes
+#else
+        ctrl=yes
+#endif
         alt=no
         shift=no
     [/hotkey]
 
     [hotkey]
         command="changelanguage"
+        description="Change editor language"
         key="l"
         cmd=no
         alt=yes
         shift=no
     [/hotkey]
-
-#else
-    [hotkey]
-        command="zoomin"
-        key="+"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="undo"
-        key="u"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="redo"
-        key="r"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="zoomout"
-        key="-"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="zoomdefault"
-        key="0"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="togglegrid"
-        key="g"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="mousescroll"
-        key="l"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editsavemap"
-        key="s"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editsaveas"
-        key="s"
-        ctrl=yes
-        alt=yes
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editquit"
-        key="q"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editsetstartpos"
-        key="t"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editnewmap"
-        key="n"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editloadmap"
-        key="l"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editfloodfill"
-        key="f"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editfillselection"
-        key="f"
-        ctrl=no
-        alt=yes
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editrotateselection"
-        key="r"
-        ctrl=no
-        alt=no
-        shift=yes
-    [/hotkey]
-
-    [hotkey]
-        command="editcut"
-        key="x"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editcopy"
-        key="c"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editpaste"
-        key="v"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editrevert"
-        key="r"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="preferences"
-        key="p"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editresize"
-        key="r"
-        ctrl=yes
-        alt=yes
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="fullscreen"
-        key="f"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editselectall"
-        key="a"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editflip"
-        key="f"
-        ctrl=yes
-        alt=yes
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editdraw"
-        key="d"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editrefresh"
-        key="e"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editupdate"
-        key="b"
-        ctrl=no
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="editautoupdate"
-        key="t"
-        ctrl=yes
-        alt=no
-        shift=no
-    [/hotkey]
-
-    [hotkey]
-        command="changelanguage"
-        key="l"
-        ctrl=no
-        alt=yes
-        shift=no
-    [/hotkey]
-#endif
 
     [resolution]
         #everywhere in here 1024x768 is seen as basic reference due to some 
hardcoded values

Modified: trunk/data/tools/Makefile
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/Makefile?rev=24158&r1=24157&r2=24158&view=diff
==============================================================================
--- trunk/data/tools/Makefile (original)
+++ trunk/data/tools/Makefile Fri Feb 29 22:11:35 2008
@@ -70,4 +70,8 @@
 
 # Reindent the mainline content
 reindent:
-       wmlindent --exclude=../../data/languages $(DATA)
+       @./wmlindent --exclude=../../data/languages $(DATA)
+
+# Extract a table of editor keybindings from the editor theme definition
+editor_bindings:
+       @./extractbindings <../themes/editor.cfg 

Added: trunk/data/tools/extractbindings
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/extractbindings?rev=24158&view=auto
==============================================================================
--- trunk/data/tools/extractbindings (added)
+++ trunk/data/tools/extractbindings Fri Feb 29 22:11:35 2008
@@ -1,0 +1,48 @@
+#!/usr/bin/env python
+#
+# Extract and format a list of bindings from a theme file.
+# Presently this generates a table suitable for wiki inclusion.
+
+import sys
+
+def report(tabcolumn, binding, description):
+    "Reporter suitable for a wiki inclusion"
+    print " %*s%s" % (tabcolumn, binding, description)
+
+def strip(st):
+    if st.startswith('"'):
+        st = st[1:-1]
+    return st
+
+tabcolumn=-32
+
+in_keydef = False
+entry = {}
+for line in sys.stdin:
+    line=line.strip()
+    if line.startswith("#!"):
+        (key, explanation) = line.split("=")
+        report(tabcolumn, key[3:], explanation)
+    elif line.startswith("#"):
+        continue
+    elif line == "[hotkey]":
+        in_keydef = True
+    elif in_keydef:
+        if line == "[/hotkey]":
+            binding = ''
+            # Presently we ignore the Mac command key
+            for mod in ("ctrl", "alt", "shift"):
+                if mod in entry and entry[mod] == 'yes':
+                    binding += mod + "-"
+            binding += strip(entry['key'])
+            report(tabcolumn, binding, strip(entry['description']))
+            in_keydef = False
+            entry = {}
+        else:
+            try:
+                (key, value) = line.split("=")
+            except ValueError:
+                print >>sys.stderr, "Malformed line: %s" % `line`
+                sys.exit(1)
+            entry[key] = value
+    

Propchange: trunk/data/tools/extractbindings
------------------------------------------------------------------------------
    svn:executable = *


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to