TerminalViewDelegate.swift 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // TerminalViewDelegate.swift
  3. //
  4. //
  5. // Created by Miguel de Icaza on 4/15/20.
  6. //
  7. #if os(iOS) || os(macOS)
  8. import Foundation
  9. public protocol TerminalViewDelegate: class {
  10. /**
  11. * The client code sending commands to the terminal has requested a new size for the terminal
  12. * Applications that support this should call the `TerminalView.getOptimalFrameSize`
  13. * to get the ideal frame size.
  14. *
  15. * This is needed for the rare cases where the remote client request 80 or 132 column displays,
  16. * it is a rare feature and you most likely can ignore this request.
  17. */
  18. func sizeChanged (source: TerminalView, newCols: Int, newRows: Int)
  19. /**
  20. * Request to change the title of the terminal.
  21. */
  22. func setTerminalTitle(source: TerminalView, title: String)
  23. /**
  24. * Request that date be sent to the application running inside the terminal.
  25. * - Parameter data: Slice of data that should be sent
  26. */
  27. func send (source: TerminalView, data: ArraySlice<UInt8>)
  28. /**
  29. * Invoked when the terminal has been scrolled and the new position is provided
  30. * - Parameter position: the relative position that the code was scrolled to, a value between 0 and 1
  31. */
  32. func scrolled (source: TerminalView, position: Double)
  33. /**
  34. * Invoked in response to the user clicking on a link, which is most likely a url, but is not
  35. * mandatory, so custom implementations receive a string, and they can act on this as a way
  36. * of communciating with the host if desired. The default implementation calls NSWorkspace.shared.open()
  37. * on the URL.
  38. * - Parameter source: the terminalview that called this method
  39. * - Parameter link: the string that was encoded as a link by the client application, typically a url,
  40. * but could be anything, and could be used to communicate by the embedded application and the host
  41. * - Parameter params: the specification allows for key/value pairs to be provided, this contains the
  42. * key and value pairs that were provided
  43. */
  44. func requestOpenLink (source: TerminalView, link: String, params: [String:String])
  45. }
  46. #endif