Эх сурвалжийг харах

Turns out that we should not set the automatic conversion of newlines
into newline + carriage return by default. This broke Emacs rendering, and it
is not the baseline setting that we should have.

For some reason, this has been carried for a while, a bug I introduced
in 2019 in XtermSharp when I commited the change in
0281d198c596063c40c5f1de514ed1bc9dff7def with the message "Small
fixes". This code did not appear on xterm.js as far as I can tell.

Miguel de Icaza 4 жил өмнө
parent
commit
3961216c1b

+ 16 - 5
Sources/SwiftTerm/Terminal.swift

@@ -289,7 +289,7 @@ open class Terminal {
     var scrollInvariantRefreshStart = Int.max
     var scrollInvariantRefreshEnd = -1
     var userScrolling = false
-    var lineFeedMode = true
+    var lineFeedMode = false
     
     // Installed colors are the 16 values that can be changed dynamically by the host
     var installedColors: [Color]
@@ -3103,9 +3103,14 @@ open class Terminal {
     {
         if collect == [] {
             switch (par) {
+            case 2:
+                // KAM mode - unlocks the keyboard, not supported
+                break
             case 4:
+                // IRM Insert/Replace Mode
                 insertMode = false
             case 20:
+                // LNM—Line Feed/New Line Mode
                 lineFeedMode = false
                 break
             default:
@@ -3194,7 +3199,7 @@ open class Terminal {
                 bracketedPasteMode = false
                 break
             default:
-                log ("Unhandled ? resetMode with \(par) and \(collect)")
+                log ("Unhandled DEC Private Mode Reset (DECRST) with \(par)")
                 break
             }
         }
@@ -3305,10 +3310,16 @@ open class Terminal {
     {
         if (collect == []) {
             switch par {
+            case 2:
+                // KAM mode - unlocks the keyboard, I do not want to support it
+                break
             case 4:
-                //Console.WriteLine ("This needs to handle the replace mode as well");
+                // IRM Insert/Replace Mode
                 // https://vt100.net/docs/vt510-rm/IRM.html
                 insertMode = true
+//            case 12:
+//                 SRM—Local Echo: Send/Receive Mode
+//                break
             case 20:
                 // Automatic New Line (LNM)
                 lineFeedMode = true
@@ -3419,11 +3430,11 @@ open class Terminal {
                 // TODO: must implement bracketed paste mode
                 bracketedPasteMode = true
             default:
-                log ("Unhandled ? setMode with \(par) and \(collect)")
+                log ("Unhandled DEC Private Mode Set (DECSET) with \(par)")
                 break;
             }
         } else {
-            log ("Unhandled setMode with \(par) and \(collect)")
+            log ("Unhandled setMode (SM) with \(par) and \(collect)")
         }
         
     }

+ 2 - 2
Sources/SwiftTerm/TerminalOptions.swift

@@ -25,7 +25,7 @@ public struct TerminalOptions {
     public var cols: Int
     /// Desired number of rows at startup (default 25)
     public var rows: Int
-    /// Controls whether a Line-Feed character will also behave like a carriage return (true) or not (false).  defaults to true)
+    /// Controls whether a Line-Feed character will also behave like a carriage return (true) or not (false).  defaults to false)
     public var convertEol: Bool
     /// Desired value for the terminal name, defaults to xterm-color
     public var termName: String
@@ -43,7 +43,7 @@ public struct TerminalOptions {
     /// Default options
     public static let `default` = TerminalOptions.init(cols: 80,
                                                        rows: 25,
-                                                       convertEol: true,
+                                                       convertEol: false,
                                                        termName: "xterm-256color",
                                                        cursorStyle: .blinkBlock,
                                                        screenReaderMode: false,

+ 2 - 2
Tests/SwiftTermTests/UnicodeTests.swift

@@ -22,7 +22,7 @@ final class SwiftTermUnicode: XCTestCase {
         // "r" and COMBINING DIAERESIS
         // "a" and COMBINING RIGHT HARPOON ABOVE
         //
-        t.feed (text: "\u{39b}\u{30a}\nv\u{307}\nr\u{308}\na\u{20d1}\nb\u{20d1}")
+        t.feed (text: "\u{39b}\u{30a}\r\nv\u{307}\r\nr\u{308}\r\na\u{20d1}\r\nb\u{20d1}")
         
         XCTAssertEqual(t.getCharacter (col:0, row: 0), "Λ̊")
         XCTAssertEqual(t.getCharacter (col:0, row: 1), "v̇")
@@ -38,7 +38,7 @@ final class SwiftTermUnicode: XCTestCase {
         let t = h.terminal!
 
         // This sends emoji, and emoji with skin colors:
-        t.feed (text: "👦🏻\n👦🏿\n")
+        t.feed (text: "👦🏻\r\n👦🏿\r\n")
         XCTAssertEqual(t.getCharacter (col:0, row: 0), "👦")
         XCTAssertEqual(t.getCharacter (col:1, row: 0), "🏻")
         XCTAssertEqual(t.getCharacter (col:0, row: 1), "👦")