[sorrows-mudlib] r205 committed - - Documentation system changes (can't remember what)....

1 view
Skip to first unread message

sorrows...@googlecode.com

unread,
May 12, 2011, 8:11:04 AM5/12/11
to sorrows-mud...@googlegroups.com
Revision: 205
Author: richard.m.tew
Date: Thu May 12 05:09:54 2011
Log: - Documentation system changes (can't remember what).
- Roguelike character set related changes. Now tiles and drawing
characters are indexed as unicode, and they are converted to either CP437
(Windows Telnet and other normal clients) or UTF-8 (Putty) as required. As
I use Chinese Windows, Putty interprets characters as CP963 which does not
have the line drawing characters for instance.
http://code.google.com/p/sorrows-mudlib/source/detail?r=205

Modified:
/trunk/bootstrap.py
/trunk/doc/build.bat
/trunk/doc/conf.py
/trunk/games/roguelike/shells/roguelike.py
/trunk/mudlib/services/transcript.py

=======================================
--- /trunk/bootstrap.py Fri Jan 7 05:23:18 2011
+++ /trunk/bootstrap.py Thu May 12 05:09:54 2011
@@ -97,8 +97,8 @@
# Register the mudlib and game script directories with the livecoding
# module. This will compile and execute them all.
import reloader
- gamePath = os.path.join("games", "room - simple")
- #gamePath = os.path.join("games", "roguelike")
+ #gamePath = os.path.join("games", "room - simple")
+ gamePath = os.path.join("games", "roguelike")
gameScriptPath = os.path.join(dirPath, gamePath)
mudlibScriptPath = os.path.join(dirPath, "mudlib")

=======================================
--- /trunk/doc/build.bat Sun Feb 21 00:34:04 2010
+++ /trunk/doc/build.bat Thu May 12 05:09:54 2011
@@ -1,4 +1,42 @@
-REM Most of the time this will complain about the directory already
existing.
-2>nul makedir %~dp0%build\html
-
-c:\python26\scripts\sphinx-build %~dp0 %~dp0%build\html
+@@echo off
+
+REM Check command line arguments.
+if "%1" EQU "html" goto build
+if "%1" EQU "htmlhelp" goto build
+
+echo Please specify a documentation build target.
+set this=%~n0
+echo %this% html
+echo %this% htmlhelp
+
+goto end
+
+:build
+
+REM Find the 32 bit Program Files directory.
+set PFA=%ProgramFiles%
+if not "%ProgramFiles(x86)%" == "" set PFA=%ProgramFiles(x86)%
+
+REM Set defaults for non-existent environment variables.
+if "%HTMLHELP%" EQU "" set HTMLHELP=%PFA%\HTML Help Workshop\hhc.exe
+
+REM Hard-coded paths.
+set PYTHON=C:\python27\python.exe
+set
DOCPATH=D:\VCS\SVN\Python\Stackless\__exports__\release27-maint-export\release27-maint\Doc
+
+set TARGETTYPE=%1
+set SOURCEPATH=%~dp0%
+set BUILDPATH=%SOURCEPATH%build
+set DOCTREEPATH=%BUILDPATH%\doctrees
+set TARGETPATH=%BUILDPATH%\%TARGETTYPE%
+
+if not exist %BUILDPATH% mkdir %BUILDPATH%
+if not exist %DOCTREEPATH% mkdir %DOCTREEPATH%
+if not exist %TARGETPATH% mkdir %TARGETPATH%
+
+cmd /C %PYTHON% %DOCPATH%\tools\sphinx-build.py -b%TARGETTYPE%
-d%DOCTREEPATH% %SOURCEPATH% %TARGETPATH%
+
+echo %HTMLHELP%
+if "%TARGETTYPE%"
EQU "htmlhelp" "%HTMLHELP%" %TARGETPATH%\SorrowsMudlib.hhp
+
+:end
=======================================
--- /trunk/doc/conf.py Fri Feb 26 01:07:53 2010
+++ /trunk/doc/conf.py Thu May 12 05:09:54 2011
@@ -9,6 +9,8 @@
exclude_trees = [ "Sphinx-0.6.4", "build" ]
highlight_language = "python"

+templates_path = [ "templates" ]
+
# -- Options for HTML output
---------------------------------------------------

# The theme to use for HTML and HTML Help pages. Major themes that come
with
@@ -57,10 +59,12 @@

# Additional templates that should be rendered to pages, maps page names to
# template names.
-#html_additional_pages = {}
+html_additional_pages = {
+ "index": "index.html",
+}

# If false, no module index is generated.
-#html_use_modindex = True
+html_use_modindex = False

# If false, no index is generated.
html_use_index = False
=======================================
--- /trunk/games/roguelike/shells/roguelike.py Fri Jan 7 05:23:18 2011
+++ /trunk/games/roguelike/shells/roguelike.py Thu May 12 05:09:54 2011
@@ -74,6 +74,12 @@

CTRL_E = chr(5) # ENQ

+# Escape codes.
+
+ESC_UTF8_CHARSET = "\x1b%G"
+ESC_DEFAULT_CHARSET = "\x1b%@"
+ESC_SCO_CHARSET = "\x1b(U"
+

CHAR_TILE = "@"
WALL_TILE = "X"
@@ -83,16 +89,40 @@
DOOR_TILE = "D"
CUBE_TILE = "C"

-displayTiles = {
- # Option to display different types if in or out of field of view.
- WALL_TILE1: chr(176),
- WALL_TILE2: chr(177),
- WALL_TILE: chr(178),
- FLOOR_TILE: chr(250),
- DOOR_TILE: chr(254), # 239
- CUBE_TILE: chr(219),
+charMap = {
+ "unicode" : {
+ # Map character mappings.
+ WALL_TILE1: u"\u2591", # Light shade.
+ WALL_TILE2: u"\u2592", # Medium shade.
+ WALL_TILE: u"\u2593", # Dark shade.
+ FLOOR_TILE: u"\xB7", # Middle dot.
+ DOOR_TILE: u"\u25A0", # Black square.
+ CUBE_TILE: u"\u2588", # Full block.
+ CHAR_TILE: u"@",
+
+ # Line-drawing characters.
+ "light-horizontal": u"\u2500",
+ "light-vertical": u"\u2502",
+ "light-down-and-right": u"\u250C",
+ "light-down-and-left": u"\u2510",
+ "light-up-and-right": u"\u2514",
+ "light-up-and-left": u"\u2518",
+ "full-block": u"\u2588",
+ "medium-shade": u"\u2592",
+ }
}

+def CHARACTERS(key, encoding):
+ encodingCharMap = charMap.get(encoding)
+ # Cache the characters in the given encoding, if they already are not.
+ if not encodingCharMap:
+ encodingCharMap = {}
+ for key_, value_ in charMap["unicode"].iteritems():
+ encodingCharMap[key_] = value_.encode(encoding)
+ charMap[encoding] = encodingCharMap
+ return encodingCharMap[key]
+
+
TILE_SEEN = 1
TILE_OPEN = 2

@@ -163,6 +193,7 @@
self.RecalculateWorldView()

self.charsetResetSequence = None
+ self.charsetEncoding = "cp437"

self.UpdateTitle()
self.UpdateStatusBar("Use the up and down cursor keys to choose an
option, and enter to select it.")
@@ -178,7 +209,8 @@
self.clientName = clientName.lower()

if self.clientName == "putty":
- self.charsetResetSequence = "\x1b(U"
+ self.charsetEncoding = "utf8"
+ self.charsetResetSequence = ESC_UTF8_CHARSET # ESC_SCO_CHARSET
self.ResetCharset()

def SetMode(self, mode, status=None):
@@ -775,7 +807,7 @@
if tile is None:
yield " "
else:
- yield self.TileColouring(tile)
+ yield self.TileColouring(tile)
x += 1

if emphasis:
@@ -798,7 +830,7 @@
s += "\x1b[4%dm" % tile.bgColour
if emphasis:
s += ESC_BOLD
- s += displayTiles.get(tile.character, tile.character)
+ s += CHARACTERS(tile.character, self.charsetEncoding)
if emphasis:
s += ESC_NORMAL
if tile.fgColour:
@@ -944,9 +976,9 @@
# Menu top border.
self.MoveCursor(screenXStart, screenY, sio=sio)
sio.write(ESC_GFX_BLUE_FG)
- sio.write(chr(218))
- sio.write(chr(196) * optionWidth)
- sio.write(chr(191))
+ sio.write(CHARACTERS("light-down-and-right",
self.charsetEncoding))
+ sio.write(CHARACTERS("light-horizontal", self.charsetEncoding)
* optionWidth)
+ sio.write(CHARACTERS("light-down-and-left",
self.charsetEncoding))
sio.write(ESC_RESET_ATTRS)

screenY += 1
@@ -958,15 +990,15 @@
# Menu top space.
self.MoveCursor(screenXStart, screenY, sio=sio)
sio.write(ESC_GFX_BLUE_FG)
- sio.write(chr(179))
+ sio.write(CHARACTERS("light-vertical",
self.charsetEncoding))
sio.write(" " * optionWidth)
- sio.write(chr(179))
+ sio.write(CHARACTERS("light-vertical",
self.charsetEncoding))
sio.write(ESC_RESET_ATTRS)

screenY += 1
self.MoveCursor(screenXStart, screenY, sio=sio)
sio.write(ESC_GFX_BLUE_FG)
- sio.write(chr(179))
+ sio.write(CHARACTERS("light-vertical", self.charsetEncoding))
sio.write(ESC_RESET_ATTRS)
sio.write(" ")
if i == selected:
@@ -976,7 +1008,7 @@
sio.write(ESC_REVERSE_VIDEO_OFF)
sio.write(" ")
sio.write(ESC_GFX_BLUE_FG)
- sio.write(chr(179))
+ sio.write(CHARACTERS("light-vertical", self.charsetEncoding))
sio.write(ESC_RESET_ATTRS)
screenY += 1

@@ -984,18 +1016,18 @@
# Menu bottom space.
self.MoveCursor(screenXStart, screenY, sio=sio)
sio.write(ESC_GFX_BLUE_FG)
- sio.write(chr(179))
+ sio.write(CHARACTERS("light-vertical", self.charsetEncoding))
sio.write(" " * optionWidth)
- sio.write(chr(179))
+ sio.write(CHARACTERS("light-vertical", self.charsetEncoding))
sio.write(ESC_RESET_ATTRS)
screenY += 1

# Menu bottom border.
self.MoveCursor(screenXStart, screenY, sio=sio)
sio.write(ESC_GFX_BLUE_FG)
- sio.write(chr(192))
- sio.write(chr(196) * optionWidth)
- sio.write(chr(217))
+ sio.write(CHARACTERS("light-up-and-right",
self.charsetEncoding))
+ sio.write(CHARACTERS("light-horizontal", self.charsetEncoding)
* optionWidth)
+ sio.write(CHARACTERS("light-up-and-left",
self.charsetEncoding))
sio.write(ESC_RESET_ATTRS)
screenY += 1

@@ -1180,7 +1212,7 @@
sio.write(" %02d " % yc)

sio.write("\x1b[%dm" % yc)
- sio.write(chr(219)+chr(219))
+ sio.write(CHARACTERS("full-block", self.charsetEncoding) +
CHARACTERS("full-block", self.charsetEncoding))

for s in ("", ESC_BOLD):
for xi in range(8):
@@ -1188,7 +1220,7 @@
sio.write("\x1b[%dm" % yc)
sio.write("\x1b[%dm" % xc)
sio.write(s)
- sio.write(chr(177)+chr(177))
+ sio.write(CHARACTERS("medium-shade",
self.charsetEncoding) + CHARACTERS("medium-shade", self.charsetEncoding))
sio.write(ESC_RESET_ATTRS)

sio.write("\r\n")
@@ -1199,7 +1231,7 @@

def MenuActionCharacters(self, charsetCode=None, inUnicode=False):
if inUnicode:
- state = "UTF-8"
+ state = "UTF8"
else:
state = "CP437"
self.SetMode(MODE_DEBUG_DISPLAY, "Characters (%s)" % state)
@@ -1214,43 +1246,22 @@

ranges = []
if inUnicode:
- firstOrd, lastOrd = 0xc280, 0xc2bf
+ firstOrd, lastOrd = 0x2500, 0x257F
ranges.append((firstOrd, lastOrd))

- firstOrd, lastOrd = 0xc580, 0xc5bf
+ firstOrd, lastOrd = 0x25A0, 0x25CF
ranges.append((firstOrd, lastOrd))

- firstOrd, lastOrd = 0xc680, 0xc6bf
+ firstOrd, lastOrd = 0x25D0, 0x25FF
ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xc780, 0xc7bf
+
+ firstOrd, lastOrd = 0x2600, 0x267F
ranges.append((firstOrd, lastOrd))

- firstOrd, lastOrd = 0xc880, 0xc8bf
+ firstOrd, lastOrd = 0x2190, 0x21ff
ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xc980, 0xc9bf
- ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xca80, 0xcabf
- ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xcb80, 0xcbbf
- ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xce80, 0xcebf
- ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xcf80, 0xcfbf
- ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xe29480, 0xe294BF
- ranges.append((firstOrd, lastOrd))
-
- firstOrd, lastOrd = 0xe29580, 0xe295BF
- ranges.append((firstOrd, lastOrd))
-
- sio.write("\x1b%G")
+
+ sio.write(ESC_UTF8_CHARSET)
else:
firstOrd, lastOrd = 32, 255
ranges.append((firstOrd, lastOrd))
@@ -1267,11 +1278,7 @@
currentOrd = firstOrd
while currentOrd <= lastOrd:
if inUnicode:
- v = currentOrd
- s = ""
- while v:
- s = chr(v & 0xFF) + s
- v = v >> 8
+ s = eval("u'\\u%x'" % currentOrd).encode("utf8")
else:
c = self.DisplayCharacter(currentOrd,
charset=charsetCode)
s = "%03d %s" % (currentOrd, c)
@@ -1297,7 +1304,7 @@
sio.write("\r\n")

if inUnicode:
- sio.write("\x1b%@")
+ sio.write(ESC_DEFAULT_CHARSET)

self.ResetCharset(sio=sio)
self.user.Write(sio.getvalue())
=======================================
--- /trunk/mudlib/services/transcript.py Sat Dec 25 00:29:47 2010
+++ /trunk/mudlib/services/transcript.py Thu May 12 05:09:54 2011
@@ -11,7 +11,8 @@
# Locate and verify the files existence.
transcriptPath =
os.path.join(sorrows.services.gameScriptPath, "transcripts")
if not os.path.exists(transcriptPath):
- raise RuntimeError("Failed to locate transcript path")
+ self.LogError("Failed to locate transcript path: %s",
transcriptPath)
+ return
self.transcriptPath = transcriptPath

def Load(self, transcriptName):

Reply all
Reply to author
Forward
0 new messages