607 points · by rxi · 6y ago · 256 comments
SDL seems to offer font hinting which would somewhat solve the immediate problem, but I'm not sure it's being used properly here. With that said, text rendering is optimized for the current device's DPI, so maybe I'm just reading too much into a screenshot taken at a different DPI.
[1] https://user-images.githubusercontent.com/3920290/81471642-6...
But system uses ClearType - compare rendering in window caption (rendered by Windows) and the text inside client area.
Gray-scale may work on high-DPI monitors, but on typical monitors it will be blurry.
But Apple and Microsoft still use ClearType even on high-dpi monitors.
For that matter, Sublime Text, that uses similar architecture (but Python instead of Lua), uses ClearType.
[1] https://arstechnica.com/features/2018/09/macos-10-14-mojave-...
i am still using a non-retina monitor for all of my day-to-day work. when i first installed mojave, it made my display look so bad that it gave me headaches. so i wiped my mac entirely and re-installed the previous version of macos. later, i learned that subpixel anti-aliasing is still there, it just takes some fiddling to get it back.
https://www.howtogeek.com/358596/how-to-fix-blurry-fonts-on-...
eventually, i will have to get with the program and buy a retina display. but i am thankful for this loophole that allowed me to put it off for awhile.
This isn't true.
edit: though it uses Scintilla for the "engine" and I would assume its LOC count is not counted towards this limit.
For now, lite also lacks "open folder", but it shows tree view of current directory atleast
From textadepts FAQ:
Q: Why can’t Textadept handle HUGE files very well?
A: Textadept is an editor for programmers. It is unlikely a programmer would be editing a gigantic log file. There are other tools for that case.
But what it still doesn’t replace is my favorite editor EmEditor [0] (Windows only). Like every alternative I’ve checked out, Lite blocks for a long time when opening a multi-gb file. They aren’t FOSS and probably more expensive than any other text editor, but I’d love to know what they do to have such superior large file performance (the free version is fast, the paid version even supports streaming-loading of parts of the file).
Also the immediate UI library from the same author is very good and the examples are amazing.
To me this is simply mind-blowing.
(They weren't big files, of course, but still. Standards have slipped.)
While subjective criteria are perhaps most important (usability, integration with favorite programming language, extensibility), for technical quality perhaps there can be some meaningful numerical benchmarks. For example, the lag and memory use when opening a many-GB text file and editing the middle of it with syntax highlighting.
Supposedly editors using ropes are good at this.
That said looking at the author's main.c this looks really nice as a shell for anyone looking to create a tool with lua scripting. Im going to download and study this one!
I.e. side-panel is too large, find+replace menu is modal and confusing.
Different approaches to extensibility can exist, all of them good in certain areas. Both Emacs and VS Code are extensible; which approach is better? You'll find different opinions.
You'll need, as a minimum, to specify a language to move "integration with favorite programming language" towards objectivity.
Kate is a surprisingly good/fast editor nowadays.
I'm not expecting it to have any of the features I'm used to with VS Code or JetBrains products, but it's definitely going to replace notepad.exe for a fast look at any text file.
Supports `lite <path>` to open any file/folder, e.g. `lite .` opens up the current folder in a tree view with beautiful dark mode by default, single click on each file loads it instantly. Seeing beautiful, matte-style syntax highlighting for all popular formats I've tried: .html, .css, .js, .md.
Perfect minimal distraction-free editor for writing docs.
Thought I'd give this a quick try on my Windows machines, where my liteweight editor of choice is Notepad3.
A fresh start of Lite uses 10MB of memory, vs 3MB for Notepad3.
After opening a 27.5MB text file in each, Lite used 156MB of memory, vs 68 for Notepad3.
The functionality available in Notepad3 is also vastly superior. Lite is pretty spartan - it doesn't even appear to have a file/directory selection dialog to open files/folders with. I really like the default colour scheme/theme Lite ships with though.
I do realise that both Lite and Notepad3 are significantly more featureful, but I'm not sure if the increase in resource consumption is proportional.
(For comparison, regular notepad uses <1MB of memory when holding nothing, and I don't have a 27.5MB text file to test with, but a 6.5MB one takes 17MB when loaded. In other words, the expansion factor is close to Notepad3.)
Font Rendering does not seem to be as crisp as needed for a text editor. (on Windows at least)
I know Sublime is using DirectWrite to render fonts on Win32, this might be something to explore. Also, TrueType with subpixel antialiasing should give good results but might need some tweaking.
I'll follow this project and I might use it as my main editor once it is more mature :)
But upon starting it up I lost all windows decorations (KDE), had to restart my session and lost the things I was working on in my terminals.
How can launching an app cripples the whole desktop ? (not that this have anything to do with the app to me, it's a plasma thing)
First thing I look for was support for vim keybinding, could neovim be used as the backend editor ?
It's not the first time something like that happened to me but I would never have had the patience to investigate !
Can confirm unchecking that setting solved that problem.
Compositing should only provide the fancy effects like Wobbly Windows and window previews in the alt-tab switcher etc. Not sure why this is causing KWin to crash... You can use Alt-Shift-F12 by default to toggle compositing.
But if you're not doing anything more graphically intense than playing turn-based or slow-paced video games then I guess you can use that option to permanently leave on compositing.
[1] https://www.youtube.com/channel/UC1eJk1sWcUYvBwnn7v5RLaQ/vid...
Excluding those, it's 1369 lines of C (.c or .h), and 5389 lines of Lua (.lua), and 112 lines of other files (license, readme, build scripts...); or 78.4% Lua, 19.9% C, and 1.6% other. I didn't count fonts or images (.ttf, .ico, or .inl).
Which is written in C.
Most of the implementation is oddly in the "data" folder.
C version:
https://github.com/DigitalMars/me
D version:
https://github.com/DigitalMars/med
The source is so simple, the "extension language" is just editing the code.
https://user-images.githubusercontent.com/3920290/80743752-7...
Or create their own custom "views":
https://user-images.githubusercontent.com/3920290/81343656-4...
The treeview at the left of the screen is implemented as a normal plugin, and like any other plugin can be removed from lite by simply deleteing the `treeview.lua` file.
I wrote a short article detailing the technique here: https://rxi.github.io/200402.html
Windows, MacOS and GTK maintain internal pixmap buffer for a window.
And when needed you call InvlidateRect(wnd,rc) and receive WM_PAINT with cumulative rect to update.
Personally, I would create an abstraction that wraps couple of functions of GDI, CoreGraphics and Cairo and use it instead manual pixmap rendering. Will be faster and more flexible. All that UI can be rendered by just 2..3 functions FillRect, DrawText, MeasureText.
With dirty rectangles, it's the application's responsibility to minimize much of its drawing; the renderer will at best avoid copying bits where the target of the bits lies outside the drawing rectangle. The renderer can only optimize in situations where the entire call is understood as a full primitive, and it knows that the result will lie outside the dirty rectangle.
With rxi's approach, the application gets to define the commands which update the UI - which may be as complex as desired, as long as they have a calculable rectangle - and the cost of calculating that rendering can be skipped, without needing to query for dirty rectangles or doing any application-side conditional logic, beyond the layer that rxi wrote.
It's particularly powerful if the rendering primitives are higher level than those provided by the native APIs.
Typically with dirty rectangles you would have to manage this state in the application code, for example, determining that line X was edited then updating the region for that line, or determining that view Y moved and updating a dirty rectangle based upon it's previous and current positions.
(Dirty rectangles are still perfectly common in desktop apps for when you e.g. drag a window back on screen after overlapping the edge, or if you scroll a window.)
You can get additional benefits from this approach, by doing multiple layers of it (e.g. having scrollable surfaces have their own tiles that precompute the inner-document-viewport-space rather than the outer-viewport-space, such that the inner tiles aren't invalidated by scrolling the outer viewport.) This technique ends up forming a tree of tiles, where tiles higher up the tree, when invalidated, re-render trivially by compositing tiles further down the tree into themselves. Thus, another name for this approach is a "precompositing tree."
The difference between this approach and dirty rects, is in the direction of information flow. In tile-based precompositing, the information only flows in one direction—from the user, through view-controller, into the DOM, to the tiles, and then out the display. Dirty rects, meanwhile, are a signal sent backwards, from the display system to the program, essentially telling it that the display system lost/discarded the information needed to re-draw an area, so could the program please send it over again. (The program doesn't even have to re-render in response; some dirty-rects implementations, like X11's DAMAGE extension, just involve the client application re-transmitting pixbuf data to the server from its own precomposited buffer.)
Also, dirty rects / screen-damage doesn't solve the problem of hardware not being fast enough; it solves the problem of hardware not having enough VRAM to do per-frame compositing from undamaged intermediates. In low-VRAM conditions, you can only keep around the final pre-composited image; and so any time you "damage" / make "dirty" a region of the screen (e.g. by removing an overdrawn element, which should have the semantics of revealing whatever was there before that element overdrew it) then you need to propagate a request back to the renderer to re-draw (and, for efficiency, re-draw just that region), because you don't just have an intermediate texture laying around for that window/stage-layer/etc. to re-source it from. If you did, then dirty-rects would never come into play, since you'd just re-composite everything each frame. (Which is cheap even on old-school CPU-only blitters—you just have to alternate which pixmap pointer you're basing your LOADs off of using either a rect-overlap check, or a mask-bitmap [which gets you 8 pixels' mask-states per LOAD.] Even the Gameboy can do it!)
That’s what I meant, yes. Interesting approach and impressive.
I saw some comments here about a WASM renderer-based editor, I think there is something in Flutter that is similar, where Flutter uses Skia to render its components.
What are they talking about!?
I mean that as someone who has grown up with 3D shooters and is obsessive about tuning networks to the lowest possible ping times to improve latency for competitive gaming. I always turn triple buffering off because I can definitely feel the difference over double buffering.
Practically every editor I use updates with the maximum 60Hz refresh of my monitor, and that literally can't be improved upon any further through software alone. The exception is Microsoft Word, which does about 30Hz and I hate this, but it's a shitty WYSIWYG editor, not a simple fixed-width text editor.
I mean, seriously: I'm playing Doom Eternal at 4K with a constant 60fps, no dips. That game is processing a decent chunk of a terabyte per second of data at that rate.
What is this mysterious difficulty people have with editing ~100KB text files!?
Either this forum is full of people editing insane multi-gigabyte files (By hand? Why!?) or they're doing it on their 486SX PCs for nostalgia reasons.
I seriously don't get it.
I remember using one editor perhaps 8 years ago, and if I tried multi-cursor mode with more than ~40 insertion points (totally reasonable to edit 40 similar lines at a time), it took a couple of seconds to register each keypress.
Similarly, other editors wind up choking on syntax highlighting, or large files, or find & replace, or documentation lookup, or whatever.
The "mysterious difficulty" you mention is often literally several seconds of latency with, say, a 30,000-line file, whether it's with opening, scrolling, editing, or the other more advanced features already mentioned.
I'm honestly pretty baffled this isn't something you've encountered before. This isn't about hertz, it's literally about entire seconds or large fractions thereof.
Notably, they're all Windows native apps written in C++, with the exception of VS Code, which is partially JavaScript.
I've noticed that some of them struggle with huge (1 GB) files, but editing such as large file is a somewhat strange thing to do.
But I hope what I described makes sense to you. It's not about 1 GB files at all, it's about regular files. My suspicion is that it's mostly "side features" that start to grind when they get beyond a certain point.
To be more specific with one example, I've used another code editor that a simple "find all" operation will populate a results box. If you mess up your regex to be accidentally super-generic and it finds 100,000 results in your 20K-line file, it takes half a minute to load the results into the results box and become responsive again, with no "cancel" button.
Similarly weird edge cases in a syntax highlighter interacting with a half-finished line of code of yours causes something to choke up. That kind of thing.
Do you understand now? Again, you seem to just be lucky that you haven't encountered this kind of thing.
I recently got Neovim working with nvim-typescript but I would be lying if I didn’t say I missed the nice UI/UX of VSCode, nor that I’m annoyed at having to spend so much time configuring my editor and memorizing shortcuts instead of actually getting things done.
So to answer your question I think part of it is that my machine is just worse than yours, and part of it is that editing text is often doing more than just editing text - in my case keystrokes trigger static analysis of a large project.
The reason I still use VS Code is because the additional features for coding make it worth the unfortunate performance cost, but whenever I'm just working with basic markdown files I always go to something like Sublime.
Anything spending time loading plugins or whatever before giving you text on screen and responding to commands is frustrating if the only requirement is to quickly tweak a setting in a config file or just viewing a text file.
I guess it’s less noticeable on windows since everything is GUI based and quite unresponsive by default. But when spending your days in a terminal you get used to a certain snappiness that’s noticeable once interrupted.
Edit: Btw an interesting in-depth analysis of typing latency with measurements https://pavelfatin.com/typing-with-pleasure/
Also add other factors such as remote editing, say on a VPS with 512mb RAM with too many daemons running.
I really like the new VS Code remote-editing feature, where the GUI is local but you can work directly on the remote system.
Visual Studio has a vaguely similar "remote debugger" feature.
Generally I avoid remote development like the plague. As you said, the latency is quite noticeable through any kind of remote connection.
Pro tip for anyone using Windows: Modern versions limit RDP to 30Hz by default, irrespective of CPU power or available bandwidth. See this MS article on how to remove the limitation: https://support.microsoft.com/en-au/help/2885213/frame-rate-...
I always set this to 60 Hz on high-performance "workstation" VDI systems used by developers.
For me the only time screen response comes in to consideration is for flicker.
Editors that flicker badly can be very annoying and very distracting.
My measure of editor responsiveness would be a count based measure of the numbers times you can find yourself waiting on the editor.
Now this waiting can happen for very many different editor actions, but it is most annoying for anything that is keyboard input related.
Snappy editors have very few of these wait points, whereas slow editors drive you mad as you find yourself constantly waiting for some action to complete.
You're missing the point with refresh rate, you could make the slowest implementation in the Universe have a snappy UI thread.
> What is this mysterious difficulty people have with editing
> ~100KB text files!?
Most editors will open the entire file into RAM, which is not such a problem unless is starts trying to index everything for searching, colourizing everything, etc, etc. What feels like a great feature for ~10kB source files starts to chomp away at CPU and RAM for some file >1MB as your editor tries to find patterns in some binary file.
> I mean, seriously: I'm playing Doom Eternal at 4K with a
> constant 60fps, no dips. That game is processing a decent
> chunk of a terabyte per second of data at that rate.
That's quite the powerful machine you have. Consider many people will operate with laptops and some of them are low-power, high battery life. Also consider that many will not just be doing that one thing. I know quite a few people now doing serious dev work from tablets... (They use build servers.)
Also, just because you do have the latest processor available doesn't mean that I expect a simple text editor to consume everything it has.
"Why are 2D vector graphics so much harder than 3D?"
https://blog.mecheye.net/2019/05/why-is-2d-graphics-is-harde...
Admittedly, not a 2D text engine, but I keep up with the research.
The difference between the blog post you linked and a programmer's text editor is night & day.
There's a huge difference between arbitrary 2D graphics and fixed-width text rendering. The former has crazy complex corner-cases, and also has to deal with all of the fun things 3D engines do such as arbitrary transformations and transparency.
A web browser has to deal with the arbitrary case, which is why Firefox's new Rust-based renderer took so many years of hard work to write. It's a complex beast.
A fixed-width text editor is more or less just putting sprites on a grid. Sure, there's subpixel alignment, antialiasing, and maybe even ligatures, but this is nothing really in comparison. They're all "local" issues where typically at most a few hundred pixels are affected per character update.
Or to put it another way, text editor rendering is "embarrassingly parallel". The screen can be split up into lines or char blocks and each can be drawn separately and updated individually when modified.
Compare this to 3D games that are pumping out 4K pixels every frame, updating all of them every time. Web browsers do the same thing, they have to update the entire screen every frame in a lot of scenarios and can manage this at 60 Hz too. Firefox and Chrome both can do this now for much more complex scenarios than text editing.
There's a difference as well between refresh/frame rate and input lag. It is very much possible for a game to have a consistent 60hz frame rate but yet lag. Lag can come from delays in the input subststem, it can come from buffering before display, it can come from the display itself.
Here's a good read: https://www.eurogamer.net/articles/digitalfoundry-2017-conso...
Ever tried early RStudio (or even current) on a crappy work-issued laptop? And I don't mean R, I mean the UI elements.
This is a great piece of software, certainly more than a text editor. But it isn't as fast and snappy as a native editor, far from it. It's tolerable now, but it used to be pretty bad on non beefy hardware.
At the same time, native IDEs did not have that issue at all.
I'm running a Pentium powered notebook and VS Code runs like a dog.
Another factor to consider is you might be running other things in parallel to editing your files (terminal watching and compiling code, a web browser for viewing output, etc).
Was the shitty there qualifying WYSIWYG (as in WYSIWYG editors are definitionally shitty) or qualifying MS Word (as in MS Word is a shitty editor)?
If the latter, do you have suggestions for good WYSIWYG editors?
I write a lot of reports these days, and the Word editor interface drives me crazy. Like I said, it's slow, irrespective of the hardware. It can't even maintain a consistent 30 Hz on a high-end gaming rig when editing plain-text paragraphs with no special formatting. I suspect it's throttled internally, but it could just be badly written.
The editor is also very glitchy in the way it handles formatting. Lots of little annoyances just haven't been fixed and have been left there to fester for decades. It's all too easy to corrupt a document's styles to the point that the only reasonable fix is to carefully cut & paste all content into a new document, going through Notepad on the way to guarantee all hints of the original formatting are stripped.
I used textadept for a while, bought the book to support the author. It didn't work out for me.
Since I really like the looks of it, in case you do need help with keeping it maintained, I would love to help! Feel free to contact me at contact@taigi100.com
Good luck and I hope it all goes well with this text editor!
brew install lincerely/tools/lite
Or brew tap lincerely/tools; brew install lite git clone https://github.com/rxi/lite.git
cd lite
./build.sh
./lite
and an app did start up, but the text gets cut off in the editor window, and I can't quit the app from the menuFixed this with:
sudo apt install libsdl2-dev
on Ubuntu.Else it works as tingletech described also using Mint/Ubuntu.
Update: I can install this using brew install sdl2 https://medium.com/@edkins.sarah/set-up-sdl2-on-your-mac-wit...
static double get_scale(void) {
float dpi;
SDL_GetDisplayDPI(0, NULL, &dpi, NULL);
#if _WIN32
return dpi / 96.0;
#elif __APPLE__
return dpi / 72.0;
#else
return 1.0;
#endif
}
I found changing it to dpi / 192.0 to be fairly comfortable. It wouldn't be too hard to add a scale option and change to `return (dpi * scale) / 192.0`. The "right way" is probably to do that but also get scale by checking the screen resolution; I'd go by height due to the increasing adoption of ultra-wide monitors: static double get_scale(void) {
SDL_DisplayMode dm;
SDL_GetDesktopDisplayMode(0, &dm);
return dm.h * scale / 786.0;
}
Edit: works on my win10 and arch boxes.also fonts are a bit big on retina screen.
Is there a config file where this can be changed?
I currently use Google Keep, which is incredibly slow
It uses database for storing stuff but you can map books to folders on hard drive. And those folders can be under control of DropBox, GoogleDrive etc. So you can read shared stuff on any device using browser there.
- Too many frills
- Too slow
Data structure initialization: https://github.com/rxi/lite/blob/master/data/core/doc/init.l...
How insertion works here, which illuminates how the table is used: https://github.com/rxi/lite/blob/143f8867a13a35f5688ad7c9771...
There's a good post on the Visual Studio Code blog about why and when they moved on from an array of lines to a new structure based on a piece table.
https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r...
It's two dynamic arrays, of hashes and values, whose sizes grow as powers of two.
Any plans of getting this into the arch repo?
(If by modern you mean actively developed)
Or are you drawing the line because Lua is a scripting language?
Is a WASM app that renders to WebGL native?
I guess the point is native should probably mean “using the toolkit the OS provides” and we should just use “performant” in most cases.
Not using a full blown web rendering engine (if that's the case) but OS painting (not necessarily GUI) APIs would make it much more native in my eyes...
It's more "native" because the stack is much shorter, much more direct. If it was more common to have plain JS interacting directly with input APIs and plain canvas, the argument for parity would be stronger. But it's just very rarely the case.
It is not running on a web browser shaped to act like a text editor instead.
There needs to be focus on building tooling that enables rapid development of native applications. GTK is a good example. Glade is a perfectly fine editor, but the underlying tooling for GTK is a mixed bag.
I think this is less true when you don't assume people know all about web tech already, IOW there would be less of a difference for someone coming into software dev completely naive of web tech.
> There needs to be focus on building tooling that enables rapid development of native applications.
Fully agree.
Move fast and break things has become the cancer of software engineering.
Because as you said "It's certainly not perfect yet"