Code Monkey home page Code Monkey logo

Comments (3)

dgelessus avatar dgelessus commented on August 23, 2024
  1. I don't know anything about Objective-C, Swift or iOS app development, if this involves more than getting/setting the history property (?) then I may be the wrong person for the job :)
  2. I'm quite certain that interactive Python input does not go through normal stdin in any way, so I'm not sure what a stdin hook would be. (And would it be necessary if the history list is accessible via objc_util?) Of course "commands" can be implemented by saying builtins.save_history = object() and making the displayhook react specially to that, but then you might as well make it a normal function.
  3. Last I checked Pythonista wouldn't run atexits, I'll need to check that though. (Edit: still doesn't, tested with atexit.register(lambda: open(os.path.expanduser("~/Documents/atexit_test.txt"), "wb").close()).)

from pythonista_startup.

jsbain avatar jsbain commented on August 23, 2024

I thought in a recent beta that atexit was supported, though I don't think it runs when killed by the os for memory reasons, or when crashing, so maybe has little value.

I thought you had done some work monkey patching the _stdoutcatcher, but maybe my memory is fuzzy. My thinking would be to log to a file each console command as it is run, then restore in startup. I am not sure if there is another "standard" method to hook into console commands? I guess, for example, whenever you append to Out, we could store the new history commands....
Okay, I guess I know where to look now.

from pythonista_startup.

dgelessus avatar dgelessus commented on August 23, 2024

Ah, atexit hooks run when you do sys.exit(), not when the app exits.

What I did "back then" was related to the autocompletion in the interactive console. Before Pythonista 2 the completion list was built by injecting a bit of Python code that printed the completions to stdout, which was then captured by Pythonista and shown in the completion list. I managed to patch that so it would show a custom suggestion at the top of the list every time, but there was no way to get the full text of the partial line typed at that point (and no way to tell whether stdout was currently in "normal" or "autocomplete list" mode, so any patching may also have affected normal output).

from pythonista_startup.

Related Issues (1)

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.