-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plugin: pycalc #9017
base: master
Are you sure you want to change the base?
Add plugin: pycalc #9017
Conversation
Hi! I initially thought "yeah" but then "why not just open a repl or ipython in Terminus like I do right now". Generally your approach to the problem is kind of obtrusive, e.g. you grab the Besides, why do you want a public plugin but hide yourself? Who are you when the commit email you used is |
Hello @kaste When you close the repl or console you will lose the code and data (or have to copy and clean from >>>) In my solution the code and data are stored in a simple text file, it borrows the philosophy of jupyter notebook simplifying it as much as possible and makes it accessible to any editor that supports plugins (I'm working on it, see https://github.com/pycalc-plugin) It seems intrusive, but you can always disable the plugin from the context menu, the user decides whether to use it or not. publishing email = spam, you can always write to me in github issues. Best regards, |
Well, you bind You should also implement |
Indeed it really isn't. I can see at least 2 alternatives:
Additionally:
|
I don't know another way to catch the enter key press, if you know another way, please tell me.
What do you mean, how to do it?
I don't touch the global interpreter, I create a local InteractiveConsole and using the redirect_stdout, redirect_stderr functions I get the result for output to sublime.
I can add an item to the command palette that will hide context menu items at the user's request.
Done
I have removed items that are not related to my plugin, if necessary I can return them.
I have looked through and installed these plugins but have not found one that is as convenient and powerful. p.s. To help you understand my logic, I'll add a screencast of the user experience with the plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated testing result: WARNING
Repo link: pycalc
Results help
Packages added:
- pycalc
Processing package "pycalc"
- WARNING: The binding ['enter'] is also defined in default bindings but is masked with a 'context'
- File: Default.sublime-keymap
The problem is that you're catching all key presses everywhere (except widgets). You want to try and only listen to keypresses in your specific "repl-like" views. You could try to ensure such a view has a specific syntax, and use that as a context for the keybinding. You could then also use that syntax to differentiate input and output. Also note that views have a settings interface you can manipulate.
Yes please, I can't tell which one's you skipped if they're not there. Maybe they're not applicable, but let me worry about that 😉
The way you're doing might not work. Your package directory is not writable as your package is delivered in a zipped format. If you manage where your event listener is active, you don't need an on/off toggle. That leaves you with one command in the context menu. It would be cleaner if you introduce a setting that toggles the that entry via an |
If it is a skill issue then the Discord channel might be interesting for you. http://discord.sublimetext.io/ https://discord.com/channels/280102180189634562/280157067396775936 One approach is to have a key binding with a context like this:
Then you just need a way to toggle this setting on and off. E.g. you create a window command and create a new view and set it. That looks like:
Refer the API documentation https://www.sublimetext.com/docs/api_reference.html#sublime.Window.new_file Add this command to the Command Palette, and you probably don't need any context menu handlers or settings. (At least for the proof-of-concept.) The trickier part may be:
The shared resources are stdout and stderr. IIRC you can implement Very likely the module is well documented and you can find tutorials for this as well. |
A very similar plugin is btw https://github.com/ichichikin/sublime-plugin-interactivity |
My package is pycalc https://github.com/pycalc-plugin/sublime
There are no packages like it in Package Control.