Browse Source

add comments

xuty 4 năm trước cách đây
mục cha
commit
22ece52e53
3 tập tin đã thay đổi với 44 bổ sung12 xóa
  1. 7 0
      lib/terminal/ansi.dart
  2. 12 1
      lib/terminal/csi.dart
  3. 25 11
      lib/terminal/terminal.dart

+ 7 - 0
lib/terminal/ansi.dart

@@ -58,6 +58,13 @@ void _ansiRestoreCursorHandler(Queue<int> queue, Terminal terminal) {
   terminal.buffer.restoreCursor();
 }
 
+/// https://vt100.net/docs/vt100-ug/chapter3.html#IND IND – Index
+///
+/// ESC D  
+///
+/// This sequence causes the active position to move downward one line without
+/// changing the column position. If the active position is at the bottom
+/// margin, a scroll up is performed.
 void _ansiIndexHandler(Queue<int> queue, Terminal terminal) {
   terminal.buffer.index();
 }

+ 12 - 1
lib/terminal/csi.dart

@@ -15,7 +15,7 @@ final _csiHandlers = <int, CsiSequenceHandler>{
   'l'.codeUnitAt(0): csiModeHandler,
   'm'.codeUnitAt(0): sgrHandler,
   'n'.codeUnitAt(0): csiDeviceStatusReportHandler,
-  'r'.codeUnitAt(0): csiSetMarginsHandler,
+  'r'.codeUnitAt(0): csiSetMarginsHandler, // DECSTBM
   't'.codeUnitAt(0): csiWindowManipulation,
   'A'.codeUnitAt(0): csiCursorUpHandler,
   'B'.codeUnitAt(0): csiCursorDownHandler,
@@ -266,6 +266,17 @@ void csiCursorDownHandler(CSI csi, Terminal terminal) {
   terminal.buffer.movePosition(0, distance);
 }
 
+/// DECSTBM – Set Top and Bottom Margins (DEC Private) 
+///
+/// ESC [ Pn; Pn r
+///
+/// This sequence sets the top and bottom margins to define the scrolling
+/// region. The first parameter is the line number of the first line in the
+/// scrolling region; the second parameter is the line number of the bottom line
+/// in the scrolling region. Default is the en tire screen (no margins). The
+/// minimum size of the scrolling region allowed is two lines, i.e., the top
+/// margin must be less than the bottom margin. The cursor is placed in the home
+/// position (see Origin Mode DECOM).  
 void csiSetMarginsHandler(CSI csi, Terminal terminal) {
   var top = 1;
   var bottom = terminal.viewHeight;

+ 25 - 11
lib/terminal/terminal.dart

@@ -46,8 +46,6 @@ class Terminal with Observable {
     _buffer = _mainBuffer;
 
     tabs.reset();
-
-    // _buffer.write('this is magic!');
   }
 
   bool _dirty = false;
@@ -86,10 +84,8 @@ class Terminal with Observable {
   /// You can set or reset insert/replace mode as follows.
   bool _replaceMode = true;
 
-  bool _lineFeed = true;
   bool _screenMode = false; // DECSCNM (black on white background)
   bool _autoWrapMode = true;
-  bool _bracketedPasteMode = false;
 
   /// DECOM – Origin Mode (DEC Private)
   ///
@@ -113,16 +109,34 @@ class Terminal with Observable {
   bool get originMode => _originMode;
   bool _originMode = false;
 
-  bool get lineFeed => _lineFeed;
-  bool get newLineMode => !_lineFeed;
+  /// LNM – Line Feed/New Line Mode
+  ///
+  /// This is a parameter applicable to set mode (SM) and reset mode (RM)
+  /// control sequences. The reset state causes the interpretation of the line
+  /// feed (LF), defined in ANSI Standard X3.4-1977, to imply only vertical
+  /// movement of the active position and causes the RETURN key (CR) to send the
+  /// single code CR. The set state causes the LF to imply movement to the first
+  /// position of the following line and causes the RETURN key to send the two
+  /// codes (CR, LF). This is the New Line (NL) option.
+  ///
+  /// This mode does not affect the index (IND), or next line (NEL) format
+  /// effectors.
+  bool get lineFeedMode => _lineFeedMode;
+  bool _lineFeedMode = true;
+
+  /// See: [lineFeedMode]
+  bool get newLineMode => !_lineFeedMode;
+
+  bool _bracketedPasteMode = false;
   bool get bracketedPasteMode => _bracketedPasteMode;
 
   bool _showCursor = true;
-  bool _applicationCursorKeys = false;
-  bool _blinkingCursor = true;
-
   bool get showCursor => _showCursor;
+
+  bool _applicationCursorKeys = false;
   bool get applicationCursorKeys => _applicationCursorKeys;
+
+  bool _blinkingCursor = true;
   bool get blinkingCursor => _blinkingCursor;
 
   late Buffer _buffer;
@@ -253,11 +267,11 @@ class Terminal with Observable {
   }
 
   void setNewLineMode() {
-    _lineFeed = false;
+    _lineFeedMode = false;
   }
 
   void setLineFeedMode() {
-    _lineFeed = true;
+    _lineFeedMode = true;
   }
 
   void setMouseMode(MouseMode mode) {