Sublime Forum

Standalone SublimeText widget

#1

@jps Hi Jon, sorry to ping you once again directly. Hope this time you’ll be able to read and and answer it :wink:

Let me talk a little bit first about my case/concerns here. Nowadays all the apps I write use python+(pyqt/pyside2) for the frontends and c++/c/asm for the backends (only when strictly necessary in terms of performance), this combo is terrific and it allows to be extremely productive while still creating awesome beautiful desktop apps.

There is a little problem I’ve struggled with for very long time though and it has been the fact than many of my apps are still using the archaic Scintilla widget. Scintilla gives a reasonable ammount of useful text-editor features but it simply can’t compare with SublimeText at all (my favourite text editor of all times). Because of this fact, I’m always trying to replicate SublimeText features on Scintilla (unuscesfully).

After trying to replicate many ST features on Scintilla I’ve reached the conclusion that this approach is simply just wrong and very limiting. Duplicating ST features on a scintilla widget is hard because internal design of scintilla is quite different to Sublime: no scope based, tmLanguage/tmTheme unsupported, multiselections working badly in comparison to ST, undo/redo not behaving like ST and so on…

Here’s a little list of some attempts I’ve tried to replace Scintilla on my apps:

  • Using ace on a chromium qt widget… while ace provides a fair ammount of similar features than sublime there was a big problem, the rendering is slow as hell and embedding chromium on a desktop apps is a big overhead and a dependency i wouldn’t like to keep.

  • Few days ago I’ve tried to port an existing cool open-source c++ widget to vanilla python, pylime but I realize even if that project would be finished, the result wouldn’t be optimal and the widget would still miss a fair ammount of “must-to-have” features.

  • Wrapped edbee-lib directly to python but the widget wouldn’t have the same ammount of features than SublimeText.

  • Embedded SublimeText as a dock widget on my apps and communicated with it using interprocess comunication or rcp protocols… not ideal in many cases and definitely an overhead as I don’t need the whole Sublime editor embedded but just Sublime Views as standalone widgets :frowning: . Plus, many of my apps will create thousands of text editor widgets on demand and you don’t definitely want to embed thousands of ST process, do you? :confused:

Summing up, as you can see, none of my attempts were ideal at all so I was thinking… how difficult would be to create a SublimeText standalone pyqt/pyside editor? In my experience wrapping c++ code to pyqt(sip) or pyside2(shiboken) is relatively easy but I’m not sure how hard would be replacing internal skia renderer with qt’s rendering engine.

That said, just to clarify I don’t care about SublimeText source code at all but instead I would really love if some standalone text editor widget was available ready to use on qt for python. If that was just crazy difficult, being able to use sublime_api module as a python module or static library could be interesting.

Sorry for the long thread but this issue of providing a proper text editor to my apps that satisfies me is driving me nuts and it seems to be not trivial at all after so much researching… guess having as a minimum standard of quality SublimeText itself isn’t making it easy to achieve :wink:

As I already mentioned it once… but I think if there was available some sort of Standalone SublimeText editor library to embed directly in pyside2 or qt in a similar way than Scintilla I wouldn’t be the only one willing to pay money to include it on my apps, of course, if the ammount was reasonable. Unfortunately, there isn’t many offers out there about high-quality standalone text editor widgets like Sublime’s…:confused:

Ideas? Thoughts? Alternatives solutions?

Please let me know about it so if this is not possible I’ll continue exploring another options… who’d tell creating an state-of-the-art text editor would be so complex :confused:

Apologies for the long thread btw.

Yours,
Bruno

2 Likes

How to bring back Sublime Text
#2

Since the time I’ve opened this thread I’ve tried to be as proactive as possible in order to find some alternatives myself to the problem, it’s become clear to me I can’t expect than SublimeHQ will become interested any time soon (or ever) to provide an standalone widget ready to be used as that would probably give them little money as the niche is too small. So I need to get the job done myself, even if that’s the most unoptimal solution :frowning:

Here’s the thing, so far I’ve learned the very basics of rust and then I’ve decided to port syntect to python, once the wrapper got quite in shape I’ve created a very basic standalone pyqt widget using that library to help with the syntax highlight, here’s a little demo:

Thing is, right now there are a identified lot of things to implement as well as a bunch of features I consider a must in order to have a basic Standalone text editor widget that remains as closely as possible to our dear Sublime.

I’m posting this here in case some coders that love Sublime as much as me would like to share the workload with me so we make something usable out of this little experiment. In case there would be enough people interested on the idea I would upload it to github… but that’s just in case there were people interested to code stuff and get the job done as I don’t want to waste time uploading something where people will post what needs to be done, bug reports, docs or other type of stuff I won’t probably be dealing with :slight_smile:

Requirements:

  • Deep knowledge of python
  • pyqt/pyside/qt would be really helpfull
  • People that want to have a python open-source embedabble text editor that remains as closely as possible to Sublime’s in terms of features and quality

Peace!

0 Likes

#3

I’m interested in helping out!

1 Like

#5

https://github.com/brupelo/pyblime

0 Likes

#6

In case anyone wanted to give it a shot… today I’ve tried to add support to this thing on linux… it requires python3.6.

Could you make me a little favour a let me know if the project runs on your linux distros?

Here’s the build instructions

Thanks in advance!

0 Likes

#7

I cloned, setup the env, installed requirement and copied your test_simple to the main folder so it could see the folder structure properly. This is what I get on Antergos linux (Arch base).
> python test_simple.py
QApplication: invalid style override passed, ignoring it.
Available styles: Windows, Fusion
Traceback (most recent call last):
File “test_simple.py”, line 11, in
view = View(data_path / “st_build_3149/syntax”)
File “/home/mond/dev/pyblime/pyblime/view.py”, line 97, in init
self.load_syntax_set(syntax_path)
File “/home/mond/dev/pyblime/pyblime/view.py”, line 447, in load_syntax_set
builder.add_from_folder(str(syntax_path), False)
Exception: SyntaxSetBuilder.add_from_folder

0 Likes

#8

fwiw it works okay for me on Ubuntu 18.04. Maybe the data path is wrong because you copied the example to the main folder?

0 Likes

#9

First of all, thanks to give it a shot… right now I’m trying to make easier the installation process… but summing up, it’s exactly what @kingkeith just said, look at test_simple.py, it uses:

data_path = Path(__file__).parent / "../data" 

So probably data_path will point to the wrong place… actually, now I think of, maybe the data path should work no matter where the tests live… i thought this way would be easier for you guys to understand how to use different syntaxes, themes, etc…

Ps. I’ll fix the all the tests to give proper advice without crashing if you didn’t use a valid path

0 Likes

#10

I’ve upgraded the repo to make it more friendly for begginers… right now should be easier both to install & test, does it work now for you? Theorically you should be able to create your tests more easily so you don’t need to have your custom data folder.

Hope it helps!

0 Likes

#11

I’m not sure I understand the goal of this project (even though it sounds interesting)
So you have a PyQt app, and you want the user to be able to read/edit some text file,
so you decided to implement a Qt compatible text widget that looks like Sublime ?

Do you want to have full editing capability and plugin support or just displaying the file with ST syntaxes / theming would be enough ?
Why can’t your app open the file in Sublime Text or another editor (with eg subl -wn )?

1 Like

#12

Ok, guess I didn’t talk too much about it in the docs provided here cos I considered it to be totally irrelevant for potential contributors that like the idea.

But it’s a good question, basically the main reason why I’ve decided to create this project is mainly because I’ve got some in-house python custom 3d tools similar to this where I’d like to replace some of the existing widgets used for text editing by pyblime eventually.

Thing is, with these 3d tooI I use text editing for a variety of different tasks so I’d like eventually feel like I’m coding in SublimeText to be as productive as possible.

At first I wasn’t even consider to open the project but then I thought probably there are many guys who like writing these type of tools and that they would also need having the same type of Sublime widget ready to drop in their projects, so yeah… pyblime born… :slight_smile:

Do you want to have full editing capability and plugin support or just displaying the file with ST syntaxes / theming would be enough ?

I’ve tried to solve these type of questions in some of the existing doc but the fact you’ve asked specially this one is nice, cos it means probably the landing page doesn’t transmit properly what could be the benefits for people to get involved in the project…

Also, if you’ve got ideas, critics, suggestions… please don’t doubt to open issues about it… have to have some patience with me as I’m a total amateur in the open-source world and probably I’ll be doing some funny things here and there, I’m learning as I go :wink:

Thanks for your feedback! It really helps :slight_smile:

Ps: when i say “there are many guys who like writing these type of tools” … I don’t specifically mean 3d tools, try to think out of the box here… basically I mean using it in all sort of pyqt/pyside2 python apps that need text editing would benefit from using this promising Sublime widget

0 Likes

#13

I’m sure this new feature I’m working on eventually will be quite useful, you can take a look at here, the idea is eventually you’ll be able to use SublimeText TextCommand plugins on the widget… in any case, it’s still WIP so don’t expect it to be fully correct :wink:

0 Likes

#14

For those who may be interested on this widget… the pyblime project is already living in PyPi, you just need to:

  • git clone https://github.com/brupelo/pyblime
  • pip install pyblime

Have fun!

0 Likes

#15

Version 0.0.2 released!!! Lots of cool stuff… give it a try :wink:

0 Likes