Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Questions about editor
-
Thanks, i thought wrong, but as if replace_text dont work yet.
-
I am lost...
import editor editor.make_new_file('tmp', 'test') # quotes around tmp editor.set_selection(0, 4) # 4 instead of 5 editor.replace_text(0, 4, 'good') # 4 instead of 5
...works as expected in the current v1.6 beta.
-
why set selection before replace? im pretty sure replace resets the selection?
-
Try taking it out and see... I was surprised myself.
-
Sorry,i dont use 1.6 beta,please ignore below:
#Comment/Uncomment selected lines import editor text = editor.get_text() selection = editor.get_line_selection() selected_text = text[selection[0]:selection[1]] is_comment = selected_text.strip().startswith('#') replacement = '' for line in selected_text.splitlines(): if is_comment: if line.strip().startswith('#'): replacement += line[line.find('#') + 1:] + '\n' else: replacement += line + '\n' else: replacement += '#' + line + '\n' #import editor editor.make_new_file('tmp', 'test') # quotes around tmp #editor.set_selection(0, 4) # 4 instead of 5 editor.replace_text(0, 4, 'good') # 4 instead of 5 editor.replace_text(selection[0], selection[1], replacement) editor.set_selection(selection[0], selection[0] + len(replacement) - 1)
-
ccc, you just have to give the editor a moment to create and open the file before writing to it. for large files, it was a good idea to call get_path until the proper path was returned, but for this example a small sleep works, or even the set selection, etc.
import editor,time editor.make_new_file('tmp', 'test') time.sleep(0.5) editor.replace_text(0, 4, 'good')
obelisk...not sure what you are trying to do! are you still having trouble?
-
Many thanks. Could u give an example to make other language syntax highlight in editor and no need to run?
-
Create a new file called junk.html in the Editor (the .html is important) and paste in this content:
<magenta="red">black</magenta> <style type="text/css">/* grey */</style>
The text magenta, red, black, and grey will be in those colors (depending on which theme you have selected).
-
syntax highlighting of html is a feature of the beta,not 1.5
-
Thanks very much,what to do next?use default theme or blackboard theme?