[Xword-commits] r59 - in trunk: debian root/usr/bin
btb at garage.maemo.org
btb at garage.maemo.org
Wed Apr 30 03:32:35 EEST 2008
Author: btb
Date: 2008-04-30 03:32:33 +0300 (Wed, 30 Apr 2008)
New Revision: 59
Modified:
trunk/debian/changelog
trunk/root/usr/bin/xword
Log:
notepad contents are now saved
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-04-26 13:29:02 UTC (rev 58)
+++ trunk/debian/changelog 2008-04-30 00:32:33 UTC (rev 59)
@@ -3,9 +3,9 @@
* Added osso support
* Basic file magic checking
* Support cryptic-type puzzles
- * Added notebook support (read-only for now)
+ * Added notebook support
- -- Bradley Bell <bradleyb at u.washington.edu> Thu, 24 Apr 2008 20:21:16 -0700
+ -- Bradley Bell <bradleyb at u.washington.edu> Tue, 29 Apr 2008 17:26:35 -0700
xword (1.0.5) stable; urgency=low
Modified: trunk/root/usr/bin/xword
===================================================================
--- trunk/root/usr/bin/xword 2008-04-26 13:29:02 UTC (rev 58)
+++ trunk/root/usr/bin/xword 2008-04-30 00:32:33 UTC (rev 59)
@@ -180,6 +180,7 @@
self.responses = {}
self.errors = {}
self.clock = 0
+ self.notes = ''
def get_size(self, m):
width = 0
@@ -207,13 +208,20 @@
bin2[index] = chr(self.errors[x, y])
bin = ''.join(bin1 + bin2)
- return '%d %d %d %s' % (width, height, int(self.clock), bin)
+ return '%d %d %d %s %s%c' % (width, height, int(self.clock), bin, self.notes, chr(0))
def get_int(self, s, pos):
pos0 = pos
while pos < len(s) and s[pos].isdigit(): pos += 1
return (int(s[pos0:pos]), pos)
+ def get_string(self, s, pos):
+ str = ''
+ while pos < len(s) and ord(s[pos]) is not 0:
+ str += s[pos]
+ pos += 1
+ return (str, pos)
+
def from_binary(self, bin):
pos = 0
(width, pos) = self.get_int(bin, pos)
@@ -225,8 +233,13 @@
count = width*height
bin1 = bin[pos:pos+count]
- bin2 = bin[pos+count:]
+ pos += count
+ bin2 = bin[pos:pos+count]
+ pos += count
+ pos += 1
+ (self.notes, pos) = self.get_string(bin, pos)
+
self.responses = {}
self.errors = {}
@@ -1383,6 +1396,8 @@
self.puzzle.responses = pp.responses
self.puzzle.errors = pp.errors
+ if len(pp.notes) > 0:
+ self.puzzle.notes = pp.notes
self.clock_time = pp.clock
except:
self.notify('The saved puzzle is corrupted. It will not be used.')
@@ -1415,6 +1430,8 @@
self.clock_time += (time.time() - self.clock_start)
pp.clock = self.clock_time
+ pp.notes = self.puzzle.notes
+
fname = self.get_puzzle_file(self.puzzle)
f = file(fname, 'w+')
f.write(pp.to_binary())
@@ -1502,6 +1519,8 @@
close_button.grab_focus()
notepad.set_size_request(650, 350)
notepad.run()
+ (start, end) = textbuf.get_bounds()
+ self.puzzle.notes = textbuf.get_slice(start, end, True)
notepad.destroy()
def show_about(self):
More information about the Xword-commits
mailing list