]> git.neil.brown.name Git - edlib.git/commitdiff
present: allow switching to presentation from markdown
authorNeilBrown <neil@brown.name>
Sat, 17 Sep 2022 03:07:35 +0000 (13:07 +1000)
committerNeilBrown <neil@brown.name>
Sat, 17 Sep 2022 03:09:04 +0000 (13:09 +1000)
:Commit (:C-c :C-c) will now switch markdown view to presenter view.
This is a bit clumsy as we have to ensure now markup (like spell errors)
can mess things up for us.

Switching back sometimes works

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
python/render-present.py

index a6a6c12128dfa83c3c8b87b36813bb4683653a1e..52ce4e1f45e50477f1176090369b50a441c41a97 100644 (file)
@@ -716,7 +716,7 @@ Module features
 ### Presenter
 
 - [1] split into lower pane which parse markdown and upper which handles presentation.
-- [1] command to immediately change current pane in to presenter view
+- [X] command to immediately change current pane in to presenter view
 - [ ] translucent bg colour for paragraphs
 - [ ] partial-view-points. Only render beyond here if mark here or beyond.
     page-down goes to next such point
index 3656a488d5082cc2fa9a7ee70a9c5947d3ea5086..18619da63fcae6fec103262db820ebe7ba400814 100644 (file)
@@ -79,6 +79,15 @@ class PresenterPane(edlib.Pane):
         self['background'] = 'color:yellow'
         self['hide-cursor'] = 'yes'
 
+    def handle_commit(self, key, focus, **a):
+        "handle:Commit"
+        self.close()
+        return 1
+    def map_attr(self, key, **a):
+        "handle:map-attr"
+        # we don't want want mapping happening, because we don't handle it.
+        return 1
+
     def first_page(self):
         return self.vmarks(self.pageview)[0]
 
@@ -94,14 +103,14 @@ class PresenterPane(edlib.Pane):
     def get_line_at(self, m):
         # call render-line at m
         try:
-            s = self.parent.call("doc:render-line", m, -1, ret = 'str')
+            s = self.parent.call("doc:render-line", self, m, -1, ret = 'str')
         except:
             s = ''
         return s if s else ''
 
     def get_line_before(self, m):
         m2 = m.dup()
-        ret = self.parent.call("doc:render-line-prev", m2, 1)
+        ret = self.parent.call("doc:render-line-prev", self, m2, 1)
         if ret <= 0:
             return None
         l = self.get_line_at(m2)
@@ -723,6 +732,20 @@ class MarkdownPane(edlib.Pane):
                 return 1
         return edlib.Efallthrough
 
+    def handle_commit(self, key, focus, **a):
+        "handle:Commit"
+        p = focus
+        while p != p.parent:
+            edlib.LOG(p == self, p)
+            p = p.parent
+        par = self
+        edlib.LOG("try", par, par.parent);
+        p = PresenterPane(par.parent)
+        if p:
+            p.call("attach-viewer")
+            par.close()
+        return 1
+
 def present_attach(key, focus, comm2, **a):
     p = PresenterPane(focus)