GChristensen / enso-portable

Portable Enso Launcher community edition
Other
164 stars 46 forks source link

refresh specific script #36

Open tnmeesters opened 4 weeks ago

tnmeesters commented 4 weeks ago

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

GChristensen commented 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.

tnmeesters commented 3 weeks ago

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.

GChristensen commented 3 weeks ago

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.

tnmeesters commented 3 weeks ago

Thank you, I will try this.

tnmeesters commented 2 weeks ago

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")

on_quasimode_start()

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

With the following in the json file

[ { "name": "mail", "clip": "test@gmail.com" }, { "name": "phone", "clip": "1245" } ]

How should I use on_quasimode_start()?

Thanks,

Thomas

GChristensen commented 2 weeks ago

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
tnmeesters commented 2 weeks ago

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

With the following in the json file

[ { "name": "mail", "clip": "test@gmail.com" }, { "name": "phone", "clip": "1245" } ]

Thanks,

Thomas

GChristensen commented 2 weeks ago
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()
tnmeesters commented 5 days ago

I have everything working. I was able to improve a lot of scripts thanks to this.

Thank you for everything.