Re: [Simple script] Jump exactly one page with Page Down
I studied the code yesterday, but its too complex for me to understand. And as you say, my scripts are probably unstable, and its hard to wire them into the rest of the existing code. So I'm guessing this conversation is over becasue of those reasons. Anyway, they are very useful, I couldn't study in Leo without them. They always work and jump just the amount of lines I need. Also checked into make them as a new default command in leosettings and bind them to the hotkeys, but there isn't a list of commands in leosettings.leo, so I figured that there must be a reason for that. On Mon, Aug 25, 2014 at 3:50 AM, Brian Theado wrote: > Fidel, > > On Sat, Aug 23, 2014 at 3:46 AM, Fidel N wrote: > > Brian, if you are happy with that solution, I will try to replace the > > current code with the new one. > > Otherwise please tell me what to improve, I'll try and edit the script > to do > > that. > > I don't have a good feel for what properties are important for the > PageUp/PageDown functionality. Nor do I have a good feel for how your > code changes the behavior (I know it fixes the issue which caused you > trouble, but what other effects does it have). IOW, I haven't spent > any time on it :-(. > > The code change I had made was a just a port of the built-in Qt > functionality and I figured with it being widely used, the dynamics of > the behavior were pretty good and so I only worried about duplicating > the functionality. > > I haven't looked yet to see if there are any unit tests in Leo related > to this functionality. Probably a good idea to have some. > > Brian > > -- > You received this message because you are subscribed to the Google Groups > "leo-editor" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to leo-editor+unsubscr...@googlegroups.com. > To post to this group, send email to leo-editor@googlegroups.com. > Visit this group at http://groups.google.com/group/leo-editor. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
Fidel, On Sat, Aug 23, 2014 at 3:46 AM, Fidel N wrote: > Brian, if you are happy with that solution, I will try to replace the > current code with the new one. > Otherwise please tell me what to improve, I'll try and edit the script to do > that. I don't have a good feel for what properties are important for the PageUp/PageDown functionality. Nor do I have a good feel for how your code changes the behavior (I know it fixes the issue which caused you trouble, but what other effects does it have). IOW, I haven't spent any time on it :-(. The code change I had made was a just a port of the built-in Qt functionality and I figured with it being widely used, the dynamics of the behavior were pretty good and so I only worried about duplicating the functionality. I haven't looked yet to see if there are any unit tests in Leo related to this functionality. Probably a good idea to have some. Brian -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
Brian, if you are happy with that solution, I will try to replace the current code with the new one. Otherwise please tell me what to improve, I'll try and edit the script to do that. Fidel. -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
Btw, I meant to quote that I did neither notice that behaviour until I had to read so much in Leo. On Thu, Aug 21, 2014 at 9:45 AM, Fidel N wrote: > I've never use Leo to read long chunks of text linearly... > > > Exactly, neither did I until I decided to study my public exam within Leo > > >> So there are misbehaviors in both implementations. I don't immediately >> > > Yes, I also noticed what you mention, but didn't think this had the > possibility to replace the current implementation so didn't bother. > A fix for that would be this: > > scroll_changed = c.frame.body.bodyCtrl.getYScrollPosition() > lines = c.frame.body.bodyCtrl.linesPerPage() > cursor_position = 0 > for number in range(lines): > cursor_position=cursor_position+1 > c.executeMinibufferCommand("next-line") > if not scroll_changed == c.frame.body.bodyCtrl.getYScrollPosition(): > break #We reached the first line outside the current view of the text. > if cursor_position > (lines * 2): > break # Too many lines, we are either in the bottom of the document > > for number in range(lines-1): > c.executeMinibufferCommand("next-line") > > #Now you can optionally go back "lines-cursor_position" lines to put the > cursor where it 'was'. > > > Fidel. > > -- > You received this message because you are subscribed to the Google Groups > "leo-editor" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to leo-editor+unsubscr...@googlegroups.com. > To post to this group, send email to leo-editor@googlegroups.com. > Visit this group at http://groups.google.com/group/leo-editor. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
> > I've never use Leo to read long chunks of text linearly... Exactly, neither did I until I decided to study my public exam within Leo > So there are misbehaviors in both implementations. I don't immediately > Yes, I also noticed what you mention, but didn't think this had the possibility to replace the current implementation so didn't bother. A fix for that would be this: scroll_changed = c.frame.body.bodyCtrl.getYScrollPosition() lines = c.frame.body.bodyCtrl.linesPerPage() cursor_position = 0 for number in range(lines): cursor_position=cursor_position+1 c.executeMinibufferCommand("next-line") if not scroll_changed == c.frame.body.bodyCtrl.getYScrollPosition(): break #We reached the first line outside the current view of the text. if cursor_position > (lines * 2): break # Too many lines, we are either in the bottom of the document for number in range(lines-1): c.executeMinibufferCommand("next-line") #Now you can optionally go back "lines-cursor_position" lines to put the cursor where it 'was'. Fidel. -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
On Wed, Aug 20, 2014 at 2:52 AM, Fidel N wrote: > Its true, in general jumps just one page, but if the body pane is a bit > bigger / smaller than X full lines (ie total length is, for instance, 12'5 > lines), it jumps one line more than desirable, so you have to go back to > read it. You are right...when only the top half of the last line on the screen is showing, then page down will advance exactly one screen height which will cause what used to be the last line to be the first line, but now you see just the bottom half of it. So in neither case do you see that line in its entirety which makes it hard to read. And that's your complaint, right? I've never use Leo to read long chunks of text linearly...always jumping around and scanning/searching...so I've never noticed the behavior. > Also, Im using a speed reading technique that implies reading 4-6 lines per > eye jump. > So I adjust the body pane to be 4/6 words wide, then read jumping down with > my eyes. [...] I put your code into script buttons and played a little and didn't really like some of the behavior. # page down for number in range(c.frame.body.bodyCtrl.linesPerPage()): c.executeMinibufferCommand("next-line") # page up for number in range(c.frame.body.bodyCtrl.linesPerPage()): c.executeMinibufferCommand("previous-line") With the cursor at the top line of the page, hitting page down moved the cursor to the last line on the page and didn't advance the screen at all. Hitting page down a second time advanced the display by one screen. The cursor is now on the last line of the screen and hitting page up moves it to the top of the screen, again not shifting the screen. So there are misbehaviors in both implementations. I don't immediately see a way to fix the issues in either approach, but maybe there is a way. If not, one of the two approaches needs to be chosen as the default, with the other left to user customization. Brian -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
Thanks Brian for your elaborate response. Its true, in general jumps just one page, but if the body pane is a bit bigger / smaller than X full lines (ie total length is, for instance, 12'5 lines), it jumps one line more than desirable, so you have to go back to read it. In the way I use Leo, I keep resizing the body pane, so I cant just set a body pane heigth and always use it. Hence the need for that script, you can exactly control the jump. Also, Im using a speed reading technique that implies reading 4-6 lines per eye jump. So I adjust the body pane to be 4/6 words wide, then read jumping down with my eyes. With current pgup and pgdn, with the line missing problem, makes it impossible to speed read. Going back to read the missing line defeats the whole purpose. With the script I suggested, it just jumps exactly the same amount all the time, so it becomes useful. Im guessing the difference might be in the line number, mine being integer and yours a flotat, or vice versa. As per c.frame.body.bodyCtrl.linesPerPage() this comes from my recent experiences with Leo, for reaching the widgets I use "c.frame.X" XXX being the widget name. Im not able to elaborate much more, its because of the way I studied Leo, just surfing leopyref, grabbing snippets that do what I need, and using them elsewhere. "c.frame.body.bodyCtrl" turns out to be the body pane, with a linesPerPage method among others. Best regards, Fidel. On Wed, Aug 20, 2014 at 3:02 AM, Brian Theado wrote: > On Tue, Aug 19, 2014 at 8:16 PM, Brian Theado > wrote: > > A few years ago the page up/down functionality was a fixed number of > > lines. I looked into the QT cpp code and translated it to python and > > checked it in: > > > > > https://github.com/leo-editor/leo-editor/commit/9401804f956c0eef31d2068450a21436e9939268 > > Whoops, that was an earlier commit which took a different approach. > Here is the commit which implements the port of the QT code to python: > > > https://github.com/leo-editor/leo-editor/commit/3f0dc96e7fe155692a06b08eb40be917a7f52e97 > > Here is a UNL to the code in question: > > leo-editor/leo/core/LeoPyRef.leo#Code-->Qt gui-->@file > ../plugins/qtGui.py--> << define text widget classes >>--> << define > LeoQTextEditWidget class >>-->leoMoveCursorHelper & helper > (LeoQTextEditWidget)-->pageUpDown > > The code moves the cursor one line at a time until the total screen > distance moved is greater than or equal to the height of the body. > After that, it moves the scroll bar one page in the same direction the > cursor was moved. > > So I'd be interested in hearing in what situation it breaks for you. > > > 2) Where did the c.frame.body.bodyCtrl.linesPerPage() function come > > from? Did I just miss it when I made my change a few years ago? > > The pageUpDown implementation will work even if some lines have > different height. Not sure that ever happens, but linesPerPage will > not handle that case. > > Brian > > -- > You received this message because you are subscribed to the Google Groups > "leo-editor" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to leo-editor+unsubscr...@googlegroups.com. > To post to this group, send email to leo-editor@googlegroups.com. > Visit this group at http://groups.google.com/group/leo-editor. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
On Tue, Aug 19, 2014 at 8:16 PM, Brian Theado wrote: > A few years ago the page up/down functionality was a fixed number of > lines. I looked into the QT cpp code and translated it to python and > checked it in: > > https://github.com/leo-editor/leo-editor/commit/9401804f956c0eef31d2068450a21436e9939268 Whoops, that was an earlier commit which took a different approach. Here is the commit which implements the port of the QT code to python: https://github.com/leo-editor/leo-editor/commit/3f0dc96e7fe155692a06b08eb40be917a7f52e97 Here is a UNL to the code in question: leo-editor/leo/core/LeoPyRef.leo#Code-->Qt gui-->@file ../plugins/qtGui.py--> << define text widget classes >>--> << define LeoQTextEditWidget class >>-->leoMoveCursorHelper & helper (LeoQTextEditWidget)-->pageUpDown The code moves the cursor one line at a time until the total screen distance moved is greater than or equal to the height of the body. After that, it moves the scroll bar one page in the same direction the cursor was moved. So I'd be interested in hearing in what situation it breaks for you. > 2) Where did the c.frame.body.bodyCtrl.linesPerPage() function come > from? Did I just miss it when I made my change a few years ago? The pageUpDown implementation will work even if some lines have different height. Not sure that ever happens, but linesPerPage will not handle that case. Brian -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
A few years ago the page up/down functionality was a fixed number of lines. I looked into the QT cpp code and translated it to python and checked it in: https://github.com/leo-editor/leo-editor/commit/9401804f956c0eef31d2068450a21436e9939268 since then the page up/down has always been exactly a page for me. So my two questions are: 1) What behavior are you seeing? 2) Where did the c.frame.body.bodyCtrl.linesPerPage() function come from? Did I just miss it when I made my change a few years ago? Brian On Tue, Aug 19, 2014 at 5:52 AM, Fidel N wrote: > Tried to do myself, but cant fin any binding for pgup or pgdn in either > leosettings or leopyref. > Also, found out that this wont work if the user wants to select the whole > page (shift + script) wont select the whole page, just jump. > But its good enough for reading as is. > > > On Tue, Aug 19, 2014 at 10:48 AM, Edward K. Ream > wrote: >> >> On Tue, Aug 19, 2014 at 3:36 AM, Fidel N wrote: >> >> > for number in range(c.frame.body.bodyCtrl.linesPerPage()): >> > c.executeMinibufferCommand("next-line") >> >> Excellent. This should be the default binding of the PageDn key. >> >> Edward >> >> -- >> You received this message because you are subscribed to the Google Groups >> "leo-editor" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to leo-editor+unsubscr...@googlegroups.com. >> To post to this group, send email to leo-editor@googlegroups.com. >> Visit this group at http://groups.google.com/group/leo-editor. >> For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "leo-editor" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to leo-editor+unsubscr...@googlegroups.com. > To post to this group, send email to leo-editor@googlegroups.com. > Visit this group at http://groups.google.com/group/leo-editor. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
Tried to do myself, but cant fin any binding for pgup or pgdn in either leosettings or leopyref. Also, found out that this wont work if the user wants to select the whole page (shift + script) wont select the whole page, just jump. But its good enough for reading as is. On Tue, Aug 19, 2014 at 10:48 AM, Edward K. Ream wrote: > On Tue, Aug 19, 2014 at 3:36 AM, Fidel N wrote: > > > for number in range(c.frame.body.bodyCtrl.linesPerPage()): > > c.executeMinibufferCommand("next-line") > > Excellent. This should be the default binding of the PageDn key. > > Edward > > -- > You received this message because you are subscribed to the Google Groups > "leo-editor" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to leo-editor+unsubscr...@googlegroups.com. > To post to this group, send email to leo-editor@googlegroups.com. > Visit this group at http://groups.google.com/group/leo-editor. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
Re: [Simple script] Jump exactly one page with Page Down
On Tue, Aug 19, 2014 at 3:36 AM, Fidel N wrote: > for number in range(c.frame.body.bodyCtrl.linesPerPage()): > c.executeMinibufferCommand("next-line") Excellent. This should be the default binding of the PageDn key. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
[Simple script] Jump exactly one page with Page Down
Hi: For those of you reading a lot in Leo it might be uncomfortable to use Page Down/Up since it doesn't exactly jump one page, so you have to check where you were reading each time you use that. This script jumps exactly the number of lines in the text widget. So you can keep reading where you finished the previous page. Maybe this should be the default Page Up/Down, although I guess this is a preference or depends on your activity. Just make a button with this script: for number in range(c.frame.body.bodyCtrl.linesPerPage()): c.executeMinibufferCommand("next-line") -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.