foiegras r66 - in trunk: . src/foiegras src/foiegras/buffer



Author: denisw
Date: Tue Mar 11 15:00:56 2008
New Revision: 66
URL: http://svn.gnome.org/viewvc/foiegras?rev=66&view=rev

Log:
2008-03-11  Denis Washington  <denisw svn gnome org>

	* src/foiegras/document.py:
	* src/foiegras/buffer/block_handler.py:
	* src/foiegras/buffer/docbuffer.py:
	* src/foiegras/buffer/save.py:
	* src/foiegras/buffer/tags.py:
	Implement simple saving (inline tags and simple block tags are
	implemented, the rest is still to be done).


Modified:
   trunk/ChangeLog
   trunk/src/foiegras/buffer/block_handler.py
   trunk/src/foiegras/buffer/docbuffer.py
   trunk/src/foiegras/buffer/tags.py
   trunk/src/foiegras/document.py

Modified: trunk/src/foiegras/buffer/block_handler.py
==============================================================================
--- trunk/src/foiegras/buffer/block_handler.py	(original)
+++ trunk/src/foiegras/buffer/block_handler.py	Tue Mar 11 15:00:56 2008
@@ -39,7 +39,7 @@
             buffer.insert(block_iter,"\n")
             block_iter = buffer.get_iter_at_mark(buffer.get_insert())
         else:
-            block_iter.set_line_offset(0)
+            block_iter.set_line_offset(0)
    
     start_offset = block_iter.get_offset()
 
@@ -48,7 +48,8 @@
     
     if not buffer.get_has_selection():
         if not end_iter.ends_line():
-          end_iter.forward_to_line_end() 
+            end_iter.forward_to_line_end()
+            end_iter.forward_char()
         end_offset = end_iter.get_offset()
     else:
         end_offset = end_offset+1        

Modified: trunk/src/foiegras/buffer/docbuffer.py
==============================================================================
--- trunk/src/foiegras/buffer/docbuffer.py	(original)
+++ trunk/src/foiegras/buffer/docbuffer.py	Tue Mar 11 15:00:56 2008
@@ -21,6 +21,7 @@
 
 from block_handler import block_handler
 from tags import INLINE_TAGS, BLOCK_TAGS, SIMPLE_BLOCK_TAGS, TAG_TABLE
+from save import save_document
 
 def _(string):
     return string
@@ -59,16 +60,26 @@
 
             newline_iter = self.get_start_iter().copy()
 
-            while not newline_iter.get_char() == "\n":
+            while not newline_iter.ends_line():
                 newline_iter.forward_char()
 
+            p_start = newline_iter.copy()
+            p_start.forward_char()
+            p_end = self.get_end_iter()
+
+            self.select_range(p_start, p_end)
+            self.apply_block_tag("p", p_start)
+
+            newline_iter = self.get_start_iter().copy()
+
+            while not newline_iter.ends_line():
+                newline_iter.forward_char()
 
             end_iter = newline_iter.copy()
             end_iter.forward_char()
 
             self.apply_tag(self.get_tag_table().lookup("_readonly"), newline_iter, end_iter)
 
- 
     def get_filename(self):
         """
         Returns the name of the file represented by the buffer.
@@ -85,7 +96,7 @@
         if filename:
             self.__filename = filename
 
-        foiegras.buffer.save.save_document(self)
+        save_document(self)
 
 
     def apply_block_tag(self, tag_name, block_iter = None):

Modified: trunk/src/foiegras/buffer/tags.py
==============================================================================
--- trunk/src/foiegras/buffer/tags.py	(original)
+++ trunk/src/foiegras/buffer/tags.py	Tue Mar 11 15:00:56 2008
@@ -26,7 +26,12 @@
 
 TAG_TABLE = gtk.TextTagTable()
 
-def setup_tags():
+
+def get_text_tag(tag_name):
+    return TAG_TABLE.lookup(tag_name)
+
+
+def _setup_tags():
 
     def block_tag(name):
         BLOCK_TAGS.append(name)
@@ -156,4 +161,4 @@
     tag.set_property("style", pango.STYLE_ITALIC)
     TAG_TABLE.add(tag)
 
-setup_tags()
+_setup_tags()

Modified: trunk/src/foiegras/document.py
==============================================================================
--- trunk/src/foiegras/document.py	(original)
+++ trunk/src/foiegras/document.py	Tue Mar 11 15:00:56 2008
@@ -118,11 +118,7 @@
         Save the document.
         """
         if self._filename is not None:
-            f = file(self._filename, 'w')
-            (start, end) = self._buffer.get_bounds()
-            f.write(self._buffer.get_text(start, end))
-            f.close()
-            self._changed = False
+            self._buffer.save(self._filename)
         else:
             print "DEBUG: no filename specified, really shouldn't happen."
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]