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.
StaSh updated for 1.6 beta with ObjC functions
-
I'd add the built in extended keyboard
-
i don't think we have an easy way of forcing the built in kb to show, or target the textview. well, we might be able to find it, traversing through the UIApplication.... hmmmm
-
I found OMKeyboardAccessoryView ...
Tried to implement it but the result for me is the view without buttons
import ui from objc_util import * v = ui.load_view() editor_view=ObjCInstance( v['textview1']) OMKeyboardAccessoryView = ObjCClass('OMKeyboardAccessoryView') accessory_view = OMKeyboardAccessoryView.alloc().initWithType_dark_('python', False).autorelease() editor_view.setInputAccessoryView_(accessory_view) v.present('sheet')
The pyui file is just a view with a textview inside it
-
@filippocld I did think about using the builtin accessory keyboard and studied the example that @omz provided. However it turned out to be rather inadequate for following reasons:
-
Unlike a text editor, a Terminal does not allow users to freely type any texts in any locations. It has strict control on where you can type texts. For the accessory keyboard, this means I need to register my own callbacks for the button actions and swipes. This may be possible but may not be trivial, especially when there is no documentation about its internals.
-
The builtin accessory keyboard does not provide Control keys (e.g. Ctrl-C, Ctrl-D) or any utility buttons like history navigation.
-
Some of the utility buttons should be context aware. For an example, behaviour of the Tab button depends on whether a script is running. This again requires a custom callback for the buttons.
With above being said, the extra keyboard really could use some improvements. A possible way is to create my own
inputAccessoryView
for better look and encapsulate the functions. -
-
Awesome! The
site-packages
installation will really make integration a lot easier for scripts like the Pythonista Tools client that rely on StaSh. The previous integration method was pretty hack-ish. Nice work! -
I am sorry to report that external bluetooth keyboard support is no longer working as it did in the prior version. History via Cmd up and down arrows is no longer functioning for me now. Output scrolling is kinda jerky and looks like some kind of buffering is going on that causes it to stop and start.
I have not seen any other issues and it looks to be functioning well running from site_packages. I made sure to delete my old stash folder in Documents and remove and re-add stash_launcher to my tools menu.
-
@wradcliffe Thanks a lot for the feedbacks!
-
The cmd + up/down history navigation is removed from the new version. I replaced them with Ctrl + p/n. But it does make sense to have arrow keys involved for browsing history. So I have just added support for using only the up/down arrow keys (no need to press Cmd, just the arrow key itself). I hope this would work better for you.
-
As for the jerky scrolling, what device do you have? How frequent did it happen? Did it happen when you type
ll
orcat
a large file or all the time? I had a few optimisations pushed since the original post. So it may also be worthwhile to try the latest version by type and runselfupdate.py beta16
from within the shell (you may need restart the whole Pythonista app afterwards).
Please let me know how it works for you. Thanks!
-
-
@Gerzer Glad to hear you like the changes! I wasn't sure about the
site-packages
change but now it seems to make more sense. -
@ywangd - Thanks for adding the simpler up arrow for history. Makes a lot of sense and has the nice benefit of preventing the user from moving the cursor off the input line.
With further testing, I don't see any real problem with scroll speed and smoothness. Testing using cat on a large file works fine and the speed is dictated by screen rendering time as you would expect. The jerkiness I noticed was for file system traversal. Seems slower then what I remember but it is hard to imagine how stash could be effecting that.
As usual, your releases are superb. Thanks for all the hard work on this.
One more question. How can users contribute scripts for potential inclusion into stash? I have one that I use often that can "sanatize" one or more text files that may contain odd character encodings. It is used for cases where a text file won't open properly in the editor. Here is the script ...
# coding: utf-8 """Sanitize one or more files to pure ascii and MAC EOL chars""" from __future__ import print_function import argparse import fileinput import os import sys import codecs def sanitize_file(fn_in, fn_out): with codecs.open(fn_in, 'rt', encoding='ascii', errors='ignore') as in_file: text = '\n'.join(line.rstrip() for line in in_file.readlines()) + '\n' with open(fn_out, 'wt') as out_file: out_file.writelines(text) def main(args): ap = argparse.ArgumentParser() ap.add_argument('files', nargs='*', help='files to be searched') ns = ap.parse_args(args) # Do not try to sanitize directories files = [f for f in ns.files if not os.path.isdir(f)] fileinput.close() # in case it is not closed try: for line in fileinput.input(files): line=line.rstrip() if os.path.exists(line): if fileinput.isstdin(): fmt = '{lineno}: {line}' else: fmt = '{filename}: {lineno}: {line}' print(fmt.format(filename=fileinput.filename(), lineno=fileinput.filelineno(), line=line)) sanitize_file(line, line) except Exception as err: print("sanitize: {}: {!s}".format(type(err).__name__, err), file=sys.stderr) finally: fileinput.close() if __name__ == "__main__": main(sys.argv[1:])
-
@wradcliffe You can make a pull request to the repo for your changes:
- Fork the repo first
- navigate your browser to the repo and click Fork at the top-right corner.
- Make changes against the forked repo
- You can make any changes since forked repo is owned by you
- Create a pull request back to the original repo once you are done with the changes
- The pull request is created by clicking the green button on the forked repo's main page.
- Please create the pull against the
dev
branch of the original repo. Thedev
branch will be merged intomaster
when things are stable.
Thanks again for the feedback. This is what I could really use to make StaSh progress.
- Fork the repo first
-
Ran launch_stash.py and it crashes (returns to home screen) after 7 seconds.
-
@ihf
I cannot reproduce it. What device do you have? Are you on the latest beta (160033)? Could you please try a fresh install:- First delete any existing stash folders and launch scripts, including the new one and any old ones (v0.4.x).
- Run
import urllib2; exec urllib2.urlopen('http://bit.ly/gsb16').read()
to install - Unload Pythonista app completely and relaunch to ensure a fresh state
- Make sure you are not loading any custom resource files, e.g.
.stashrc
. - Now run
~/Documents/launch_stash.py
Please let me know if above steps work for you.
-
I will just report I have the latest version of stash, and the latest beta, and launch_stash.py works.
IPad Air 2 , 128gb , wifi + cell, iOS 8.4.1 -
@Phuket2 Good to know it works for you. Thanks a lot for the feedback.
-
@ywangd , no problems. However there is always a but :) on the previous version I tried to find where to change the font and size used. It was described clearly, but I could not find the file that was referred to. When you have time, could you please point me in the right direction to change the font and size. My eyes are bad, so I need a bigger size
-
@Phuket2
You can configure the text size, but the font can no longer be changed in the new version (at least not recommended).- If you prefer to modify the source file, you can do it by change the value on Line 103 of
stash.py
. Default size is 14 for iPad and 12 for iPhone. - Alternatively, I'd recommend creating a
.stash_config
file under the stash installation root (i.e.~/Documents/site-packages/stash/
). Any settings in this file override the same settings in the source file. For an example, to increase the text size:[display] TEXT_FONT_SIZE=20
The text font can no longer be configured because not every font has all of the bold, italic and bold-italic variants. If stash tries to display a non-existing font variant, it crashes the entire Pythonista app.
- If you prefer to modify the source file, you can do it by change the value on Line 103 of
-
@ywangd, thanks I did it in your code. I know it seems simple, but I tried the config file and failed big time. But did you mean literally '.stash_config' or 'stash_config.txt' or ...... Sorry, I was not sure
-
@ywangd I followed your instructions and the problem persists. I am running v1.6 (160033) on an iPad 3.
-
@Phuket2 I mean literally
.stash_config
. It can be tricky to create this file just using Pythonista editor because it does not like files without extension. You can create as a regular python file, saystash_config.py
in~/Documents
. Then from inside stash, rename it by runningmv stash_config.py site-packages/stash/.stash_config
. -
@ihf I am not sure if it has anything to do with 32bit vs 64 bit devices. As I remember, iPad3 is 32 bit. Unfortunately I don't have a 32bit device around to do any tests. I'll try add some debug loggings so the launching process can be recorded into a file. I'll let you know once it is ready. Sorry for the inconvenience.