27 karma · joined March 28, 2013
It's ok to disagree with godit, it's not meant for everybody. Frankly, just for me. And if someone else likes it, I don't mind sharing it.
Go-completion facility in Emacs is available. `github.com/nsf/gocode` has two plugins for emacs (auto-complete-mode and company-mode).
And I can't just add "modes" and "view" packages, because there are parts in them which depend on core concepts, which leads me to another "core" package or something. And that's 3 packages already. When there's 3, there's 4. It's easier the way it is.
In my opinion linked list of lines is perfect here. Because the only time you need to go through it in a linear fashion is the actual "goto line" operation. The rest is mostly O(1). Of course line insertion is much more common than "goto line" in editors.
The only problem in godit is that it still doesn't handle long lines very well, here most of the operations are O(N). In fact in godit every time you move a cursor or basically do anything it will do O(N) operation on a current line. I checked this kind of stuff on long enough line (10k), no problems here. I don't think there are that many docs with lines longer than 10k.
So, yes, it will work on very large files without any problems. I've just tested it by creating a 56M file with ~660k lines. Can't see any performance issues on my i5-3470, except for loading and saving, it feels like 0.5s for both or so.
Of course contiguous buffer is not an efficient way to do an editor, I guess "advanced" editors use rope data structure or something. Although most of the editors load large files slower than godit. In a perfect world on files bigger than say 50M you should do memory mapping or something. But most editors like to know the amount of lines in a file they're showing to you, so, no mmap here.
Anyways.. It works very well in practice.
Writing the right combination of what I want is a perfect way to solve this problem.
The editor is never meant to be used by anyone except me. But if someone finds it nice, I don't mind sharing it. Plus it's the only serious example of termbox library usage (I wrote it too).