simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
724 stars 49 forks source link

addText method for textArea copies whole contents on each call #102

Closed ZoomRmc closed 4 years ago

ZoomRmc commented 4 years ago

addText method for textArea copies whole contents on each call: textArea.text = textArea.text & text It gets slow for big texts and lots of sequential adds.

At least for Win32 the preferred way to avoid copying would be setting the cursor to the end of the text and replacing the selection with the added line. The issue with that is we lose current selection.

I made some working changes for Windows implementation and could prepare a PR, but It will certainly require a review: I'm neither WinApi nor Nim export, to put it mildly.

simonkrauter commented 4 years ago

I agree, this would be useful. And probably easy to implement. I will have a look how it could work under Gtk.

simonkrauter commented 4 years ago

PR: https://github.com/trustable-code/NiGui/pull/103

simonkrauter commented 4 years ago

I have implemented it differently also using EM_REPLACESEL. Most work was to preserve the scroll position.

The Gtk backend already had a fast implementation for this.

ZoomRmc commented 4 years ago

Thanks a lot!