Commits

Ronny Pfannschmidt  committed cd7a683

initial buffer stuff

  • Participants
  • Parent commits 91d4d7c

Comments (0)

Files changed (2)

File tests/test_engine.py

 
 
-def test_create_buffer(engine):
+def test_buffer_line_count(engine):
     buffer = engine.create_buffer()
+    buffer.text = "Test\ntest2"
+    assert len(buffer) == 2
+    buffer.append("\n")
+    assert len(buffer) == 3
+
+

File vimish/engine.py

     handles input mapping and command processing
 """
 
+from gtk import TextBuffer
+
+
+class Buffer(object):
+    def __init__(self, engine):
+        self.engine = engine
+        self.text_buffer = TextBuffer()
+
+    @property
+    def text(self):
+        return self.text_buffer.get_text(
+                self.text_buffer.get_start_iter(),
+                self.text_buffer.get_end_iter()
+                )
+
+    @text.setter
+    def text(self, text):
+        self.text_buffer.set_text(text)
+
+    def append(self, text):
+        self.text_buffer.insert(
+                self.text_buffer.get_end_iter(),
+                text)
+
+    def __len__(self):
+        return self.text_buffer.get_line_count()
 
 class Engine(object):
-    
+
     def create_buffer(self):
-        return
+        return Buffer(self)
+
+