@@ -237,14 +237,11 @@ public static void DeleteToEnd(ConsoleKeyInfo? key = null, object arg = null)
237
237
var length = endPosition - startPosition + 1 ;
238
238
if ( length > 0 )
239
239
{
240
- _clipboard . Record ( _singleton . _buffer , startPosition , length ) ;
241
- _singleton . SaveEditItem ( EditItemDelete . Create (
242
- _clipboard ,
243
- _singleton . _current ,
240
+ _singleton . RemoveTextToViRegister (
241
+ startPosition ,
242
+ length ,
244
243
DeleteToEnd ,
245
- arg ) ) ;
246
-
247
- _singleton . _buffer . Remove ( _singleton . _current , length ) ;
244
+ arg ) ;
248
245
249
246
// the cursor will go back one character, unless at the beginning of the line
250
247
var endOfLineCursorPos = GetEndOfLogicalLinePos ( _singleton . _current ) - 1 ;
@@ -282,14 +279,12 @@ public static void DeleteWord(ConsoleKeyInfo? key = null, object arg = null)
282
279
283
280
private static void DeleteToEndPoint ( object arg , int endPoint , Action < ConsoleKeyInfo ? , object > instigator )
284
281
{
285
- _singleton . SaveToClipboard ( _singleton . _current , endPoint - _singleton . _current ) ;
286
- _singleton . SaveEditItem ( EditItemDelete . Create (
287
- _clipboard ,
282
+ _singleton . RemoveTextToViRegister (
288
283
_singleton . _current ,
284
+ endPoint - _singleton . _current ,
289
285
instigator ,
290
- arg
291
- ) ) ;
292
- _singleton . _buffer . Remove ( _singleton . _current , endPoint - _singleton . _current ) ;
286
+ arg ) ;
287
+
293
288
if ( _singleton . _current >= _singleton . _buffer . Length )
294
289
{
295
290
_singleton . _current = Math . Max ( 0 , _singleton . _buffer . Length - 1 ) ;
@@ -301,14 +296,12 @@ private static void DeleteBackwardToEndPoint(object arg, int endPoint, Action<Co
301
296
{
302
297
int deleteLength = _singleton . _current - endPoint ;
303
298
304
- _singleton . SaveToClipboard ( endPoint , deleteLength ) ;
305
- _singleton . SaveEditItem ( EditItemDelete . Create (
306
- _clipboard ,
299
+ _singleton . RemoveTextToViRegister (
307
300
endPoint ,
301
+ deleteLength ,
308
302
instigator ,
309
- arg
310
- ) ) ;
311
- _singleton . _buffer . Remove ( endPoint , deleteLength ) ;
303
+ arg ) ;
304
+
312
305
_singleton . _current = endPoint ;
313
306
_singleton . Render ( ) ;
314
307
}
@@ -324,21 +317,8 @@ public static void ViDeleteGlob(ConsoleKeyInfo? key = null, object arg = null)
324
317
{
325
318
endPoint = _singleton . ViFindNextGlob ( endPoint ) ;
326
319
}
327
- int length = endPoint - _singleton . _current ;
328
320
329
- _singleton . SaveToClipboard ( _singleton . _current , length ) ;
330
- _singleton . SaveEditItem ( EditItemDelete . Create (
331
- _clipboard ,
332
- _singleton . _current ,
333
- ViDeleteGlob ,
334
- arg
335
- ) ) ;
336
- _singleton . _buffer . Remove ( _singleton . _current , length ) ;
337
- if ( _singleton . _current >= _singleton . _buffer . Length )
338
- {
339
- _singleton . _current = Math . Max ( 0 , _singleton . _buffer . Length - 1 ) ;
340
- }
341
- _singleton . Render ( ) ;
321
+ DeleteToEndPoint ( arg , endPoint , ViDeleteGlob ) ;
342
322
}
343
323
344
324
/// <summary>
@@ -358,19 +338,8 @@ public static void DeleteEndOfWord(ConsoleKeyInfo? key = null, object arg = null
358
338
Ding ( ) ;
359
339
return ;
360
340
}
361
- _singleton . SaveToClipboard ( _singleton . _current , 1 + endPoint - _singleton . _current ) ;
362
- _singleton . SaveEditItem ( EditItemDelete . Create (
363
- _clipboard ,
364
- _singleton . _current ,
365
- DeleteEndOfWord ,
366
- arg
367
- ) ) ;
368
- _singleton . _buffer . Remove ( _singleton . _current , 1 + endPoint - _singleton . _current ) ;
369
- if ( _singleton . _current >= _singleton . _buffer . Length )
370
- {
371
- _singleton . _current = Math . Max ( 0 , _singleton . _buffer . Length - 1 ) ;
372
- }
373
- _singleton . Render ( ) ;
341
+
342
+ DeleteToEndPoint ( arg , 1 + endPoint , DeleteEndOfWord ) ;
374
343
}
375
344
376
345
/// <summary>
@@ -385,19 +354,7 @@ public static void ViDeleteEndOfGlob(ConsoleKeyInfo? key = null, object arg = nu
385
354
endPoint = _singleton . ViFindGlobEnd ( endPoint ) ;
386
355
}
387
356
388
- _singleton . SaveToClipboard ( _singleton . _current , 1 + endPoint - _singleton . _current ) ;
389
- _singleton . SaveEditItem ( EditItemDelete . Create (
390
- _clipboard ,
391
- _singleton . _current ,
392
- ViDeleteEndOfGlob ,
393
- arg
394
- ) ) ;
395
- _singleton . _buffer . Remove ( _singleton . _current , 1 + endPoint - _singleton . _current ) ;
396
- if ( _singleton . _current >= _singleton . _buffer . Length )
397
- {
398
- _singleton . _current = Math . Max ( 0 , _singleton . _buffer . Length - 1 ) ;
399
- }
400
- _singleton . Render ( ) ;
357
+ DeleteToEndPoint ( arg , 1 + endPoint , ViDeleteEndOfGlob ) ;
401
358
}
402
359
403
360
/// <summary>
@@ -724,10 +681,12 @@ public static void DeleteLineToFirstChar(ConsoleKeyInfo? key = null, object arg
724
681
{
725
682
var i = GetFirstNonBlankOfLogicalLinePos ( _singleton . _current ) ;
726
683
727
- _singleton . SaveToClipboard ( i , _singleton . _current - i ) ;
728
- _singleton . SaveEditItem ( EditItemDelete . Create ( _clipboard , i , DeleteLineToFirstChar ) ) ;
684
+ _singleton . RemoveTextToViRegister (
685
+ i ,
686
+ _singleton . _current - i ,
687
+ DeleteLineToFirstChar ,
688
+ arg ) ;
729
689
730
- _singleton . _buffer . Remove ( i , _singleton . _current - i ) ;
731
690
_singleton . _current = i ;
732
691
_singleton . Render ( ) ;
733
692
}
@@ -775,7 +734,7 @@ private static int DeleteLineImpl(int lineIndex, int lineCount)
775
734
776
735
var deleteText = _singleton . _buffer . ToString ( range . Offset , range . Count ) ;
777
736
778
- _clipboard . LinewiseRecord ( deleteText ) ;
737
+ _viRegister . LinewiseRecord ( deleteText ) ;
779
738
780
739
var deletePosition = range . Offset ;
781
740
var anchor = _singleton . _current ;
@@ -890,14 +849,12 @@ public static void BackwardDeleteWord(ConsoleKeyInfo? key = null, object arg = n
890
849
Ding ( ) ;
891
850
return ;
892
851
}
893
- _clipboard . Record ( _singleton . _buffer , deletePoint , _singleton . _current - deletePoint ) ;
894
- _singleton . SaveEditItem ( EditItemDelete . Create (
895
- _clipboard ,
852
+ _singleton . RemoveTextToViRegister (
896
853
deletePoint ,
854
+ _singleton . _current - deletePoint ,
897
855
BackwardDeleteWord ,
898
- arg
899
- ) ) ;
900
- _singleton . _buffer . Remove ( deletePoint , _singleton . _current - deletePoint ) ;
856
+ arg ) ;
857
+
901
858
_singleton . _current = deletePoint ;
902
859
_singleton . Render ( ) ;
903
860
}
@@ -923,14 +880,12 @@ public static void ViBackwardDeleteGlob(ConsoleKeyInfo? key = null, object arg =
923
880
Ding ( ) ;
924
881
return ;
925
882
}
926
- _clipboard . Record ( _singleton . _buffer , deletePoint , _singleton . _current - deletePoint ) ;
927
- _singleton . SaveEditItem ( EditItemDelete . Create (
928
- _clipboard ,
883
+ _singleton . RemoveTextToViRegister (
929
884
deletePoint ,
885
+ _singleton . _current - deletePoint ,
930
886
BackwardDeleteWord ,
931
- arg
932
- ) ) ;
933
- _singleton . _buffer . Remove ( deletePoint , _singleton . _current - deletePoint ) ;
887
+ arg ) ;
888
+
934
889
_singleton . _current = deletePoint ;
935
890
_singleton . Render ( ) ;
936
891
}
@@ -966,10 +921,12 @@ private static void DeleteRange(int first, int last, Action<ConsoleKeyInfo?, obj
966
921
{
967
922
int length = last - first + 1 ;
968
923
969
- _singleton . SaveToClipboard ( first , length ) ;
970
- _singleton . SaveEditItem ( EditItemDelete . Create ( _clipboard , first , action ) ) ;
924
+ _singleton . RemoveTextToViRegister (
925
+ first ,
926
+ length ,
927
+ action ) ;
928
+
971
929
_singleton . _current = first ;
972
- _singleton . _buffer . Remove ( first , length ) ;
973
930
_singleton . Render ( ) ;
974
931
}
975
932
0 commit comments