68
115
//debugln(['done ',ASubName]);
118
procedure TTestTrimSpace.test_assert(ASubName: String; AExp: array of String; AExpX: Integer;
119
AExpY: Integer; AppendCr: Boolean = True);
121
test_assert(ASubName, LinesToText(AExp), AExpX, AExpY, AppendCr);
124
procedure TTestTrimSpace.test_add_undo(Cmd: TSynEditorCommand; IsRedo: Boolean);
126
if not IsRedo then begin
128
SetLength(FUndoList, FUndoIndex);
129
FUndoList[FUndoIndex-1].Command := Cmd;
130
FUndoList[FUndoIndex-1].CaretWas := SynEdit.CaretXY;
131
FUndoList[FUndoIndex-1].VTextWas := SynEdit.ViewedTextBuffer.Text;
134
SetLength(FRedoList, FUndoIndex);
135
FRedoList[FUndoIndex-1].Command := Cmd;
136
FRedoList[FUndoIndex-1].CaretWas := SynEdit.CaretXY;
137
FRedoList[FUndoIndex-1].VTextWas := SynEdit.ViewedTextBuffer.Text;
71
141
procedure TTestTrimSpace.test_start(AName, Txt: String);
74
144
SynEdit.Text := Txt;
145
SetLength(FUndoList, 0);
75
147
//debugln(['----- START ',AName]);
79
Procedure TTestTrimSpace.test_cmd(ASubName: String; X, Y: Integer; Cmd: TSynEditorCommand; AChar: TUTF8Char;
80
AExp: String = ''; AExpX: Integer = -1; AExpY: Integer = -1);
150
procedure TTestTrimSpace.test_start(AName: String; Txt: array of String);
152
test_start(AName, LinesToText(Txt));
155
procedure TTestTrimSpace.test_start(AName: String; Txt: array of String; X, Y: Integer);
157
test_start(AName, LinesToText(Txt));
158
SynEdit.CaretXY := Point(x, y);
161
procedure TTestTrimSpace.test_cmd(ASubName: String; X, Y: Integer; Cmd: TSynEditorCommand;
162
AChar: TUTF8Char; AExp: String; AExpX: Integer; AExpY: Integer);
82
166
SynEdit.CaretXY := Point(x, y);
83
167
SynEdit.CommandProcessor(Cmd, AChar, nil);
84
test_assert('cmd: '+ASubName, AExp, AExpX, AExpY);
87
Procedure TTestTrimSpace.test_caret(ASubName: String; X, Y: Integer;
88
AExp: String = ''; AExpX: Integer = -1; AExpY: Integer = -1);
169
test_add_undo(Cmd, True);
170
test_assert('cmd: '+ASubName, AExp, AExpX, AExpY);
173
procedure TTestTrimSpace.test_cmd(ASubName: String; Cmd: TSynEditorCommand;
174
AExp: array of String; AExpX: Integer; AExpY: Integer; SkipAddUndo: Boolean);
176
if not SkipAddUndo then
179
SynEdit.CommandProcessor(Cmd, '', nil);
181
if not SkipAddUndo then
182
test_add_undo(Cmd, True);
183
test_assert('cmd: '+ASubName, AExp, AExpX, AExpY);
186
procedure TTestTrimSpace.test_caret(ASubName: String; X, Y: Integer; AExp: String;
187
AExpX: Integer; AExpY: Integer);
90
189
SynEdit.CaretXY := Point(x, y);
91
190
test_assert('caret: '+ASubName, AExp, AExpX, AExpY);
94
Procedure TTestTrimSpace.test_undo(ASubName: String;
95
AExp: String = ''; AExpX: Integer = -1; AExpY: Integer = -1);
193
procedure TTestTrimSpace.test_type(ASubName: String; AText: String; AExp: array of String;
194
AExpX: Integer; AExpY: Integer);
196
test_add_undo(ecChar);
197
SynEdit.TestTypeText(AText);
198
test_add_undo(ecNone, True);
199
test_assert('Typed: '+ASubName, AExp, AExpX, AExpY);
202
procedure TTestTrimSpace.test_type(ASubName: String; AText: String; X, Y: Integer;
203
AExp: array of String; AExpX: Integer; AExpY: Integer);
205
test_add_undo(ecChar);
206
SynEdit.CaretXY := Point(x, y);
207
SynEdit.TestTypeText(AText);
208
test_add_undo(ecNone, True);
209
test_assert('Typed: '+ASubName, AExp, AExpX, AExpY);
212
procedure TTestTrimSpace.test_bspace(ASubName: String; AExp: array of String; AExpX: Integer;
215
test_add_undo(ecDeleteLastChar);
216
SynEdit.CommandProcessor(ecDeleteLastChar, '', nil);
217
test_add_undo(ecNone, True);
218
test_assert('BSpace: '+ASubName, AExp, AExpX, AExpY);
221
procedure TTestTrimSpace.test_bspace(ASubName: String; X, Y: Integer; AExp: array of String;
222
AExpX: Integer; AExpY: Integer);
224
test_add_undo(ecDeleteLastChar);
225
SynEdit.CaretXY := Point(x, y);
226
SynEdit.CommandProcessor(ecDeleteLastChar, '', nil);
227
test_add_undo(ecNone, True);
228
test_assert('BSpace: '+ASubName, AExp, AExpX, AExpY);
231
procedure TTestTrimSpace.test_del(ASubName: String; AExp: array of String; AExpX: Integer;
234
test_add_undo(ecDeleteChar);
235
SynEdit.CommandProcessor(ecDeleteChar, '', nil);
236
test_add_undo(ecNone, True);
237
test_assert('Del: '+ASubName, AExp, AExpX, AExpY);
240
procedure TTestTrimSpace.test_del(ASubName: String; X, Y: Integer; AExp: array of String;
241
AExpX: Integer; AExpY: Integer);
243
test_add_undo(ecDeleteChar);
244
SynEdit.CaretXY := Point(x, y);
245
SynEdit.CommandProcessor(ecDeleteChar, '', nil);
246
test_add_undo(ecNone, True);
247
test_assert('Del: '+ASubName, AExp, AExpX, AExpY);
250
procedure TTestTrimSpace.test_undo(ASubName: String; SkipCaretTest: Boolean);
253
SynEdit.CommandProcessor(ecUndo, ' ', nil)
256
AssertTrue('Undo selftest', FUndoIndex > 0);
258
if SkipCaretTest then
259
test_assert('undo: '+ASubName, FUndoList[FUndoIndex].VTextWas,
263
test_assert('undo: '+ASubName, FUndoList[FUndoIndex].VTextWas,
264
FUndoList[FUndoIndex].CaretWas.X, FUndoList[FUndoIndex].CaretWas.Y,
268
procedure TTestTrimSpace.test_redo(ASubName: String; SkipCaretTest: Boolean);
271
SynEdit.CommandProcessor(ecRedo, ' ', nil)
274
assert(FUndoIndex < length(FRedoList));
275
if SkipCaretTest then
276
test_assert('undo: '+ASubName, FRedoList[FUndoIndex].VTextWas,
280
test_assert('undo: '+ASubName, FRedoList[FUndoIndex].VTextWas,
281
FRedoList[FUndoIndex].CaretWas.X, FRedoList[FUndoIndex].CaretWas.Y,
286
procedure TTestTrimSpace.test_undo_exp(ASubName: String; AExp: String; AExpX: Integer;
98
290
SynEdit.CommandProcessor(ecUndo, ' ', nil)
111
309
test_assert('redo: '+ASubName, AExp, AExpX, AExpY);
312
procedure TTestTrimSpace.test_redo_exp(ASubName: String; AExp: array of String;
313
AExpX: Integer; AExpY: Integer);
315
test_redo_exp(ASubName, LinesToText(AExp), AExpX, AExpY);
114
318
procedure TTestTrimSpace.TrimUndoRedo;
319
procedure UndoRedo(AMax: Integer; AName: String = ''; SkipCaretTest: Boolean = False);
325
test_undo(AName, SkipCaretTest);
326
test_redo(AName, SkipCaretTest);
330
for i := 1 to j do test_undo(Format('%s %d/%d', [AName, i, j]), SkipCaretTest);
331
for i := 1 to j do test_redo(Format('%s %d/%d', [AName, i, j]), SkipCaretTest);
338
// must have eoScrollPastEol
339
// because ForcePastEOL does not work on longest line
340
SynEdit.Options := [eoTrimTrailingSpaces, eoAutoIndent, eoScrollPastEol]; // eoScrollPastEol, eoGroupUndo
341
SynEdit.TabWidth := 6;
342
for MaxUndo := 0 to 2 do begin
343
{%region settLeaveLine }
344
SynEdit.TrimSpaceType := settLeaveLine;
347
test_start ('Append Space and text', ['', 'abc'], 4,2);
348
test_type ('Space 1', ' ', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
349
test_type ('Space 2', ' ', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
350
test_type ('Char', 'A', ['', 'abc A'], 7,2); UndoRedo(MaxUndo);
351
test_bspace('BackSpace', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
352
test_bspace('BackSpace', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
353
test_bspace('BackSpace', ['', 'abc'], 4,2); UndoRedo(MaxUndo);
356
test_start ('Append tab + Space and text', ['', 'abc'], 4,2);
357
test_type ('tab 1', #9, ['', 'abc'#9], 7,2); UndoRedo(MaxUndo);
358
test_type ('Space 2', ' ', ['', 'abc'#9' '], 8,2); UndoRedo(MaxUndo);
359
test_type ('Char', 'A', ['', 'abc'#9' A'], 9,2); UndoRedo(MaxUndo);
360
test_bspace('BackSpace', ['', 'abc'#9' '], 8,2); UndoRedo(MaxUndo);
361
test_bspace('BackSpace', ['', 'abc'#9], 7,2); UndoRedo(MaxUndo);
362
test_bspace('BackSpace', ['', 'abc'], 4,2); UndoRedo(MaxUndo);
364
// trim on leave line
365
test_start ('Append Space, move left, text, trim', ['', 'abc'], 4,2);
366
test_type ('Space 1', ' ', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
367
test_type ('Space 2', ' ', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
368
test_cmd ('caret left',ecLeft, ['', 'abc '], 5,2, True);
369
test_type ('Char', 'A', ['', 'abc A '], 6,2); UndoRedo(MaxUndo);
370
test_cmd ('caret up', ecUp, ['', 'abc A'], 6,1, True);
373
test_start ('Insert CR, and trim space before CR ', ['', 'abc def'], 5,2);
374
test_type ('CR', #13, ['', 'abc', 'def'], 1,3);
377
test_start ('Replace select by CR, and trim before sel', ['', 'abc def,123'], 5,2);
378
SetCaretAndSel(5,2, 8,2); // 'def'
379
test_type ('CR', #13, ['', 'abc', ',123'], 1,3);
382
{%endregion settLeaveLine }
384
{%region settEditLine }
385
SynEdit.TrimSpaceType := settEditLine;
388
test_start ('Append Space and text', ['', 'abc'], 4,2);
389
test_type ('Space 1', ' ', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
390
test_type ('Space 2', ' ', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
391
test_type ('Char', 'A', ['', 'abc A'], 7,2); UndoRedo(MaxUndo);
392
test_bspace('BackSpace', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
393
test_bspace('BackSpace', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
394
test_bspace('BackSpace', ['', 'abc'], 4,2); UndoRedo(MaxUndo);
397
test_start ('Append tab + Space and text', ['', 'abc'], 4,2);
398
test_type ('tab 1', #9, ['', 'abc'#9], 7,2); UndoRedo(MaxUndo);
399
test_type ('Space 2', ' ', ['', 'abc'#9' '], 8,2); UndoRedo(MaxUndo);
400
test_type ('Char', 'A', ['', 'abc'#9' A'], 9,2); UndoRedo(MaxUndo);
401
test_bspace('BackSpace', ['', 'abc'#9' '], 8,2); UndoRedo(MaxUndo);
402
test_bspace('BackSpace', ['', 'abc'#9], 7,2); UndoRedo(MaxUndo);
403
test_bspace('BackSpace', ['', 'abc'], 4,2); UndoRedo(MaxUndo);
406
test_start ('Append Space, move left, text', ['', 'abc'], 4,2);
407
test_type ('Space 1', ' ', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
408
test_type ('Space 2', ' ', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
409
test_cmd ('caret left',ecLeft, ['', 'abc '], 5,2, True);
410
test_type ('Char', 'A', ['', 'abc A'], 6,2); UndoRedo(MaxUndo); // Trimmed on Edit
411
test_cmd ('caret up', ecUp, ['', 'abc A'], 6,1, True);
414
test_start ('Insert CR, and trim space before CR ', ['', 'abc def'], 5,2);
415
test_type ('CR', #13, ['', 'abc', 'def'], 1,3);
418
test_start ('Replace select by CR, and trim before sel', ['', 'abc def,123'], 5,2);
419
SetCaretAndSel(5,2, 8,2); // 'def'
420
test_type ('CR', #13, ['', 'abc', ',123'], 1,3);
423
{%endregion settEditLine }
425
{%region settMoveCaret }
426
SynEdit.TrimSpaceType := settMoveCaret;
429
test_start ('Append Space and text', ['', 'abc'], 4,2);
430
test_type ('Space 1', ' ', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
431
test_type ('Space 2', ' ', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
432
test_type ('Char', 'A', ['', 'abc A'], 7,2); UndoRedo(MaxUndo);
433
test_bspace('BackSpace', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
434
test_bspace('BackSpace', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
435
test_bspace('BackSpace', ['', 'abc'], 4,2); UndoRedo(MaxUndo);
438
test_start ('Append tab + Space and text', ['', 'abc'], 4,2);
439
test_type ('tab 1', #9, ['', 'abc'#9], 7,2); UndoRedo(MaxUndo);
440
test_type ('Space 2', ' ', ['', 'abc'#9' '], 8,2); UndoRedo(MaxUndo);
441
test_type ('Char', 'A', ['', 'abc'#9' A'], 9,2); UndoRedo(MaxUndo);
442
test_bspace('BackSpace', ['', 'abc'#9' '], 8,2); UndoRedo(MaxUndo);
443
test_bspace('BackSpace', ['', 'abc'#9], 7,2); UndoRedo(MaxUndo);
444
test_bspace('BackSpace', ['', 'abc'], 4,2); UndoRedo(MaxUndo);
446
// trim on move caret
447
test_start ('Append Space, move left, text', ['', 'abc'], 4,2);
448
test_type ('Space 1', ' ', ['', 'abc '], 5,2); UndoRedo(MaxUndo);
449
test_type ('Space 2', ' ', ['', 'abc '], 6,2); UndoRedo(MaxUndo);
450
test_cmd ('caret left',ecLeft, ['', 'abc '], 5,2, True);
451
// TODO: Review: The spacethat was just trimmed, can be undone (leading to an undo that changes nothing)
452
test_type ('Char', 'A', ['', 'abc A'], 6,2); UndoRedo(MaxUndo); // Trimmed on Edit
453
test_cmd ('caret up', ecUp, ['', 'abc A'], 6,1, True);
454
//TODO: FAIL: This fails with MaxUndo = 2
457
test_start ('Insert CR, and trim space before CR ', ['', 'abc def'], 5,2);
458
test_type ('CR', #13, ['', 'abc', 'def'], 1,3);
461
test_start ('Replace select by CR, and trim before sel', ['', 'abc def,123'], 5,2);
462
SetCaretAndSel(5,2, 8,2); // 'def'
463
test_type ('CR', #13, ['', 'abc', ',123'], 1,3);
466
{%endregion settMoveCaret }
468
{%region settIgnoreAll }
469
SynEdit.TrimSpaceType := settIgnoreAll;
472
test_start ('Append Space and text', ['', 'abc'], 4,2);
473
test_type ('Space 1', ' ', ['', 'abc'], 5,2);
474
test_type ('Space 2', ' ', ['', 'abc'], 6,2);
475
test_type ('Char', 'A', ['', 'abc A'], 7,2);
476
if MaxUndo > 0 then begin
477
test_undo_exp('undo', ['', 'abc'], 6,2); // only undo the "A"
478
test_redo_exp('redo', ['', 'abc A'], 7,2);
480
test_bspace('BackSpace', ['', 'abc'], 6,2);
481
test_bspace('BackSpace', ['', 'abc'], 5,2);
482
test_bspace('BackSpace', ['', 'abc'], 4,2);
485
test_start ('Append tab + Space and text', ['', 'abc'], 4,2);
486
// TODO: currently tab acts as space, because Log/Phys can not work, if the tab is not present
487
test_type ('tab 1', #9, ['', 'abc'], 7,2);
488
test_type ('Space 2', ' ', ['', 'abc'], 8,2);
489
test_type ('Char', 'A', ['', 'abc A'], 9,2);
490
if MaxUndo > 0 then begin
491
test_undo_exp('undo', ['', 'abc'], 8,2); // only undo the "A"
492
test_redo_exp('redo', ['', 'abc A'], 9,2);
494
test_bspace('BackSpace', ['', 'abc'], 8,2);
495
test_bspace('BackSpace', ['', 'abc'], 7,2);
496
test_bspace('BackSpace', ['', 'abc'], 6,2);
499
test_start ('Append Space, move left, text', ['', 'abc'], 4,2);
500
test_type ('Space 1', ' ', ['', 'abc'], 5,2);
501
test_type ('Space 2', ' ', ['', 'abc'], 6,2);
502
test_cmd ('caret left',ecLeft, ['', 'abc'], 5,2, True);
503
test_type ('Char', 'A', ['', 'abc A'], 6,2);
504
test_cmd ('caret up', ecUp, ['', 'abc A'], 6,1, True);
506
test_start ('Insert CR, and trim space before CR ', ['', 'abc def'], 5,2);
507
test_type ('CR', #13, ['', 'abc', 'def'], 1,3);
510
test_start ('Replace select by CR, and trim before sel', ['', 'abc def,123'], 5,2);
511
SetCaretAndSel(5,2, 8,2); // 'def'
512
test_type ('CR', #13, ['', 'abc', ',123'], 1,3);
515
{%endregion settIgnoreAll }
116
518
SynEdit.Options := [eoTrimTrailingSpaces, eoAutoIndent, eoScrollPastEol]; // eoGroupUndo
519
SynEdit.TrimSpaceType := settLeaveLine;
121
524
test_cmd ('Backspace 6,2', 6,2, ecDeleteLastChar, '', cr+'abc ', 5,2);
122
525
test_caret('trim', 1,1, cr+'abc', 1,1);
124
//# test_undo('undo trim', cr+'abc ', 5,2);
125
test_undo('undo bspace', cr+'abc d', 6,2);
126
test_redo('redo bspace', cr+'abc ', 5,2);
527
//# test_undo_exp('undo trim', cr+'abc ', 5,2);
528
test_undo_exp('undo bspace', cr+'abc d', 6,2);
529
test_redo_exp('redo bspace', cr+'abc ', 5,2);
127
530
test_caret('trim', 1,1, cr+'abc', 1,1);
129
//# test_undo('undo trim(2)', cr+'abc ', 5,2);
130
test_undo('undo bspace(2)', cr+'abc d', 6,2);
131
test_redo('redo bspace(2)', cr+'abc ', 5,2);
132
test_redo('no redo trim(2)', cr+'abc ', 5,2);
532
//# test_undo_exp('undo trim(2)', cr+'abc ', 5,2);
533
test_undo_exp('undo bspace(2)', cr+'abc d', 6,2);
534
test_redo_exp('redo bspace(2)', cr+'abc ', 5,2);
535
test_redo_exp('no redo trim(2)', cr+'abc ', 5,2);
134
537
test_caret('trim(3)', 1,1, cr+'abc', 1,1);
135
//# test_undo('undo trim(3)', cr+'abc ', 5,2);
538
//# test_undo_exp('undo trim(3)', cr+'abc ', 5,2);
136
539
//## test_caret('trim(3)', 1,1, cr+'abc', 1,1);
139
542
test_start('insert past real space', cr+'abc ');
140
543
test_cmd ('insert 5,2', 5,2, ecChar, 'x', cr+'abc x', 6,2);
142
test_undo('undo insert', cr+'abc ', 5,2);
545
test_undo_exp('undo insert', cr+'abc ', 5,2);
143
546
test_caret('no trim', 1,1, cr+'abc ', 1,1);
144
547
// rdeo/undo again
145
test_redo('redo insert', cr+'abc x', 6,2);
146
test_undo('undo insert(2)', cr+'abc ', 5,2);
548
test_redo_exp('redo insert', cr+'abc x', 6,2);
549
test_undo_exp('undo insert(2)', cr+'abc ', 5,2);
147
550
test_caret('no trim(2)', 1,1, cr+'abc ', 1,1);
229
632
test_cmd ('insert 3,3', 3,3, ecLineBreak, ' ', cr+' ab'+cr+''+cr+' ', 3,4);
230
633
test_cmd ('insert 3,4', 3,4, ecLineBreak, ' ', cr+' ab'+cr+''+cr+''+cr+' ', 3,5);
231
634
test_caret('trim', 1,1, cr+' ab'+cr+''+cr+''+cr+'', 1,1);
232
//# test_undo('-trim', cr+' ab'+cr+''+cr+''+cr+' ', 4,5); // TODO caret at: 3,5);
233
test_undo('-newlin 1', cr+' ab'+cr+''+cr+' ', 3,4);
234
test_undo('-newlin 2', cr+' ab'+cr+' ', 3,3);
235
test_undo('-newlin 3', cr+' ab ', 5,2);
635
//# test_undo_exp('-trim', cr+' ab'+cr+''+cr+''+cr+' ', 4,5); // TODO caret at: 3,5);
636
test_undo_exp('-newlin 1', cr+' ab'+cr+''+cr+' ', 3,4);
637
test_undo_exp('-newlin 2', cr+' ab'+cr+' ', 3,3);
638
test_undo_exp('-newlin 3', cr+' ab ', 5,2);
236
639
test_caret('no trim', 1,1, cr+' ab ', 1,1);
237
test_redo('redo 3', cr+' ab'+cr+' ', 3,3);
238
test_redo('redo 2', cr+' ab'+cr+''+cr+' ', 3,4);
239
test_redo('redo 1', cr+' ab'+cr+''+cr+''+cr+' ', 3,5);
240
test_undo('-newlin 1(r)', cr+' ab'+cr+''+cr+' ', 3,4);
241
test_undo('-newlin 2(r)', cr+' ab'+cr+' ', 3,3);
242
test_undo('-newlin 3(r)', cr+' ab ', 5,2);
640
test_redo_exp('redo 3', cr+' ab'+cr+' ', 3,3);
641
test_redo_exp('redo 2', cr+' ab'+cr+''+cr+' ', 3,4);
642
test_redo_exp('redo 1', cr+' ab'+cr+''+cr+''+cr+' ', 3,5);
643
test_undo_exp('-newlin 1(r)', cr+' ab'+cr+''+cr+' ', 3,4);
644
test_undo_exp('-newlin 2(r)', cr+' ab'+cr+' ', 3,3);
645
test_undo_exp('-newlin 3(r)', cr+' ab ', 5,2);
243
646
test_caret('no trim', 1,1, cr+' ab ', 1,1);
246
649
test_start('insert linebreak', cr+'ab 1234 ');
247
650
test_cmd ('insert 4,2', 4,2, ecInsertLine, ' ', cr+'ab '+cr+'1234', 4,2);
248
651
test_caret('trim', 1,1, cr+'ab'+cr+'1234', 1,1);
249
//# test_undo('-trim', cr+'ab '+cr+'1234', 4,2);
250
test_undo('-linebreak', cr+'ab 1234 ', 4,2);
652
//# test_undo_exp('-trim', cr+'ab '+cr+'1234', 4,2);
653
test_undo_exp('-linebreak', cr+'ab 1234 ', 4,2);
251
654
test_caret('no trim', 1,1, cr+'ab 1234 ', 1,1);
288
691
test_start('del', cr+'ab '+cr+'12');
289
692
test_cmd ('del 4,2', 4,2, ecDeleteChar, ' ', cr+'ab 12', 4,2);
290
test_undo('-del', cr+'ab '+cr+'12', 4,2);
693
test_undo_exp('-del', cr+'ab '+cr+'12', 4,2);
291
694
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
292
test_redo('+del', cr+'ab 12', 4,2);
293
test_undo('-del(2)', cr+'ab '+cr+'12', 4,2);
695
test_redo_exp('+del', cr+'ab 12', 4,2);
696
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 4,2);
294
697
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
297
700
test_start('del (both sp)', cr+'ab '+cr+'12 ');
298
701
test_cmd ('del 4,2', 4,2, ecDeleteChar, ' ', cr+'ab 12 ', 4,2);
299
test_undo('-del', cr+'ab '+cr+'12 ', 4,2);
702
test_undo_exp('-del', cr+'ab '+cr+'12 ', 4,2);
300
703
test_caret('trim', 1,1, cr+'ab '+cr+'12 ', 1,1);
301
test_redo('+del', cr+'ab 12 ', 4,2);
302
test_undo('-del(2)', cr+'ab '+cr+'12 ', 4,2);
704
test_redo_exp('+del', cr+'ab 12 ', 4,2);
705
test_undo_exp('-del(2)', cr+'ab '+cr+'12 ', 4,2);
303
706
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12 ', 1,1);
306
709
test_start('del past eol', cr+'ab '+cr+'12');
307
710
test_cmd ('del 6,2', 6,2, ecDeleteChar, ' ', cr+'ab 12', 6,2);
308
test_undo('-del', cr+'ab '+cr+'12', 6,2);
711
test_undo_exp('-del', cr+'ab '+cr+'12', 6,2);
309
712
test_caret('no trim', 1,1, cr+'ab '+cr+'12', 1,1);
310
713
test_caret('-no trim', 6,2, cr+'ab '+cr+'12', 6,2);
311
test_redo('+del(2)', cr+'ab 12', 6,2);
312
test_undo('-del(2)', cr+'ab '+cr+'12', 6,2);
714
test_redo_exp('+del(2)', cr+'ab 12', 6,2);
715
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 6,2);
313
716
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
314
test_redo('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret
717
test_redo_exp('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret
317
720
test_start('backspace', cr+'ab '+cr+'12');
318
721
test_cmd ('bs 1,3', 1,3, ecDeleteLastChar, ' ', cr+'ab 12', 4,2);
319
test_undo('-bs', cr+'ab '+cr+'12', 1,3);
722
test_undo_exp('-bs', cr+'ab '+cr+'12', 1,3);
320
723
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
321
test_redo('+bs', cr+'ab 12', 4,2);
322
test_undo('-bs(2)', cr+'ab '+cr+'12', 1,3);
724
test_redo_exp('+bs', cr+'ab 12', 4,2);
725
test_undo_exp('-bs(2)', cr+'ab '+cr+'12', 1,3);
323
726
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
326
729
test_start('del-word', cr+'ab '+cr+'12');
327
730
test_cmd ('del 4,2', 4,2, ecDeleteWord, ' ', cr+'ab 12', 4,2);
328
test_undo('-del', cr+'ab '+cr+'12', 4,2);
731
test_undo_exp('-del', cr+'ab '+cr+'12', 4,2);
329
732
test_caret('no trim', 1,1, cr+'ab '+cr+'12', 1,1);
330
test_redo('+del', cr+'ab 12', 4,2);
331
test_undo('-del(2)', cr+'ab '+cr+'12', 4,2);
733
test_redo_exp('+del', cr+'ab 12', 4,2);
734
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 4,2);
332
735
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
335
738
test_start('del-word (both sp)', cr+'ab '+cr+'12 ');
336
739
test_cmd ('del 4,2', 4,2, ecDeleteWord, ' ', cr+'ab 12 ', 4,2);
337
740
(* xxxxxxxxxxxxxxx
338
test_undo('-del', cr+'ab '+cr+'12 ', 4,2);
741
test_undo_exp('-del', cr+'ab '+cr+'12 ', 4,2);
339
742
test_caret('trim', 1,1, cr+'ab '+cr+'12 ', 1,1);
340
test_redo('+del', cr+'ab 12 ', 4,2);
341
test_undo('-del(2)', cr+'ab '+cr+'12 ', 4,2);
743
test_redo_exp('+del', cr+'ab 12 ', 4,2);
744
test_undo_exp('-del(2)', cr+'ab '+cr+'12 ', 4,2);
342
745
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12 ', 1,1);
346
749
test_start('del-word past eol', cr+'ab '+cr+'12');
347
750
test_cmd ('del 6,2', 6,2, ecDeleteWord, ' ', cr+'ab 12', 6,2);
348
test_undo('-del', cr+'ab '+cr+'12', 6,2);
751
test_undo_exp('-del', cr+'ab '+cr+'12', 6,2);
349
752
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
350
753
test_caret('-trim', 6,2, cr+'ab '+cr+'12', 6,2);
351
test_redo('+del(2)', cr+'ab 12', 6,2);
352
test_undo('-del(2)', cr+'ab '+cr+'12', 6,2);
754
test_redo_exp('+del(2)', cr+'ab 12', 6,2);
755
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 6,2);
353
756
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
354
test_redo('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret
757
test_redo_exp('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret
460
863
test_start('del', cr+'ab '+cr+'12');
461
864
test_cmd ('del 4,2', 4,2, ecDeleteChar, ' ', cr+'ab 12', 4,2);
462
test_undo('-del', cr+'ab '+cr+'12', 4,2);
865
test_undo_exp('-del', cr+'ab '+cr+'12', 4,2);
463
866
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
464
test_redo('+del', cr+'ab 12', 4,2);
465
test_undo('-del(2)', cr+'ab '+cr+'12', 4,2);
867
test_redo_exp('+del', cr+'ab 12', 4,2);
868
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 4,2);
466
869
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
469
872
test_start('del (both sp)', cr+'ab '+cr+'12 ');
470
873
test_cmd ('del 4,2', 4,2, ecDeleteChar, ' ', cr+'ab 12 ', 4,2);
471
test_undo('-del', cr+'ab '+cr+'12 ', 4,2);
874
test_undo_exp('-del', cr+'ab '+cr+'12 ', 4,2);
472
875
test_caret('trim', 1,1, cr+'ab '+cr+'12 ', 1,1);
473
test_redo('+del', cr+'ab 12 ', 4,2);
474
test_undo('-del(2)', cr+'ab '+cr+'12 ', 4,2);
876
test_redo_exp('+del', cr+'ab 12 ', 4,2);
877
test_undo_exp('-del(2)', cr+'ab '+cr+'12 ', 4,2);
475
878
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12 ', 1,1);
478
881
test_start('del past eol', cr+'ab '+cr+'12');
479
882
test_cmd ('del 6,2', 6,2, ecDeleteChar, ' ', cr+'ab 12', 6,2);
480
test_undo('-del', cr+'ab '+cr+'12', 6,2);
883
test_undo_exp('-del', cr+'ab '+cr+'12', 6,2);
481
884
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
482
885
test_caret('-trim', 6,2, cr+'ab '+cr+'12', 6,2);
484
test_redo('+del(2)', cr+'ab 12', 6,2);
485
test_undo('-del(2)', cr+'ab '+cr+'12', 6,2);
887
test_redo_exp('+del(2)', cr+'ab 12', 6,2);
888
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 6,2);
486
889
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
487
test_redo('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret
890
test_redo_exp('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret
491
894
test_start('backspace', cr+'ab '+cr+'12');
492
895
test_cmd ('bs 1,3', 1,3, ecDeleteLastChar, ' ', cr+'ab 12', 4,2);
493
test_undo('-bs', cr+'ab '+cr+'12', 1,3);
896
test_undo_exp('-bs', cr+'ab '+cr+'12', 1,3);
494
897
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
495
test_redo('+bs', cr+'ab 12', 4,2);
496
test_undo('-bs(2)', cr+'ab '+cr+'12', 1,3);
898
test_redo_exp('+bs', cr+'ab 12', 4,2);
899
test_undo_exp('-bs(2)', cr+'ab '+cr+'12', 1,3);
497
900
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
500
903
test_start('del-word', cr+'ab '+cr+'12');
501
904
test_cmd ('del 4,2', 4,2, ecDeleteWord, ' ', cr+'ab 12', 4,2);
502
test_undo('-del', cr+'ab '+cr+'12', 4,2);
905
test_undo_exp('-del', cr+'ab '+cr+'12', 4,2);
503
906
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
504
test_redo('+del', cr+'ab 12', 4,2);
505
test_undo('-del(2)', cr+'ab '+cr+'12', 4,2);
907
test_redo_exp('+del', cr+'ab 12', 4,2);
908
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 4,2);
506
909
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
509
912
test_start('del-word (both sp)', cr+'ab '+cr+'12 ');
510
913
test_cmd ('del 4,2', 4,2, ecDeleteWord, ' ', cr+'ab 12 ', 4,2);
511
test_undo('-del', cr+'ab '+cr+'12 ', 4,2);
914
test_undo_exp('-del', cr+'ab '+cr+'12 ', 4,2);
512
915
test_caret('trim', 1,1, cr+'ab '+cr+'12 ', 1,1);
513
test_redo('+del', cr+'ab 12 ', 4,2);
514
test_undo('-del(2)', cr+'ab '+cr+'12 ', 4,2);
916
test_redo_exp('+del', cr+'ab 12 ', 4,2);
917
test_undo_exp('-del(2)', cr+'ab '+cr+'12 ', 4,2);
515
918
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12 ', 1,1);
518
921
test_start('del-word past eol', cr+'ab '+cr+'12');
519
922
test_cmd ('del 6,2', 6,2, ecDeleteWord, ' ', cr+'ab 12', 6,2);
520
test_undo('-del', cr+'ab '+cr+'12', 6,2);
923
test_undo_exp('-del', cr+'ab '+cr+'12', 6,2);
521
924
test_caret('trim', 1,1, cr+'ab '+cr+'12', 1,1);
522
925
test_caret('-trim', 6,2, cr+'ab '+cr+'12', 6,2);
523
test_redo('+del(2)', cr+'ab 12', 6,2);
524
test_undo('-del(2)', cr+'ab '+cr+'12', 6,2);
926
test_redo_exp('+del(2)', cr+'ab 12', 6,2);
927
test_undo_exp('-del(2)', cr+'ab '+cr+'12', 6,2);
525
928
test_caret('trim(2)', 1,1, cr+'ab '+cr+'12', 1,1);
526
test_redo('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret
929
test_redo_exp('+del(3)', cr+'ab 12', 6,2); // redo with mis-place caret