gio: ui/widget: password-mode for editor v1 PROPOSED

~funvit: 1
 ui/widget: password-mode for editor

 1 files changed, 10 insertions(+), 0 deletions(-)
Short resume after some research with io.Reader:
1. Easy to implement masked reader
2. BUT caret begins to bugging

More info for #2:
- No such bug before io.Reader usage was introduced.
- Caret moves by wrong amount of runes (ex: when entering Russian
symbols on macos).

Due to i didn't know what is a "gap" for (editBuffer), and how to
handle caret (replacing position calculation with custom func for
masking mode can leads to bugs in future changes) – i'm cant suggest
new patch version...
(resending email in plain-text)

пн, 13 янв. 2020 г. в 23:47, Elias Naur <mail@eliasnaur.com>:
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/9506/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gio] ui/widget: password-mode for editor Export this patch

From: Vitaliy Funtikov <funvit@gmail.com>

Ability to hide actual editor text, replacing it with asterisk(s) on

Signed-off-by: Vitaliy Funtikov <funvit@gmail.com>
For issue #80

 widget/editor.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/widget/editor.go b/widget/editor.go
index 7ba8d3c..9cb9512 100644
--- a/widget/editor.go
+++ b/widget/editor.go
@@ -33,6 +33,9 @@ type Editor struct {
	// If not enabled, carriage returns are inserted as newlines in the text.
	Submit bool

	// Hide input, replacing each symbol with asterisk (*)
	Password bool

	eventKey     int
	scale        int
	font         text.Font
@@ -432,6 +435,13 @@ func (e *Editor) moveCoord(c unit.Converter, pos image.Point) {

func (e *Editor) layoutText(c unit.Converter, s *text.Shaper, font text.Font) ([]text.Line, layout.Dimensions) {
	txt := e.rr.String()
	if e.Password {
		txtLen := len(txt)
		txt = ""
		for i := 0; i < txtLen; i++ {
			txt += "*"
	opts := text.LayoutOptions{MaxWidth: e.maxWidth}
	textLayout := s.Layout(c, font, txt, opts)
	lines := textLayout.Lines