Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Tabbed File Editing
-
I haven't dug into the script, but is there a simple way for the tabs to remember where the "cursor" was the last time its file was "on top". Would make jumping between files to compare sections very useful.
-
I'm fairly certain thath there are methods like
get_selection
andset_selection
in theeditor
module, those should be easy to integrate. -
get/set_selection() would be good. How would you easily force the displayed screen to put the selection mid screen. Setting the selection does not "scroll" the window.
-
See the
force_scroll
method hereThe key line is the last.... If you call replace_text, the editor will scroll. Calling setting the start and end offset the same, and using an empty string ensures you don't actually change anything, but the editor scrolls just the same. The part that is hard to control is where the offset ends up on the screen. I believe there is a way by scrolling twice to have a little more control, (I.e overshooting, then backing up, as it does depend on the direction you are moving)... But this code just tries to keep a little context on screen.
By the way, not sure if smath ever publicized it, but this repo is an integration with his awesome Tabs with [editmenu] (https://github.com/jsbain/editmenu) one button block comment/uncomment, block indenting, cut,copy,paste, and execute the selected block in current interpreter session). Smath also added find and replace functionality, which makes this a sweet little package.
-
By the way, I had considered this in the past.... While it would be easy to save/resume the position when switching from the tab itself, we don't have any way to trigger an action when opening a file from the usual pythonista browser.. I guess the main use case would be switching back and forth between two files, so maybe that's ok. An alternative would be to poll the editor's file name and line number periodically, and update the database. I'm not sure if the editor sidebar and main ui run in different threads, if not there would be some risk of freezing.
-
editmenu with Tabs has now been updated to include saving of last selection/cursor location, and restoring it when switching tabs!
Also, I converted Tabs over to a class to fix problems with namespace collisions in some cases.
Also, the previous editmenu/Tabs mashup didn't keep the tabs database in a fixed location, resulting in lost tabs when running from action menu.
Now it does.As an aside, I switched over from sqllite3 to shelve, because well it is easier for me to understand! This makes future enhancements easier, also, otherwise there has to be a lot of logic to add new columns, etc.
-
Where should this get installed. I getting a lot of file not found errors for the components (pyui and py files)
-
You should download all files into one folder, but the specific location shouldn't matter... Mine sits in an editmenu folder off of the ~/Documents folder. Use GitHubGet, gitview, or your favorite git manager to download. You should run editmenu.py first, that's probably the most tested, everything else is accessible from the buttons
-
JonB - I just downloaded the current version from github and am getting an error:
Traceback (most recent call last): File "./Tabs.py", line 78, in move self.sv.subviews[i].y -= self.tab_width*1.05 NameError: global name 'tab_width' is not defined
I've even changed the reference to self.tab_width to be self.width, and get the exact same error.
Any ideas?
-
Whoops, my bad. Apparently when I tested this, I had the global tab_width still in the namespace, so the code appeared to work. I just checked in an update...
Actually, I'm a little confused by the traceback, since it implies tab width was a global, instead of an attribute of self (the fix I checked in added a self to that line where there was none before)
I checked with a fresh pull, so try again?