Skip to content

Commit

Permalink
Report Sixel through the proper channels
Browse files Browse the repository at this point in the history
  • Loading branch information
migueldeicaza committed Apr 23, 2021
1 parent 9684765 commit f215628
Show file tree
Hide file tree
Showing 33 changed files with 122 additions and 74 deletions.
27 changes: 21 additions & 6 deletions Sources/SwiftTerm/Terminal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3531,6 +3531,7 @@ open class Terminal {
// tures the terminal supports:
// Ps = 1 -> 132-columns.
// Ps = 2 -> Printer.
// Ps = 4 -> Sixel graphics
// Ps = 6 -> Selective erase.
// Ps = 8 -> User-defined keys.
// Ps = 9 -> National replacement character sets.
Expand Down Expand Up @@ -3558,27 +3559,41 @@ open class Terminal {
func cmdSendDeviceAttributes (_ pars: [Int], collect: cstring)
{
if pars.count > 0 && pars [0] > 0 {
log ("SendDeviceAttribuets got \(pars) and \(String(cString: collect))")
log ("SendDeviceAttributes got \(pars) and \(String(cString: collect))")
return
}

if collect == [UInt8 (ascii: ">")] || collect == [UInt8 (ascii: ">"), UInt8 (ascii: "0")] {
// DA2 Secondary Device Attributes
if pars.count == 0 || pars [0] == 0 {
let vt510 = 61 // we identified as a vt510
let vt525 = 65 // we identified as a vt525
let kbd = 1 // PC-style keyboard
sendResponse(cc.CSI, ">\(vt510);20;\(kbd)c")
sendResponse(cc.CSI, ">\(vt525);20;\(kbd)c")
return
}
log ("Got a CSI > c with an unknown set of argument")
return
}

// We should use a terminal emulation level, and not rely on the TERM name
// for now, "xterm" as a part of the name surfaces all the capabilities.
let name = options.termName
if collect == [] {
if name.hasPrefix("xterm") || name.hasPrefix ("rxvt-unicode") || name.hasPrefix("screen") {
sendResponse (cc.CSI, "?1;2c")
let termVt525 = 65
let sixel = options.enableSixelReported ? ";6" : ""
let cols132 = 1
let printer = 2
let decsera = 6
let horizontalScrolling = 21
let ansiColor = 22

// Send Device Attributes (Primary DA).1
if name.hasPrefix("xterm") {
sendResponse (cc.CSI, "?\(termVt525)\(sixel);\(cols132);\(printer);\(decsera);\(horizontalScrolling);\(ansiColor)c")
} else if name.hasPrefix("screen") || name.hasPrefix ("rxvt-unicode") {
sendResponse (cc.CSI, "?\(cols132);\(printer)c")
} else if name.hasPrefix ("linux") {
sendResponse (cc.CSI, "?6c")
sendResponse (cc.CSI, "?\(decsera)c")
}
} else if collect.count == 1 && collect [0] == UInt8 (ascii: ">") {
// xterm and urxvt
Expand Down
11 changes: 8 additions & 3 deletions Sources/SwiftTerm/TerminalOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public struct TerminalOptions {
public var scrollback: Int
/// Default size of the tabs, defaults to 8
public var tabStopWidth: Int

/// Whether to report that sixel support is present
public var enableSixelReported:Bool

/// Default options
public static let `default` = TerminalOptions.init(cols: 80,
rows: 25,
Expand All @@ -46,9 +48,11 @@ public struct TerminalOptions {
cursorStyle: .blinkBlock,
screenReaderMode: false,
scrollback: 500,
tabStopWidth: 8)
tabStopWidth: 8,
enableSixelReported: true)

public init(cols: Int = Self.default.cols, rows: Int = Self.default.rows, convertEol: Bool = Self.default.convertEol, termName: String = Self.default.termName, cursorStyle: CursorStyle = Self.default.cursorStyle, screenReaderMode: Bool = Self.default.screenReaderMode, scrollback: Int = Self.default.scrollback, tabStopWidth: Int = Self.default.tabStopWidth) {
public init(cols: Int = Self.default.cols, rows: Int = Self.default.rows, convertEol: Bool = Self.default.convertEol, termName: String = Self.default.termName, cursorStyle: CursorStyle = Self.default.cursorStyle, screenReaderMode: Bool = Self.default.screenReaderMode, scrollback: Int = Self.default.scrollback, tabStopWidth: Int = Self.default.tabStopWidth,
enableSixelReported: Bool = Self.default.enableSixelReported) {
self.cols = cols
self.rows = rows
self.convertEol = convertEol
Expand All @@ -57,5 +61,6 @@ public struct TerminalOptions {
self.screenReaderMode = screenReaderMode
self.scrollback = scrollback
self.tabStopWidth = tabStopWidth
self.enableSixelReported = enableSixelReported
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
{
"images" : [
{
"filename" : "16.png",
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "32.png",
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "128.png",
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "256.png",
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "512.png",
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
6 changes: 3 additions & 3 deletions TerminalApp/MacTerminal/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,98 +1,116 @@
{
"images" : [
{
"filename" : "iPhone_Notifications_20_2x.png",
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "iPhone_Notifications_20_3x.png",
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
"scale" : "3x",
"size" : "20x20"
},
{
"filename" : "iPhone_Settings_29_2x.png",
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"filename" : "iPhone_Settings_29_3x.png",
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"filename" : "iPhone_Spotlight_40_2x.png",
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "iPhone_Spotlight_40_3x.png",
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "40x40"
},
{
"filename" : "iPhone_App_60_2x.png",
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
"scale" : "2x",
"size" : "60x60"
},
{
"filename" : "iPhone_App_60_3x.png",
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "60x60"
},
{
"filename" : "iPad_Notifications_20_1x.png",
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
"scale" : "1x",
"size" : "20x20"
},
{
"filename" : "iPad_Notifications_20_2x.png",
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "iPad_Settings_29_1x.png",
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
"scale" : "1x",
"size" : "29x29"
},
{
"filename" : "iPad_Settings_29_2x.png",
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"filename" : "iPad_Spotlight_40_1x.png",
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
"scale" : "1x",
"size" : "40x40"
},
{
"filename" : "iPad_Pro_Spotlight_40_2x.png",
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "iPad_App_76_1x.png",
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
"scale" : "1x",
"size" : "76x76"
},
{
"filename" : "iPad_App_76_2x.png",
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
"scale" : "2x",
"size" : "76x76"
},
{
"filename" : "iPad_Pro_App_83.5_2x.png",
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"filename" : "App_store_1024_1x.png",
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f215628

Please sign in to comment.