Skip to content

Commit cc4ebcf

Browse files
Thibault Brocherieuxzephylac
Thibault Brocherieux
authored andcommitted
Support Chinese URL
Support Chinese URL (go-flutter-desktop#48) Fixes go-flutter-desktop#48 Support MacShortcuts Support quick cursor move Clarification of the purpose explanation. go-flutter-desktop#54 Fixes go-flutter-desktop#54, confusing README Update README.md Fix regression caused by go-flutter-desktop#47 Feature/keyboard layout support (go-flutter-desktop#57) * Support different layout * Exported struct, user can use it in main * Renaming function (matchin new format) * Added default value for shortcuts * Removed local import (testing) * Added keyboard config * Check for optionnal keyboard * Fixed renaming * Fixed regression * new example for keyboard * Added explaination Now only send boolean Changed to boolean parameter & fixed textSelection Fixed some issue, added backspace wordTravellerKEy support wordTravellerKEy added (alt for MacOS, Ctrl for others) Update BUG.md (go-flutter-desktop#69) Removes the "task list" from the template. Add gl_proc_resolver to resolve GL procs within the GLFW context (go-flutter-desktop#71) Fix two race conditions and a type conversion mistake (go-flutter-desktop#70) GLFW callbacks: Obtaining the index of the engine using the window userPointer Engine Args: main_path and packages_path should be set null Assert that EngineOpenGL was created using NewEngineOpenGL (go-flutter-desktop#73) Update LICENSE Calculate pixel_ratio based on users' display (go-flutter-desktop#75) Update release mode flag Example: User defined Pixel Ratio Moved project (go-flutter-desktop#76) Rename a bunch of things: - import path github.com/Drakirus/go-flutter-desktop-embedder > github.com/go-flutter-desktop/go-flutter - package path go-flutter/flutter > go-flutter/embedder - package name flutter > embedder - package name gutter > flutter - embedder.EngineOpenGL > embedder.FlutterEngine - identifier flutterOGL > flutterEngine - formatted embedder.embedder_helper.c README.md: Package rename, change to introduction Fix Linux control issue Fixes go-flutter-desktop#79: cgo identifiers conflict README.md: Add version compatibility information Deprecate OptionWindowInitializer, add WindowIcon Update embedder definitions (go-flutter-desktop#81) updated stocks demo so it work with flutter 1.2.1 Update README.md (go-flutter-desktop#85) * Update README.md fixes cd path Add go.mod Fix go.mod Add codecs and a plugin structure, rework the system plugins. chore: align method receivers Add debugging values in dpi calculation README.md: Add godoc and go report card badge plugin: Add tests plugin: Add json method codec tests plugin: Add first method channel tests chore: Make lint and vet happier and fix spelling mistakes. chore: Improve identifiers .github: Update and simplify the issue template .github: Add template for plugin issues fixes: gitter link in README.md chore: adds link to plugins repo godoc: Handle doc 'MissingPluginException' Add sane defaults for assets and icudtl Remove forced pixelratio Oops, debugging leftover.. Resolve executable path for flutter_assets an icudtl.dat internal/execpath: cleanup Improve engine result handling Add support for sync method handlers Remove hover desktop setup from example go.mod: Add test dependencies Remove duplicate pixels to screencoordinates calculation Fixes go-flutter-desktop#101 .github: Add example template Fix broken tests, now using ResponseSender. README.md: Restructure and simpler getting started Remove examples Fix panic and remove glfw dependency from embedder chore: cleanup and deprecation warnings Upgrade embedder.h, implement mouse hovering, cleanup glfw cursor handling embedder: Add README.md embedder/README.md: cleanup and typo's Cleanup PointerPhaseNone Cleanup debug remnant README.md: Add mouse-over to supported features Fix go-flutter-desktop#113: Don't double-add event of pointerPhase embedder: upgrade embedder.h to flutter/engine for v1.5.4-hotfix.2 (52c7a1e849a170be4b2b2fe34142ca2c0a6fea1f) Implement pointer scrolling. Fixes go-flutter-desktop#6 Add initial implementation for system navigator pop event (go-flutter-desktop#142) Unexport PopBehaviorKind chore: Remove relic of the past Add WindowMode Option for bordreless and borderless fullscreen windows. (go-flutter-desktop#144) Add window dimension limits (go-flutter-desktop#145) * Add window dimensions limits Add renovate.json Update github.com/go-gl/glfw commit hash to e6da0ac pull origin Revert "pull origin" This reverts commit 7f1705a. feature: support for RawKeyboard events Uses the the RawKeyEventDataLinux for every platform. RawKeyEventDataLinux is the only Flutter implementation that support the GLFW Toolkit, the events data is sended as it is, no translation is made in go-flutter, everything is handled by the Flutter framework. Update README.md translate glfw.Repeat to glfw.Press to match other shell's keyevents fix comment Removed debug Removed debug Renamed var (coded = ☁️ or 😴 New way to handle keyboard New way to handle keyboard shortcut bind Fixed masking issue Fixed masking
1 parent a4522cf commit cc4ebcf

File tree

5 files changed

+106
-95
lines changed

5 files changed

+106
-95
lines changed

textinput.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type textinputPlugin struct {
2828
selectionExtent int
2929
}
3030

31-
// keyboardShortcutsGLFW handle glfw.ModifierKey from glfwKeyCallback.
3231
type keyboardShortcutsGLFW struct {
3332
mod glfw.ModifierKey
3433
}
@@ -158,18 +157,18 @@ func (p *textinputPlugin) glfwKeyCallback(window *glfw.Window, key glfw.Key, sca
158157

159158
case p.keyboardLayout.SelectAll:
160159
if keyboardShortcutBind.isModifier() {
161-
p.selectAll()
160+
p.SelectAll()
162161
}
163162

164163
case p.keyboardLayout.Copy:
165164
if keyboardShortcutBind.isModifier() && p.isSelected() {
166-
_, _, selectedContent := p.getSelectedText()
165+
_, _, selectedContent := p.GetSelectedText()
167166
window.SetClipboardString(selectedContent)
168167
}
169168

170169
case p.keyboardLayout.Cut:
171170
if keyboardShortcutBind.isModifier() && p.isSelected() {
172-
_, _, selectedContent := p.getSelectedText()
171+
_, _, selectedContent := p.GetSelectedText()
173172
window.SetClipboardString(selectedContent)
174173
p.removeSelectedText()
175174
}

textinput_darwin.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package flutter
22

3-
import "github.com/go-gl/glfw/v3.2/glfw"
3+
import (
4+
"github.com/go-gl/glfw/v3.2/glfw"
5+
)
46

57
func (p *keyboardShortcutsGLFW) isModifier() bool {
68
return p.mod&glfw.ModSuper != 0
@@ -21,70 +23,70 @@ func (p *keyboardShortcutsGLFW) isWordTravelShift() bool {
2123
func (p *textinputPlugin) MoveCursorHome(mods keyboardShortcutsGLFW) {
2224

2325
if mods.isShift() {
24-
p.moveCursorHomeSelect()
26+
p.MoveCursorHomeSelect()
2527
} else {
26-
p.moveCursorHomeNoSelect()
28+
p.MoveCursorHomeSimple()
2729
}
2830
}
2931

3032
func (p *textinputPlugin) MoveCursorEnd(mods keyboardShortcutsGLFW) {
3133
if mods.isShift() {
32-
p.moveCursorEndSelect()
34+
p.MoveCursorEndSelect()
3335
} else {
34-
p.moveCursorEndNoSelect()
36+
p.MoveCursorEndSimple()
3537
}
3638
}
3739

3840
func (p *textinputPlugin) MoveCursorLeft(mods keyboardShortcutsGLFW) {
3941
if mods.isWordTravelShift() {
40-
p.extendSelectionLeftLine()
42+
p.MoveCursorLeftLine()
4143
} else if mods.isWordTravel() {
42-
p.extendSelectionLeftWord()
44+
p.MoveCursorLeftWord()
4345
} else if mods.isShift() {
44-
p.extendSelectionLeftChar()
46+
p.MoveCursorLeftSimple()
4547
} else {
46-
p.extendSelectionLeftReset()
48+
p.MoveCursorLeftReset()
4749
}
4850
}
4951

5052
func (p *textinputPlugin) MoveCursorRight(mods keyboardShortcutsGLFW) {
5153
if mods.isWordTravelShift() {
52-
p.extendSelectionRightLine()
54+
p.MoveCursorRightLine()
5355
} else if mods.isWordTravel() {
54-
p.extendSelectionRightWord()
56+
p.MoveCursorRightWord()
5557
} else if mods.isShift() {
56-
p.extendSelectionRightChar()
58+
p.MoveCursorRightSimple()
5759
} else {
58-
p.extendSelectionRightReset()
60+
p.MoveCursorRightReset()
5961
}
6062
}
6163

6264
func (p *textinputPlugin) Backspace(mods keyboardShortcutsGLFW) {
63-
if p.removeSelectedText() {
65+
if p.RemoveSelectedText() {
6466
p.updateEditingState()
6567
return
6668
}
6769

6870
if mods.isModifier() {
69-
p.sliceLeftLine()
71+
p.BackspaceLine()
7072
} else if mods.isWordTravel() {
71-
p.sliceLeftWord()
73+
p.BackspaceWord()
7274
} else {
73-
p.sliceLeftChar()
75+
p.BackspaceSimple()
7476
}
7577
}
7678

7779
func (p *textinputPlugin) Delete(mods keyboardShortcutsGLFW) {
78-
if p.removeSelectedText() {
80+
if p.RemoveSelectedText() {
7981
p.updateEditingState()
8082
return
8183
}
8284

8385
if mods.isWordTravelShift() {
84-
p.sliceRightLine()
86+
p.DeleteLine()
8587
} else if mods.isWordTravel() {
86-
p.sliceRightWord()
88+
p.DeleteWord()
8789
} else {
88-
p.sliceRightChar()
90+
p.DeleteSimple()
8991
}
9092
}

textinput_linux.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package flutter
22

3-
import "github.com/go-gl/glfw/v3.2/glfw"
3+
import "github.com/go-gl/glfw/v3.0/glfw"
44

55
func (p *keyboardShortcutsGLFW) isModifier() bool {
66
return p.mod&glfw.ModControl != 0
@@ -20,70 +20,70 @@ func (p *keyboardShortcutsGLFW) isWordTravelShift() bool {
2020

2121
func (p *textinputPlugin) MoveCursorHome(mods keyboardShortcutsGLFW) {
2222
if mods.isShift() {
23-
p.moveCursorHomeSelect()
23+
p.MoveCursorHomeSelect()
2424
} else {
25-
p.moveCursorHomeNoSelect()
25+
p.MoveCursorHomeSimple()
2626
}
2727
}
2828

2929
func (p *textinputPlugin) MoveCursorEnd(mods keyboardShortcutsGLFW) {
3030
if mods.isShift() {
31-
p.moveCursorEndSelect()
31+
p.MoveCursorEndSelect()
3232
} else {
33-
p.moveCursorEndNoSelect()
33+
p.MoveCursorEndSimple()
3434
}
3535
}
3636

3737
func (p *textinputPlugin) MoveCursorLeft(mods keyboardShortcutsGLFW) {
3838
if mods.isWordTravelShift() {
39-
p.extendSelectionLeftLine()
39+
p.MoveCursorLeftLine()
4040
} else if mods.isWordTravel() {
41-
p.extendSelectionLeftWord()
41+
p.MoveCursorLeftWord()
4242
} else if mods.isShift() {
43-
p.extendSelectionLeftChar()
43+
p.MoveCursorLeftSimple()
4444
} else {
45-
p.extendSelectionLeftReset()
45+
p.MoveCursorLeftReset()
4646
}
4747
}
4848

4949
func (p *textinputPlugin) MoveCursorRight(mods keyboardShortcutsGLFW) {
5050
if mods.isWordTravelShift() {
51-
p.extendSelectionRightLine()
51+
p.MoveCursorRightLine()
5252
} else if mods.isWordTravel() {
53-
p.extendSelectionRightWord()
53+
p.MoveCursorRightWord()
5454
} else if mods.isShift() {
55-
p.extendSelectionRightChar()
55+
p.MoveCursorRightSimple()
5656
} else {
57-
p.extendSelectionRightReset()
57+
p.MoveCursorRightReset()
5858
}
5959
}
6060

6161
func (p *textinputPlugin) Backspace(mods keyboardShortcutsGLFW) {
62-
if p.removeSelectedText() {
62+
if p.RemoveSelectedText() {
6363
p.updateEditingState()
6464
return
6565
}
6666

67-
if mods.isWordTravelShift() {
68-
p.sliceLeftLine()
67+
if mods.isModifier() {
68+
p.BackspaceLine()
6969
} else if mods.isWordTravel() {
70-
p.sliceLeftWord()
70+
p.BackspaceWord()
7171
} else {
72-
p.sliceLeftChar()
72+
p.BackspaceSimple()
7373
}
7474
}
7575

7676
func (p *textinputPlugin) Delete(mods keyboardShortcutsGLFW) {
77-
if p.removeSelectedText() {
77+
if p.RemoveSelectedText() {
7878
p.updateEditingState()
7979
return
8080
}
8181

8282
if mods.isWordTravelShift() {
83-
p.sliceRightLine()
83+
p.DeleteLine()
8484
} else if mods.isWordTravel() {
85-
p.sliceRightWord()
85+
p.DeleteWord()
8686
} else {
87-
p.sliceRightChar()
87+
p.DeleteSimple()
8888
}
8989
}

textinput_model.go

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,51 @@ func (p *textinputPlugin) addChar(char []rune) {
3333
p.updateEditingState()
3434
}
3535

36-
func (p *textinputPlugin) moveCursorHomeNoSelect() {
36+
func (p *textinputPlugin) MoveCursorHomeSimple() {
3737
p.selectionBase = 0
3838
p.selectionExtent = p.selectionBase
39+
p.updateEditingState()
3940
}
4041

41-
func (p *textinputPlugin) moveCursorHomeSelect() {
42+
func (p *textinputPlugin) MoveCursorHomeSelect() {
4243
p.selectionBase = 0
44+
p.updateEditingState()
4345
}
4446

45-
func (p *textinputPlugin) moveCursorEndNoSelect() {
47+
func (p *textinputPlugin) MoveCursorEndSimple() {
4648
p.selectionBase = len(p.word)
4749
p.selectionExtent = p.selectionBase
50+
p.updateEditingState()
4851
}
4952

50-
func (p *textinputPlugin) moveCursorEndSelect() {
53+
func (p *textinputPlugin) MoveCursorEndSelect() {
5154
p.selectionBase = len(p.word)
55+
p.updateEditingState()
5256
}
5357

54-
func (p *textinputPlugin) extendSelectionLeftChar() {
55-
if p.selectionExtent > 0 {
56-
p.selectionExtent--
57-
}
58+
func (p *textinputPlugin) MoveCursorLeftSimple() {
59+
p.selectionExtent--
60+
p.updateEditingState()
5861
}
5962

60-
func (p *textinputPlugin) extendSelectionLeftWord() {
63+
func (p *textinputPlugin) MoveCursorLeftWord() {
6164
p.selectionBase = indexStartLeadingWord(p.word, p.selectionBase)
6265
p.selectionExtent = p.selectionBase
66+
p.updateEditingState()
6367

6468
}
6569

66-
func (p *textinputPlugin) extendSelectionLeftLine() {
70+
func (p *textinputPlugin) MoveCursorLeftLine() {
6771
if p.isSelected() {
6872
p.selectionExtent = indexStartLeadingWord(p.word, p.selectionExtent)
6973
} else {
7074
p.selectionExtent = indexStartLeadingWord(p.word, p.selectionBase)
7175
}
76+
p.updateEditingState()
7277

7378
}
7479

75-
func (p *textinputPlugin) extendSelectionLeftReset() {
80+
func (p *textinputPlugin) MoveCursorLeftReset() {
7681
if !p.isSelected() {
7782
if p.selectionBase > 0 {
7883
p.selectionBase--
@@ -83,28 +88,29 @@ func (p *textinputPlugin) extendSelectionLeftReset() {
8388
}
8489
}
8590

86-
func (p *textinputPlugin) extendSelectionRightChar() {
87-
if p.selectionExtent < len(p.word) {
88-
p.selectionExtent++
89-
}
91+
func (p *textinputPlugin) MoveCursorRightSimple() {
92+
p.selectionExtent++
93+
p.updateEditingState()
9094
}
9195

92-
func (p *textinputPlugin) extendSelectionRightWord() {
96+
func (p *textinputPlugin) MoveCursorRightWord() {
9397
p.selectionBase = indexEndForwardWord(p.word, p.selectionBase)
9498
p.selectionExtent = p.selectionBase
99+
p.updateEditingState()
95100

96101
}
97102

98-
func (p *textinputPlugin) extendSelectionRightLine() {
103+
func (p *textinputPlugin) MoveCursorRightLine() {
99104
if p.isSelected() {
100105
p.selectionExtent = indexEndForwardWord(p.word, p.selectionExtent)
101106
} else {
102107
p.selectionExtent = indexEndForwardWord(p.word, p.selectionBase)
103108
}
109+
p.updateEditingState()
104110

105111
}
106112

107-
func (p *textinputPlugin) extendSelectionRightReset() {
113+
func (p *textinputPlugin) MoveCursorRightReset() {
108114
if !p.isSelected() {
109115
if p.selectionBase < len(p.word) {
110116
p.selectionBase++
@@ -113,52 +119,56 @@ func (p *textinputPlugin) extendSelectionRightReset() {
113119
} else {
114120
p.selectionBase = p.selectionExtent
115121
}
122+
p.updateEditingState()
116123
}
117124

118125
func (p *textinputPlugin) selectAll() {
119126
p.selectionBase = 0
120127
p.selectionExtent = len(p.word)
121128
}
122129

123-
func (p *textinputPlugin) sliceRightChar() {
130+
func (p *textinputPlugin) DeleteSimple() {
124131
if p.selectionBase < len(p.word) {
125132
p.word = append(p.word[:p.selectionBase], p.word[p.selectionBase+1:]...)
126133

127134
}
128135
}
129136

130-
func (p *textinputPlugin) sliceRightWord() {
137+
func (p *textinputPlugin) DeleteWord() {
131138
UpTo := indexEndForwardWord(p.word, p.selectionBase)
132139
p.word = append(p.word[:p.selectionBase], p.word[UpTo:]...)
140+
p.updateEditingState()
133141
}
134142

135-
func (p *textinputPlugin) sliceRightLine() {
143+
func (p *textinputPlugin) DeleteLine() {
136144
p.word = p.word[:p.selectionBase]
145+
p.updateEditingState()
137146
}
138147

139-
func (p *textinputPlugin) sliceLeftChar() {
148+
func (p *textinputPlugin) BackspaceSimple() {
140149
if len(p.word) > 0 && p.selectionBase > 0 {
141150
p.word = append(p.word[:p.selectionBase-1], p.word[p.selectionBase:]...)
142151
p.selectionBase--
143152
p.selectionExtent = p.selectionBase
144-
153+
p.updateEditingState()
145154
}
146155
}
147156

148-
func (p *textinputPlugin) sliceLeftWord() {
157+
func (p *textinputPlugin) BackspaceWord() {
149158
if len(p.word) > 0 && p.selectionBase > 0 {
150159
deleteUpTo := indexStartLeadingWord(p.word, p.selectionBase)
151160
p.word = append(p.word[:deleteUpTo], p.word[p.selectionBase:]...)
152161
p.selectionBase = deleteUpTo
153162
p.selectionExtent = deleteUpTo
154-
163+
p.updateEditingState()
155164
}
156165
}
157166

158-
func (p *textinputPlugin) sliceLeftLine() {
167+
func (p *textinputPlugin) BackspaceLine() {
159168
p.word = p.word[:0]
160169
p.selectionBase = 0
161170
p.selectionExtent = 0
171+
p.updateEditingState()
162172
}
163173

164174
// removeSelectedText do nothing if no text is selected

0 commit comments

Comments
 (0)