Skip to content

Commit

Permalink
Patch stash to run with Pythonista 3.4 beta
Browse files Browse the repository at this point in the history
`launch_stash.py` will work. But an ignore exception `No method found
for selector "setAutomaticallyAdjustsContentInsetForKeyboard:"` is
raised.

pip seams to fail to download files.
  • Loading branch information
mkb79 committed Jan 18, 2023
1 parent b722d71 commit cb96166
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions system/shcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
if IN_PYTHONISTA:
import plistlib

_properties = plistlib.readPlist(os.path.join(os.path.dirname(sys.executable), 'Info.plist'))
PYTHONISTA_VERSION = _properties['CFBundleShortVersionString']
PYTHONISTA_VERSION_LONG = _properties['CFBundleVersion']
info_plist_path = os.path.join(os.path.dirname(sys.executable), 'Info.plist')
if hasattr(plistlib, 'readPlist'):
_properties = plistlib.readPlist(info_plist_path)
elif hasattr(plistlib, 'load'):
with open(info_plist_path, 'rb') as info_plist:
_properties = plistlib.load(info_plist)
else:
raise Exception('`plistlib` does not support reading a plist file.')

if PYTHONISTA_VERSION < '3.0':
python_capi = ctypes.pythonapi
Expand Down
8 changes: 4 additions & 4 deletions system/shui/pythonista_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,14 @@ def _vk_tapped(self, sender):
# noinspection PyAttributeOutsideInit,PyUnusedLocal,PyPep8Naming
class ShTerminal(ShBaseTerminal):
"""
This is a wrapper class of the actual TextView that subclass the SUITextView.
This is a wrapper class of the actual TextView that subclass the UITextView.
The wrapper is used to encapsulate the objc calls so that it behaves more like
a regular ui.TextView.
"""

def __init__(self, stash, parent, superview, width, height):

# Create the actual TextView by subclass SUITextView
# Create the actual TextView by subclass UITextView
UIKeyCommand = ObjCClass('UIKeyCommand')

def kcDispatcher_(_self, _cmd, _sender):
Expand Down Expand Up @@ -490,7 +490,7 @@ def keyCommands(_self, _cmd):
('UIKeyInputRightArrow', 0): parent.arrowRightAction,
}

_ShTerminal = create_objc_class('_ShTerminal', ObjCClass('SUITextView'), [keyCommands, kcDispatcher_])
_ShTerminal = create_objc_class('_ShTerminal', ObjCClass('UITextView'), [keyCommands, kcDispatcher_])

self.is_editing = False

Expand Down Expand Up @@ -894,7 +894,7 @@ def render(self, no_wait=False):
self.render_thread.cancel()
self._render()
else: # delayed rendering
if self.render_thread is None or not self.render_thread.isAlive():
if self.render_thread is None or not self.render_thread.is_alive():
self.render_thread = sh_delay(self._render, self.RENDER_INTERVAL)
# Do nothing if there is already a delayed rendering thread waiting

Expand Down

1 comment on commit cb96166

@jsbain
Copy link
Contributor

@jsbain jsbain commented on cb96166 Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s actually SUITextView_PY3. That fixes the ignored exception

Please sign in to comment.