Code Monkey home page Code Monkey logo

Comments (2)

cclauss avatar cclauss commented on August 28, 2024 1

Please add Pythonista 3.4 beta to the issue title above.

from pythonista-issues.

watosar avatar watosar commented on August 28, 2024

For those who suffer from the same bug and can't wait for the update. I have written a script to alleviate the symptoms of this bug and will share it with you.

  1. add https://github.com/jsbain/objc_hacks/blob/master/swizzle.py to site-packages
  2. add the following code to site-packages/pythonista_startup.py
from objc_util import *
import swizzling
import editor

win = UIApplication.sharedApplication().keyWindow()
root_vc = win.rootViewController()
console_vc = root_vc.accessoryViewController().consoleViewController()

def consoleAdjustInsetsForKeyboardFrameChangeNotification_(_self, _cmd, ptr,*, ObjCInstance=ObjCInstance, UIEdgeInsets=UIEdgeInsets):
    obj=ObjCInstance(_self)
    arg = ObjCInstance(ptr)
    
    keyheight = arg.userInfo()['UIKeyboardFrameEndUserInfoKey'].rectValue().size.height
    keyboardon = keyheight>0
    obj.consoleOutputTextView().setContentInset_(
        UIEdgeInsets(0,0,(keyheight+32)*keyboardon,0))
        
def adjustInsetsForKeyboardFrameChangeNotification_(_self, _cmd, ptr,*,ObjCInstance=ObjCInstance, UIEdgeInsets=UIEdgeInsets, ObjCClass=ObjCClass): 
    obj=ObjCInstance(_self)
    arg = ObjCInstance(ptr)
    
    obj.originaladjustInsetsForKeyboardFrameChangeNotification_(arg) 
    if obj.delegate().isKindOfClass_(ObjCClass('PA2ConsoleViewController')):
        return 
    
    keyheight = arg.userInfo()['UIKeyboardFrameEndUserInfoKey'].rectValue().size.height
    keyboardon = keyheight>0
    obj.textView().setContentInset_(
        UIEdgeInsets(0,0,(keyheight+32)*keyboardon,0))

swizzling.swizzle(
    ObjCInstance(ObjCClass('PA2ConsoleViewController').ptr), 
    'adjustInsetsForKeyboardFrameChangeNotification:', 
    consoleAdjustInsetsForKeyboardFrameChangeNotification_)
swizzling.swizzle(
    ObjCInstance(ObjCClass('OMTextEditorView').ptr),
    'adjustInsetsForKeyboardFrameChangeNotification:',
    adjustInsetsForKeyboardFrameChangeNotification_)

from pythonista-issues.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.