~eliasnaur/gio

1

Text Editing

Werner Laurensse
Details
Message ID
<CABN121hxn4Wrc0mHwCy8xJAYs7v4AuNJAoNzETEDY55eJYTUDA@mail.gmail.com>
DKIM signature
missing
Download raw message
Cool project.

I've created a small patch that adds copy/paste support [1].
The api looks as followed:

s := app.PasteboardGetString()
app.PasteboardSetString(s)

Are you happy with this design or should it be in its own package?

s := pasteboard.GetString()
pasteboard.SetString(s)

Currently it only works on OSX

Do you plan to support more advanced text editing?
I'm developing a GUI for a symbolic programming language [2] and
was looking to do the following advanced text editing.

* Select text with either mouse or shift+arrow keys
* Copy/past to/from OS text buffer
* Highlight selected text
* Render certain substrings in a different way, like → instead of ->
* Custom keybindings for things like autocompletion and evaluating expressions.

Maybe there is a way we can share ate least some of the implementation?

[1] https://github.com/wrnrlr/gio/commit/d053f6f095a1b69683c9fb930e7edef1c58ab9be
[2] https://github.com/wrnrlr/expreduce

Kind Regards
Werner
Details
Message ID
<BXOA5CNPF64W.8P7OBLX9WJ56@testmac>
In-Reply-To
<CABN121hxn4Wrc0mHwCy8xJAYs7v4AuNJAoNzETEDY55eJYTUDA@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
On Sat Oct 12, 2019 at 10:10 PM Werner Laurensse wrote:
> Cool project.
> 
> I've created a small patch that adds copy/paste support [1].
> The api looks as followed:
> 
> s := app.PasteboardGetString()
> app.PasteboardSetString(s)
> 
> Are you happy with this design or should it be in its own package?
> 
> s := pasteboard.GetString()
> pasteboard.SetString(s)
> 

In Gio only the top level of your program interfaces with package app
and similar system packages. Furthermore, to fit in with the immediate
mode event and update model, clipboard interaction should be
modeled as an operation for declaring interest in the clipboard and
an operation to update the clipboard. See

	https://lists.sr.ht/~eliasnaur/gio/%3CCAJnE92uoo%3DpjEf4_E2-+xpFFevdjBXwpX+cqeUWSQfXRmb8hyg%40mail.gmail.com%3E#%3C0f825099-1304-f86c-8b02-998daf4c19f7@wow.st%3E

for a previous discussion that includes a design sketch. With the recent
package renaming, the clipboard package should probably live in
`gioui.org/io/clipboard`.

> Do you plan to support more advanced text editing?
> I'm developing a GUI for a symbolic programming language [2] and
> was looking to do the following advanced text editing.
> 

Absolutely. Next on my plate for the widget.Editor is proper integration
with the OS IME system. IME support is particularly important on mobile where
the software keyboard is frustrating to use without spellchecks and
autocorrect.

> * Select text with either mouse or shift+arrow keys

Yep.

> * Copy/past to/from OS text buffer

Ideally, your work on clipboard integration would add widget.Editor
support as well.

> * Highlight selected text

Yep.

> * Render certain substrings in a different way, like → instead of ->

I hadn't thought about that use case before. One way to do it would
be intercepting Editor events and replacing -> with →. However, perhaps
you want to retain the entered text?

> * Custom keybindings for things like autocompletion and evaluating expressions.
> 

I believe you can do that today by listening for key.Event in your main
loop and modifying the Editor content.

> Maybe there is a way we can share ate least some of the implementation?
> 

Ideally, most if not all of your points above belong in widget.Editor.

> [1] https://github.com/wrnrlr/gio/commit/d053f6f095a1b69683c9fb930e7edef1c58ab9be
> [2] https://github.com/wrnrlr/expreduce
> 

Nice!

-- elias
Reply to thread Export thread (mbox)