multiline_input 0.2.0

Terminal multiline input with rich editing (ENTER to submit, CTRL+ENTER for newline)
Documentation
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
# multiline_input - Manual Testing Guide

Manual testing procedures for the multiline_input terminal widget library.

## Overview

This document covers manual testing scenarios for multiline_input that verify functionality not easily covered by automated tests:
- Terminal interaction and key bindings
- Visual rendering and formatting
- Cursor movement and editing behavior
- Validation and error feedback
- Cross-platform terminal compatibility

**Note**: This is a library, not a standalone CLI. Tests use example programs to exercise the library.

## Prerequisites

### 1. Build Examples

```bash
cd /home/user1/pro/lib/willbe/module/multiline_input
cargo build --examples --release
```

### 2. Terminal Requirements

- ANSI color support
- UTF-8 encoding
- Standard terminal size (80x24 minimum)

### 3. Test Terminals

Test on multiple terminal emulators:
- **Linux**: gnome-terminal, konsole, alacritty
- **macOS**: Terminal.app, iTerm2
- **Windows**: Windows Terminal, ConEmu

## Test Scenarios

### Test 1: Basic Text Input

**Objective**: Verify simple text input works

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Manual Steps**:
1. Type: `Hello World`
2. Press ENTER

**Expected Results**:
- ✅ Text appears as typed
- ✅ Cursor follows typing
- ✅ ENTER submits input
- ✅ Program prints: `You entered: Hello World`
- ✅ Exit code 0

**Success Criteria**:
- Text is readable
- Cursor is visible
- Submit works correctly

### Test 2: Multiline Input

**Objective**: Verify CTRL+ENTER creates newlines

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Manual Steps**:
1. Type: `Line 1`
2. Press CTRL+ENTER
3. Type: `Line 2`
4. Press CTRL+ENTER
5. Type: `Line 3`
6. Press ENTER

**Expected Results**:
- ✅ CTRL+ENTER adds newlines (not submits)
- ✅ Cursor moves to next line
- ✅ All lines visible during editing
- ✅ ENTER submits all three lines
- ✅ Output shows all three lines

**Success Criteria**:
- Multiline editing works
- Line breaks preserved
- Submit includes all lines

### Test 3: Cursor Movement - Arrows

**Objective**: Verify arrow key navigation

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Manual Steps**:
1. Type: `ABCDEF`
2. Press LEFT 3 times (cursor at D)
3. Type `X` (should insert, not overwrite)
4. Press RIGHT 2 times
5. Type `Y`
6. Press ENTER

**Expected Result**: `ABXCDEYF`

**Test Vertical Movement**:
1. Type: `Line 1`
2. Press CTRL+ENTER
3. Type: `Line 2`
4. Press UP (should move to Line 1)
5. Press END
6. Type ` end`
7. Press DOWN
8. Type ` end`
9. Press ENTER

**Expected Result**:
```
Line 1 end
Line 2 end
```

**Success Criteria**:
- ✅ LEFT/RIGHT move cursor horizontally
- ✅ UP/DOWN move cursor between lines
- ✅ Cursor position is accurate
- ✅ Text insertion works at cursor position

### Test 4: Home/End Keys

**Objective**: Verify Home/End navigation

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Manual Steps**:
1. Type: `Hello World`
2. Press HOME (cursor to start of line)
3. Type `>> ` (should prepend)
4. Press END (cursor to end of line)
5. Type ` <<` (should append)
6. Press ENTER

**Expected Result**: `>> Hello World <<`

**Test Multi-line**:
1. Type: `Line 1`
2. Press CTRL+ENTER
3. Type: `Line 2`
4. Press CTRL+HOME (to start of all text)
5. Type `START `
6. Press CTRL+END (to end of all text)
7. Type ` END`
8. Press ENTER

**Expected Result**:
```
START Line 1
Line 2 END
```

**Success Criteria**:
- ✅ HOME moves to start of current line
- ✅ END moves to end of current line
- ✅ CTRL+HOME moves to start of all text
- ✅ CTRL+END moves to end of all text

### Test 5: Backspace and Delete

**Objective**: Verify character deletion

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Test Backspace**:
1. Type: `Hello World`
2. Press BACKSPACE 5 times
3. Press ENTER

**Expected Result**: `Hello `

**Test Delete**:
1. Type: `Hello World`
2. Press HOME
3. Press DELETE 6 times
4. Press ENTER

**Expected Result**: `World`

**Test at Line Boundaries**:
1. Type: `Line 1`
2. Press CTRL+ENTER
3. Type: `Line 2`
4. Press UP, END
5. Press DELETE (should merge lines)
6. Press ENTER

**Expected Result**: `Line 1Line 2`

**Success Criteria**:
- ✅ BACKSPACE deletes before cursor
- ✅ DELETE deletes at cursor
- ✅ Line merging works correctly
- ✅ No crashes at text boundaries

### Test 6: Cancellation (ESC/CTRL+C)

**Objective**: Verify cancellation returns None

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Test ESC**:
1. Type: `Some text`
2. Press ESC

**Expected Results**:
- ✅ Program exits immediately
- ✅ Prints: `Cancelled`
- ✅ Exit code 0

**Test CTRL+C**:
1. Run example again
2. Type: `Some text`
3. Press CTRL+C

**Expected Results**:
- ✅ Program exits immediately
- ✅ Prints: `Cancelled`
- ✅ Exit code 0

**Success Criteria**:
- Both cancellation methods work
- Clean exit with no errors
- Typed text discarded

### Test 7: Visual Formatting with Line Numbers

**Objective**: Verify line numbers display correctly

**Execute**:
```bash
./target/release/examples/with_config
# (or modify basic_usage to enable line numbers)
```

**Manual Steps**:
1. Type: `Line 1`
2. Press CTRL+ENTER
3. Type: `Line 2`
4. Press CTRL+ENTER
5. Type: `Line 3`
6. Press ENTER

**Expected Display**:
```
1 │ Line 1
2 │ Line 2
3 │ Line 3
```

**Success Criteria**:
- ✅ Line numbers increment correctly
- ✅ Separator (│) is visible
- ✅ Alignment is clean
- ✅ Numbers update on line add/delete

### Test 8: Status Line

**Objective**: Verify status line shows position

**Execute**:
```bash
./target/release/examples/with_config
# (ensure show_status is enabled)
```

**Manual Steps**:
1. Type: `Hello World`
2. Observe status line

**Expected Status**: `Line 1, Col 12, 11 chars`

3. Press CTRL+ENTER
4. Type: `More text`

**Expected Status**: `Line 2, Col 10, 21 chars`

**Success Criteria**:
- ✅ Line number accurate
- ✅ Column number accurate
- ✅ Character count accurate
- ✅ Updates in real-time as you type

### Test 9: Validation - Minimum Length

**Objective**: Verify min length validation

**Execute**:
```bash
./target/release/examples/with_validation
# (ensure min_length is configured, e.g., 10)
```

**Manual Steps**:
1. Type: `Short`
2. Press ENTER

**Expected Results**:
- ✅ Validation error displayed
- ✅ Message: "Text must be at least 10 characters"
- ✅ Does NOT submit (stays in editor)
- ✅ Can continue editing

3. Type more text to meet minimum
4. Press ENTER

**Expected Results**:
- ✅ Validation passes
- ✅ Text submitted successfully

**Success Criteria**:
- Validation enforced on submit
- Clear error messages
- Can retry after validation failure

### Test 10: Validation - Maximum Length

**Objective**: Verify max length validation

**Execute**:
```bash
./target/release/examples/with_validation
# (ensure max_length is configured, e.g., 50)
```

**Manual Steps**:
1. Type 60 characters of text
2. Press ENTER

**Expected Results**:
- ✅ Validation error displayed
- ✅ Message: "Text must be at most 50 characters"
- ✅ Does NOT submit
- ✅ Can delete characters and retry

**Success Criteria**:
- Max length enforced
- Error message clear
- Can correct and resubmit

### Test 11: Custom Validation

**Objective**: Verify custom validator works

**Execute**:
```bash
./target/release/examples/with_validation
```

**Manual Steps**:
1. Type: `This contains spam word`
2. Press ENTER

**Expected Results**:
- ✅ Custom validation error displayed
- ✅ Message: "Message contains prohibited content"
- ✅ Does NOT submit

3. Delete "spam" and retype without it
4. Press ENTER

**Expected Results**:
- ✅ Validation passes
- ✅ Text submitted

**Success Criteria**:
- Custom validators work
- Error messages are custom
- Validation logic is respected

### Test 12: Pre-filled Text Editing

**Objective**: Verify editing pre-filled text works

**Execute**:
```bash
./target/release/examples/pre_filled
```

**Expected Initial State**:
```
- Task 1
- Task 2
- Task 3
```

**Manual Steps**:
1. Press END (move to end of line 1)
2. Type ` (edited)`
3. Press DOWN, DOWN
4. Press HOME, DELETE (delete "- ")
5. Press ENTER

**Expected Result**:
```
- Task 1 (edited)
- Task 2
Task 3
```

**Success Criteria**:
- ✅ Pre-filled text appears immediately
- ✅ Cursor starts at beginning
- ✅ All editing operations work
- ✅ Can modify pre-filled content

### Test 13: Color Output

**Objective**: Verify color rendering

**Execute**:
```bash
./target/release/examples/with_config
# (ensure color is enabled)
```

**Visual Inspection**:
- ✅ Prompt is colored (if configured)
- ✅ Status line is colored differently from text
- ✅ Line numbers are colored differently
- ✅ Colors are readable on both light and dark terminals

**Test Color Disabled**:
```bash
./target/release/examples/with_config
# (set color::false)
```

**Visual Inspection**:
- ✅ No color codes visible
- ✅ Still readable
- ✅ Layout unchanged

**Success Criteria**:
- Colors enhance readability
- Graceful degradation when disabled
- Works on various terminal themes

### Test 14: Terminal Size Changes

**Objective**: Verify handling of terminal resize

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Manual Steps**:
1. Type several lines of text
2. Resize terminal window (make narrower)
3. Continue typing
4. Resize terminal window (make wider)
5. Press ENTER

**Expected Results**:
- ✅ Text reflows on resize (if supported)
- ✅ No crashes on resize
- ✅ Cursor remains visible
- ✅ Can continue editing after resize

**Success Criteria**:
- Graceful handling of resize
- No data loss
- Editing continues normally

### Test 15: Unicode and Special Characters

**Objective**: Verify unicode support

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Test Cases**:
1. Type emoji: `Hello 👋 World 🌍`
2. Type accents: `Café résumé naïve`
3. Type CJK: `你好世界 こんにちは 안녕하세요`
4. Type symbols: `→ ≈ © ™ ± ≠`
5. Press ENTER for each

**Expected Results**:
- ✅ All characters display correctly
- ✅ Cursor position accurate
- ✅ Character count correct
- ✅ Backspace/Delete work properly with unicode

**Success Criteria**:
- Full unicode support
- Accurate character counting
- No rendering glitches

### Test 16: Long Lines

**Objective**: Verify handling of very long single lines

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Manual Steps**:
1. Type 200+ characters on a single line (no CTRL+ENTER)
2. Press LEFT repeatedly to navigate back
3. Press RIGHT to navigate forward
4. Press ENTER

**Expected Results**:
- ✅ Long line handles correctly
- ✅ Horizontal scrolling works (or line wraps)
- ✅ Cursor navigation works throughout
- ✅ Full text captured

**Success Criteria**:
- No truncation
- Navigation works
- Text captured completely

### Test 17: Empty Input

**Objective**: Verify handling of empty/whitespace input

**Execute**:
```bash
./target/release/examples/basic_usage
```

**Test Empty**:
1. Don't type anything
2. Press ENTER

**Expected Results** (if allow_empty is true):
- ✅ Submits empty string
- ✅ Program prints: `You entered: ` (empty)

**Test Whitespace Only**:
1. Type several spaces
2. Press ENTER

**Expected Results**:
- ✅ Whitespace preserved (not trimmed automatically)
- ✅ Output shows spaces

**Success Criteria**:
- Empty handling configurable
- Whitespace preserved when intended

### Test 18: Cross-Platform Compatibility

**Objective**: Verify functionality across platforms

**Test on Each Platform**:
- Linux (primary)
- macOS (if available)
- Windows (if available)

**For Each Platform, Test**:
1. Basic input and submit (ENTER)
2. Multiline (CTRL+ENTER)
3. Cursor movement (arrows)
4. Cancellation (ESC, CTRL+C)
5. Special keys (Home, End, Delete)

**Expected Results**:
- ✅ All tests pass on each platform
- ✅ Key bindings work correctly
- ✅ Terminal rendering is clean
- ✅ No platform-specific bugs

**Known Issues**:
- Windows cmd.exe: CTRL+ENTER may not work
- Windows cmd.exe: Limited ANSI color support

## Verification Checklist

**Basic Input**:
- [ ] Simple text input works
- [ ] Multiline input (CTRL+ENTER) works
- [ ] Submit (ENTER) works
- [ ] Cancellation (ESC, CTRL+C) works

**Navigation**:
- [ ] Arrow keys (LEFT, RIGHT, UP, DOWN) work
- [ ] Home/End keys work
- [ ] CTRL+Home/CTRL+End work
- [ ] Cursor position is accurate

**Editing**:
- [ ] Backspace deletes correctly
- [ ] Delete key works
- [ ] Text insertion at cursor works
- [ ] Line merging works

**Visual Rendering**:
- [ ] Line numbers display correctly (if enabled)
- [ ] Status line shows accurate info (if enabled)
- [ ] Colors render properly (if enabled)
- [ ] Layout is clean and readable

**Validation**:
- [ ] Minimum length enforced
- [ ] Maximum length enforced
- [ ] Custom validators work
- [ ] Error messages are clear

**Advanced Features**:
- [ ] Pre-filled text editing works
- [ ] Unicode characters supported
- [ ] Long lines handled
- [ ] Terminal resize handled
- [ ] Empty input allowed (if configured)

**Cross-Platform**:
- [ ] Linux terminal support verified
- [ ] macOS terminal support verified (if tested)
- [ ] Windows terminal support verified (if tested)

## Known Limitations

1. **Scrolling**: Long texts may not scroll properly (planned feature)
2. **Undo/Redo**: Not yet implemented
3. **Clipboard**: No copy/paste integration yet
4. **Windows cmd.exe**: Limited support, use Windows Terminal instead

## Reporting Issues

When reporting issues from manual testing:

1. **Include terminal type and version**:
   ```bash
   echo $TERM
   # Terminal emulator name and version
   ```

2. **Include example used**:
   ```bash
   ./target/release/examples/basic_usage
   ```

3. **Describe exact key sequence**:
   - "Typed 'Hello', pressed CTRL+ENTER, typed 'World', pressed ENTER"

4. **Expected vs actual behavior**

5. **Screenshot** showing visual issue (if rendering problem)

6. **OS and version**:
   ```bash
   uname -a  # Linux/macOS
   ver  # Windows
   ```

## References

- Terminal control sequences: <https://en.wikipedia.org/wiki/ANSI_escape_code>
- Rust termion crate: <https://docs.rs/termion/>
- Main spec: `../../spec.md`
- Examples: `../../examples/`