Open tnmeesters opened 4 weeks ago
It is theoretically possible, but requires a thorough rewrite of the Enso's scriptotron engine. It was written so that all evaluated symbols of all scripts are cleared before loading update from script files. Unfortunately, this is a task no of the foreseeable future.
Ok, thanks. I do notice that the Enso editor does update and quite faster. Is there a way to update it like that. Having a script in ...\Enso.enso\commands\ like 'user' and update it with a command.
By default, changes in command files are tracked only in the editor commands. It is possible to track all files by enabling
TRACK_COMMAND_CHANGES = True
in config.py or the configuration editor.
Unfortunately, currently it is impossible to speed up anything because all python symbols used in commands should be recreated.
Thank you, I will try this.
I'm running into a problem with updating the commands. I saw in the tutorial that using 'on_quasimode_start()' could solve this problem. But I don't know how to do that. I have the following example:
import os import json
def displayMessage(msg): import enso.messages enso.messages.displayMessage("
%s
" % msg)clipboard = [] clipboard = json.load(open("files/clipboard.txt")) validarguments = list(map(lambda x : x['name'], clipboard))
def cmd_add_clipboard(ensoapi, name): """ Add clip to clipboard """ seldict = ensoapi.get_selection()
if seldict.get('text'):
text = seldict['text'].strip()
clipboard.append({"name": name,"clip": text})
json.dump(clipboard, open("files/clipboard.txt",'w'), indent=2)
displayMessage("Creating new clip in clipboard...")
else:
displayMessage("Nothing was file selected")
def cmd_clipboard(ensoapi, subject): """ Paste from clipboard """
indexposition = next((index for (index, d) in enumerate(clipboard) if d["name"] == subject), None)
clip = clipboard[indexposition]['clip']
displayMessage(clip)
#ensoapi.set_selection(paste)
cmd_clipboard.valid_args = validarguments
[ { "name": "mail", "clip": "test@gmail.com" }, { "name": "phone", "clip": "1245" } ]
How should I use on_quasimode_start()?
Thanks,
Thomas
Hi,
It is possible in the same way as with the valid_args:
def cmd_test(ensoapi):
ensoapi.display_message("test")
def my_func():
displayMessage("<p>test2</p>")
cmd_test.on_quasimode_start = my_func
Hello,
Sorry, I'm not able to get it to work with the .valid_args to be dynamic. I am able to load a list at starting quasimode but I don not know how to use for the input arguments.
import os
import json
def displayMessage(msg):
import enso.messages
enso.messages.displayMessage("%s " % msg)
def load_clips():
clipboard = []
clipboard = json.load(open(r"C:\Enso\files\clipboard.txt"))
validarguments = list(map(lambda x : x['name'], clipboard))
displayMessage(validarguments)
return validarguments
def cmd_non(ensoapi, subject):
ensoapi.display_message("test")
cmd_non.on_quasimode_start = load_clips
#cmd_non.valid_args = load_clips
[ { "name": "mail", "clip": "test@gmail.com" }, { "name": "phone", "clip": "1245" } ]
Thanks,
Thomas
import os
import json
def displayMessage(msg):
import enso.messages
enso.messages.displayMessage("%s " % msg)
def load_clips():
clipboard = []
clipboard = json.load(open(r"C:\Enso\files\clipboard.txt")))
validarguments = list(map(lambda x : x['name'], clipboard))
displayMessage(validarguments)
cmd_non.valid_args = validarguments
return validarguments
def cmd_non(ensoapi, subject):
ensoapi.display_message("test")
cmd_non.on_quasimode_start = load_clips
cmd_non.valid_args = load_clips()
I have everything working. I was able to improve a lot of scripts thanks to this.
Thank you for everything.
Is it possible to refresh a specific script instead of every script in the commands folder? Refreshing has become slow with to many scripts.
Thanks,
Thomas