> What are you doing?  Adding scroll bars to bodytext?

Heh, no :-)

The body pane scrollbar issue was settled here.
http://groups.google.com/group/leo-editor/browse_thread/thread/aaa852a616c12569
It was the matter of a setting.

I've been trying to implement the feature discussed in the first two
posts of this thread.

I'd like to point from the start that thinking about fileLevel as
being a multiple of c.tab_width is wrong. Ok, it is true for derived
files that contain Python code, but that's because Python is very
strict about indentation. For other languages (like C), another
approach is needed.
I would like to think that my algorithm is good, because it walks the
outline branch only once, from c.currentPosition() up to min (root, a
derived file node). But feel free to criticize or improve it.
A special note: I do admit that some of the variable names are kinda
ugly and long. Feel free to refactor the code to make it "leo-style"
in terms of variable names.
I would also like to point that I've made modifications only to the
tkinter gui. If this will go into the trunk, please don't forget to
modify other GUI classes (GTK and Swing IIRC).

This patch was made against r664:

--- cut here ---
diff -Naur /tmp/5/leo-editor-r664/leo/core/leoNodes.py /tmp/leo/leo-
editor-r664-mod/leo/core/leoNodes.py
--- /tmp/5/leo-editor-r664/leo/core/leoNodes.py 2008-07-15
09:23:05.000000000 +0000
+++ /tmp/leo/leo-editor-r664-mod/leo/core/leoNodes.py   2008-07-15
09:51:34.000000000 +0000
@@ -1007,6 +1007,8 @@
         g.app.positions += 1

         # if g.app.tracePositions and trace: g.trace(g.callers())
+
+        self.flevel = None # see self.fileLevel()
     [EMAIL PROTECTED]:ekr.20080416161551.190: p.__init__
     [EMAIL PROTECTED]:ekr.20080416161551.186:p.__cmp__, equal and isEqual
     def __cmp__(self,p2):
@@ -1391,6 +1393,46 @@

     simpleLevel = level
     [EMAIL PROTECTED]:ekr.20080416161551.197:p.level & simpleLevel
+    [EMAIL PROTECTED]:shadow.20080715122537.2:p.fileLevel
+    def fileLevel(self):
+
+        '''
+            See http://tinyurl.com/5nescw for details
+        '''
+
+        p = self
+
+        if p.flevel is not None:
+            return p.flevel
+
+        p.flevel = 0
+        is_file = False
+        for cursor in p.self_and_parents_iter():
+            cursor_is_section = False
+            cursor_headString = cursor.headString()
+            if cursor_headString.startswith('<<'):
+                cursor_is_section = True # section node
+            parent = cursor.parent()
+            if parent == None:
+                break
+            parent_bodyString = parent.bodyString()
+            if parent_bodyString == '': # organizer node
+                continue
+            parent_lines = parent_bodyString.split('\n')
+            for line in parent_lines:
+                if cursor_is_section == True:
+                    pos = line.find(cursor_headString)
+                else:
+                    pos = line.find('@others')
+                if pos > 0:
+                    break
+            if pos > 0:
+                p.flevel += pos
+            if parent.v.isAnyAtFileNode(): # do not scan upper
+                break
+
+        return p.flevel
+    [EMAIL PROTECTED]:shadow.20080715122537.2:p.fileLevel
     [EMAIL PROTECTED]:ekr.20040306212636:p.Getters
     [EMAIL PROTECTED]:ekr.20040305222924:p.Setters
     [EMAIL PROTECTED]:ekr.20040306220634:p.Vnode proxies
diff -Naur /tmp/5/leo-editor-r664/leo/core/leoTkinterFrame.py /tmp/leo/
leo-editor-r664-mod/leo/core/leoTkinterFrame.py
--- /tmp/5/leo-editor-r664/leo/core/leoTkinterFrame.py  2008-07-15
09:23:06.000000000 +0000
+++ /tmp/leo/leo-editor-r664-mod/leo/core/leoTkinterFrame.py
2008-07-15 09:32:19.000000000 +0000
@@ -974,7 +974,7 @@
             #    self.log.colorTags.append("black")
             self.parentFrame = parentFrame
             self.statusFrame = Tk.Frame(parentFrame,bd=2)
-            text = "line 0, col 0"
+            text = "line 0, col 0, fcol = 0"
             width = len(text) + 4
             self.labelWidget =
Tk.Label(self.statusFrame,text=text,width=width,anchor="w")
             self.labelWidget.pack(side="left",padx=1)
@@ -1111,9 +1111,10 @@
                 s2 = s[index-col:index]
                 s2 = g.toUnicode(s2,g.app.tkEncoding)
                 col = g.computeWidth (s2,c.tab_width)
+            fcol = col + c.currentPosition().fileLevel()

             # Important: this does not change the focus because
labels never get focus.
-            self.labelWidget.configure(text="line %d, col %d" %
(row,col))
+            self.labelWidget.configure(text="line %d, col %d, fcol
%d" % (row,col,fcol))
             self.lastRow = row
             self.lastCol = col
         [EMAIL PROTECTED]:ekr.20031218072017.1733:update (statusLine)
--- cut here ---

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to