-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpashua.go
685 lines (637 loc) · 21.6 KB
/
pashua.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
package pashua
import (
"bytes"
"fmt"
"os"
"os/exec"
"os/user"
"path"
"strconv"
"strings"
)
// CompletionMode is a type to store the completion mode for a combobox
type CompletionMode string
const (
NoCompletion CompletionMode = "0"
CaseSensitive = "1"
CaseInsensitive = "2"
)
// FontSize is a type to store the fontsize of a Pashua window
type FontSize string
const (
Regular FontSize = "regular"
Small = "small"
Mini = "mini"
)
// PashuaButton is a structure that holds all information for a PashuaButton
type PashuaButton struct {
Label string
X int
Y int
Disabled bool
Tooltip string
}
// PashuaCancelButton is a structure that holds all information for a PashuaCancelButton
type PashuaCancelButton struct {
Label string
Disabled bool
Tooltip string
}
// PashuaCheckbox is a structure that holds all information for a PashuaCheckbox
type PashuaCheckbox struct {
Label string
Default bool
Disabled bool
Tooltip string
X int
Y int
RelX int
RelY int
}
// PashuaCombobox is a structure that holds all information for a PashuaCombobox
type PashuaCombobox struct {
Label string
Option []string
CompletionMode CompletionMode
Mandatory bool
Rows int
Placeholder string
Disabled bool
Tooltip string
Width int
X int
Y int
RelX int
RelY int
}
// PashuaDate is a structure that holds all information for a PashuaDate
type PashuaDate struct {
Label string
Textual bool
UseDate bool
UseTime bool
Default string
Disabled bool
Tooltip string
X int
Y int
}
// PashuaDefaultButton is a structure that holds all information for a PashuaDefaultButton
type PashuaDefaultButton struct {
Label string
Disabled bool
Tooltip string
}
// PashuaImage is a structure that holds all information for a PashuaImage
type PashuaImage struct {
Label string
Path string
Border bool
Width int
Height int
MaxWidth int
MaxHeight int
UpScale bool
Tooltip string
X int
Y int
RelX int
RelY int
}
// PashuaOpenBrowser is a structure that holds all information for a PashuaOpenBrowser
type PashuaOpenBrowser struct {
Label string
DefaultPath string
Width int
Filetype string
Placeholder string
Mandatory bool
X int
Y int
RelX int
RelY int
}
// PashuaPassword is a structure that holds all information for a PashuaPassword
type PashuaPassword struct {
Label string
Default bool
Disabled bool
Mandatory bool
Tooltip string
Width int
X int
Y int
RelX int
RelY int
}
// PashuaPopup is a structure that holds all information for a PashuaPopup
type PashuaPopup struct {
Option []string
Default string
Label string
Disabled bool
Tooltip string
Mandatory bool
Width int
X int
Y int
RelX int
RelY int
}
// PashuaRadioButton is a structure that holds all information for a PashuaRadioButton
type PashuaRadioButton struct {
Option []string
Default string
Label string
Disabled bool
Tooltip string
Mandatory bool
X int
Y int
RelX int
RelY int
}
// PashuaSaveBrowser is a structure that holds all information for a PashuaSaveBrowser
type PashuaSaveBrowser struct {
Label string
DefaultPath string
Width int
Filetype string
Placeholder string
Mandatory bool
X int
Y int
RelX int
RelY int
}
// PashuaText is a structure that holds all information for a PashuaText
type PashuaText struct {
Label string
Text string
Tooltip string
Width int
X int
Y int
RelX int
RelY int
}
// PashuaTextBox is a structure that holds all information for a PashuaTextBox
type PashuaTextBox struct {
Label string
Default string
Tooltip string
FixedFont bool
FontSize FontSize // regular small mini
Mandatory bool
Disabled bool
Width int
Height int
X int
Y int
RelX int
RelY int
}
// PashuaTextField is a structure that holds all information for a PashuaTextField
type PashuaTextField struct {
Label string
Default string
Tooltip string
Mandatory bool
Disabled bool
Width int
X int
Y int
RelX int
RelY int
}
// PashuaComponents is type for th elist of components contained in a Pashua window
type PashuaComponents map[string]interface{}
// PashuaWindow is the top-most structure when defininng a dialog window for Pashua
type PashuaWindow struct {
AutoCloseTime int
AutoSaveKey string
Floating bool
Title string
Transparency float64
X int
Y int
Components PashuaComponents
}
// fileExists is a helper function that returns true
// if a specified file exists and is a file
func fileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return (info != nil) && !info.IsDir()
}
// LocatePashua is one of the two main binding function
// and tries to find the Pashua.app and the executable contained
// within the app container by iterating over the standard
// file locations. Returns the location path and an error code
func LocatePashua(pashuaPath string) (string, error) {
const bundlePath = "Pashua.app/Contents/MacOS/Pashua"
usr, err := user.Current()
if err != nil {
return "", err
}
usrhome := usr.HomeDir
pashuaPlaces := []string{
path.Join(path.Dir(os.Args[0]), "Pashua"),
path.Join(path.Dir(os.Args[0]), bundlePath),
"./" + bundlePath,
path.Join("/Applications", bundlePath),
path.Join(usrhome, "Applications", bundlePath),
path.Join("/usr/local/bin", bundlePath),
}
if pashuaPath != "" {
// insert at index 0
// yeah, in Go there is no "insert" function,
// so this is a little tricky at first
pashuaPlaces = append(pashuaPlaces, "")
copy(pashuaPlaces[1:], pashuaPlaces[0:])
pashuaPlaces[0] = pashuaPath
}
for _, p := range pashuaPlaces {
if fileExists(p) {
return p, nil
}
}
return "", fmt.Errorf("Could not locate pashua")
}
// RunPashua is one of the two main binding function.
// it sets up a pipe and executes Pashua as an external command,
// then converts the STdOut and StdErr to strings and parses the output
func RunPashua(configData string, pashuaPath string) (map[string]string, error) {
var err error
result := make(map[string]string)
appPath, err := LocatePashua(pashuaPath)
if err != nil {
return nil, err
}
cmd := exec.Command(appPath, "-")
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Stdin = bytes.NewBuffer([]byte(configData))
err = cmd.Run()
if err != nil {
return result, fmt.Errorf("Error: %w, pashua error text: %s", err, string(stderr.Bytes()))
}
outStr := string(stdout.Bytes())
result = parsePashuaOutput(outStr)
return result, err
}
// RunPashuaWithStruct is a convenience function that saves you
// from having to convert a struct-based window definition to a string first
func RunPashuaWithStruct(pashuaWindow *PashuaWindow, pashuaPath string) (map[string]string, error) {
configString := pashuaWindow.ToString()
return RunPashua(configString, pashuaPath)
}
// parsePashuaOutput takes a list of lines and
// converts key=value pairs to a map and
// skips empty lines of lines without an "="
func parsePashuaOutput(output string) map[string]string {
result := make(map[string]string)
lines := strings.Split(output, "\n")
for _, line := range lines {
line = strings.TrimSpace(line)
pos := strings.Index(line, "=")
if line != "" && pos > 0 {
key := line[:pos]
value := line[pos+1:]
result[key] = value
}
}
return result
}
// getFieldValue converts various types to a string
// representation as Pashua needs the configuration as string
func getFieldValue(field interface{}) string {
result := ""
switch field.(type) {
case string:
result = field.(string)
case int:
result = strconv.Itoa(field.(int))
case int8:
result = strconv.Itoa(field.(int))
case int16:
result = strconv.Itoa(field.(int))
case int32:
result = strconv.Itoa(field.(int))
case int64:
result = strconv.Itoa(field.(int))
case float32:
result = strconv.FormatFloat(field.(float64), 'f', 4, 32)
case float64:
result = strconv.FormatFloat(field.(float64), 'f', 4, 64)
case bool:
if field.(bool) {
return "1"
} else {
return "0"
}
case CompletionMode:
result = string(field.(CompletionMode))
case FontSize:
result = string(field.(FontSize))
default:
result = field.(string)
}
return result
}
/*
the function below convert each possible component type
into a config string that Pashua con use.
the "ToString()" of the PashuaWindow iterates over all
defines component and combines them into a large config string
that can be provided to Pashua
*/
func (btn *PashuaButton) ToString(key string) string {
result := []string{key + ".type=button"}
result = append(result, key+".label="+getFieldValue(btn.Label))
result = append(result, key+".tooltip="+getFieldValue(btn.Tooltip))
result = append(result, key+".disabled="+getFieldValue(btn.Disabled))
result = append(result, key+".x="+getFieldValue(btn.X))
result = append(result, key+".y="+getFieldValue(btn.Y))
return strings.Join(result, "\n")
}
func (btn *PashuaDate) ToString(key string) string {
result := []string{key + ".type=date"}
result = append(result, key+".label="+getFieldValue(btn.Label))
result = append(result, key+".tooltip="+getFieldValue(btn.Tooltip))
result = append(result, key+".disabled="+getFieldValue(btn.Disabled))
result = append(result, key+".default="+getFieldValue(btn.Default))
result = append(result, key+".date="+getFieldValue(btn.UseDate))
result = append(result, key+".time="+getFieldValue(btn.UseTime))
result = append(result, key+".textual="+getFieldValue(btn.Textual))
result = append(result, key+".x="+getFieldValue(btn.X))
result = append(result, key+".y="+getFieldValue(btn.Y))
return strings.Join(result, "\n")
}
func (btn *PashuaDefaultButton) ToString(key string) string {
result := []string{key + ".type=defaultbutton"}
result = append(result, key+".label="+getFieldValue(btn.Label))
result = append(result, key+".tooltip="+getFieldValue(btn.Tooltip))
result = append(result, key+".disabled="+getFieldValue(btn.Disabled))
return strings.Join(result, "\n")
}
func (txt *PashuaCancelButton) ToString(key string) string {
result := []string{key + ".type=cancelbutton"}
result = append(result, key+".label="+getFieldValue(txt.Label))
result = append(result, key+".tooltip="+getFieldValue(txt.Tooltip))
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
return strings.Join(result, "\n")
}
func (txt *PashuaCheckbox) ToString(key string) string {
result := []string{key + ".type=checkbox"}
result = append(result, key+".label="+getFieldValue(txt.Label))
result = append(result, key+".default="+getFieldValue(txt.Default))
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
result = append(result, key+".tooltip="+getFieldValue(txt.Tooltip))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (txt *PashuaCombobox) ToString(key string) string {
result := []string{key + ".type=combobox"}
result = append(result, key+".label="+getFieldValue(txt.Label))
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
result = append(result, key+".tooltip="+getFieldValue(txt.Tooltip))
result = append(result, key+".width="+getFieldValue(txt.Width))
result = append(result, key+".rows="+getFieldValue(txt.Rows))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
result = append(result, key+".placeholder="+getFieldValue(txt.Placeholder))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
result = append(result, key+".completion="+getFieldValue(txt.CompletionMode))
for _, k := range txt.Option {
result = append(result, key+".option="+getFieldValue(k))
}
return strings.Join(result, "\n")
}
func (txt *PashuaImage) ToString(key string) string {
result := []string{key + ".type=image"}
result = append(result, key+".label="+txt.Label)
result = append(result, key+".path="+txt.Path)
result = append(result, key+".tooltip="+txt.Tooltip)
result = append(result, key+".width="+getFieldValue(txt.Width))
result = append(result, key+".height="+getFieldValue(txt.Height))
result = append(result, key+".maxwidth="+getFieldValue(txt.MaxWidth))
result = append(result, key+".maxheight="+getFieldValue(txt.MaxHeight))
result = append(result, key+".upscale="+getFieldValue(txt.UpScale))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (txt *PashuaOpenBrowser) ToString(key string) string {
result := []string{key + ".type=openbrowser"}
result = append(result, key+".label="+txt.Label)
result = append(result, key+".default="+txt.DefaultPath)
result = append(result, key+".filetype="+txt.Filetype)
result = append(result, key+".width="+getFieldValue(txt.Width))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
result = append(result, key+".placeholder="+getFieldValue(txt.Placeholder))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (txt *PashuaSaveBrowser) ToString(key string) string {
result := []string{key + ".type=savebrowser"}
result = append(result, key+".label="+txt.Label)
result = append(result, key+".default="+txt.DefaultPath)
result = append(result, key+".filetype="+txt.Filetype)
result = append(result, key+".width="+getFieldValue(txt.Width))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
result = append(result, key+".placeholder="+getFieldValue(txt.Placeholder))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (txt *PashuaPassword) ToString(key string) string {
result := []string{key + ".type=password"}
result = append(result, key+".label="+txt.Label)
result = append(result, key+".tooltip="+txt.Tooltip)
result = append(result, key+".width="+getFieldValue(txt.Width))
result = append(result, key+".default="+getFieldValue(txt.Default))
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (txt *PashuaPopup) ToString(key string) string {
result := []string{key + ".type=popup"}
result = append(result, key+".label="+txt.Label)
result = append(result, key+".tooltip="+txt.Tooltip)
result = append(result, key+".width="+getFieldValue(txt.Width))
result = append(result, key+".default="+getFieldValue(txt.Default))
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
for _, k := range txt.Option {
result = append(result, key+".option="+getFieldValue(k))
}
return strings.Join(result, "\n")
}
func (txt *PashuaRadioButton) ToString(key string) string {
result := []string{key + ".type=radiobutton"}
result = append(result, key+".label="+txt.Label)
result = append(result, key+".tooltip="+txt.Tooltip)
result = append(result, key+".default="+getFieldValue(txt.Default))
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
for _, k := range txt.Option {
result = append(result, key+".option="+getFieldValue(k))
}
return strings.Join(result, "\n")
}
func (txt *PashuaText) ToString(key string) string {
result := []string{key + ".type=text"}
result = append(result, key+".label="+txt.Label)
s := getFieldValue(txt.Text)
s = strings.Replace(s, "\n", "[return]", -1)
result = append(result, key+".text="+s)
result = append(result, key+".tooltip="+txt.Tooltip)
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (txt *PashuaTextBox) ToString(key string) string {
result := []string{key + ".type=textbox"}
result = append(result, key+".label="+txt.Label)
s := getFieldValue(txt.Default)
s = strings.Replace(s, "\n", "[return]", -1)
result = append(result, key+".default="+s)
result = append(result, key+".tooltip="+txt.Tooltip)
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
s = getFieldValue(txt.FixedFont)
if s == "1" {
s = "fixed"
} else {
s = ""
}
result = append(result, key+".fonttype="+s)
result = append(result, key+".fontsize="+getFieldValue(txt.FontSize))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (txt *PashuaTextField) ToString(key string) string {
result := []string{key + ".type=textfield"}
result = append(result, key+".label="+txt.Label)
result = append(result, key+".default="+txt.Default)
result = append(result, key+".tooltip="+txt.Tooltip)
result = append(result, key+".disabled="+getFieldValue(txt.Disabled))
result = append(result, key+".mandatory="+getFieldValue(txt.Mandatory))
result = append(result, key+".x="+getFieldValue(txt.X))
result = append(result, key+".y="+getFieldValue(txt.Y))
result = append(result, key+".relx="+getFieldValue(txt.RelX))
result = append(result, key+".rely="+getFieldValue(txt.RelY))
return strings.Join(result, "\n")
}
func (win *PashuaWindow) WindowToString() string {
result := []string{}
autoSaveKey := getFieldValue(win.AutoSaveKey)
title := getFieldValue(win.Title)
if title != "" {
result = append(result, "*.title="+title)
}
if win.Transparency > 0 {
// do not display invisible dialogs ;-)
result = append(result, "*.transparency="+getFieldValue(win.Transparency))
}
if win.AutoCloseTime > 1 {
result = append(result, "*.autoclosetime="+getFieldValue(win.AutoCloseTime))
}
if autoSaveKey != "" {
result = append(result, "*.autosavekey="+autoSaveKey)
} else {
result = append(result, "*.x="+getFieldValue(win.X))
result = append(result, "*.y="+getFieldValue(win.Y))
}
if win.Floating {
result = append(result, "*.floating=1")
}
return strings.Join(result, "\n")
}
func (win *PashuaWindow) ToString() string {
var result = []string{}
result = append(result, win.WindowToString())
for key, comp := range win.Components {
switch comp.(type) {
case PashuaButton:
btn := comp.(PashuaButton)
result = append(result, btn.ToString(key))
case PashuaCancelButton:
txt := comp.(PashuaCancelButton)
result = append(result, txt.ToString(key))
case PashuaCheckbox:
txt := comp.(PashuaCheckbox)
result = append(result, txt.ToString(key))
case PashuaCombobox:
txt := comp.(PashuaCombobox)
result = append(result, txt.ToString(key))
case PashuaDate:
txt := comp.(PashuaDate)
result = append(result, txt.ToString(key))
case PashuaDefaultButton:
txt := comp.(PashuaDefaultButton)
result = append(result, txt.ToString(key))
case PashuaImage:
txt := comp.(PashuaImage)
result = append(result, txt.ToString(key))
case PashuaOpenBrowser:
txt := comp.(PashuaOpenBrowser)
result = append(result, txt.ToString(key))
case PashuaPassword:
txt := comp.(PashuaPassword)
result = append(result, txt.ToString(key))
case PashuaPopup:
txt := comp.(PashuaPopup)
result = append(result, txt.ToString(key))
case PashuaRadioButton:
txt := comp.(PashuaRadioButton)
result = append(result, txt.ToString(key))
case PashuaSaveBrowser:
txt := comp.(PashuaSaveBrowser)
result = append(result, txt.ToString(key))
case PashuaText:
txt := comp.(PashuaText)
result = append(result, txt.ToString(key))
case PashuaTextBox:
txt := comp.(PashuaTextBox)
result = append(result, txt.ToString(key))
case PashuaTextField:
txt := comp.(PashuaTextField)
result = append(result, txt.ToString(key))
}
}
return strings.Join(result, "\n")
}