Created
May 22, 2013 17:33
-
-
Save saitoha/5629358 to your computer and use it in GitHub Desktop.
Poderosa - Add focus reporting mode (DECSET/DECRST 1004) for Poderosa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/TerminalEmulator/TerminalBase.cs b/TerminalEmulator/TerminalBase.cs | |
| index 5d4eb09..810da88 100644 | |
| --- a/TerminalEmulator/TerminalBase.cs | |
| +++ b/TerminalEmulator/TerminalBase.cs | |
| @@ -343,6 +343,10 @@ public abstract class AbstractTerminal : ICharProcessor, IByteAsyncInputStream { | |
| return false; | |
| } | |
| + public virtual bool GetFocusReportingMode() { | |
| + return false; | |
| + } | |
| + | |
| #region IByteAsyncInputStream | |
| public void OnReception(ByteDataFragment data) { | |
| try { | |
| diff --git a/TerminalEmulator/TerminalControl.cs b/TerminalEmulator/TerminalControl.cs | |
| index 6588cc4..e127d90 100644 | |
| --- a/TerminalEmulator/TerminalControl.cs | |
| +++ b/TerminalEmulator/TerminalControl.cs | |
| @@ -774,6 +774,10 @@ public class TerminalControl : CharacterDocumentViewer { | |
| base.OnGotFocus(args); | |
| if (!this.EnabledEx) | |
| return; | |
| + if (GetTerminal().GetFocusReportingMode()) { | |
| + byte[] data = new byte[] { 0x1b, 0x5b, 0x49 }; | |
| + TransmitDirect(data, 0, data.Length); | |
| + } | |
| if (this.CharacterDocument != null) { //初期化過程のときは無視 | |
| @@ -787,6 +791,10 @@ public class TerminalControl : CharacterDocumentViewer { | |
| base.OnLostFocus(args); | |
| if (!this.EnabledEx) | |
| return; | |
| + if (GetTerminal().GetFocusReportingMode()) { | |
| + byte[] data = new byte[] { 0x1b, 0x5b, 0x4f }; | |
| + TransmitDirect(data, 0, data.Length); | |
| + } | |
| if (_inIMEComposition) | |
| ClearIMEComposition(); | |
| @@ -1297,4 +1305,4 @@ internal static class DrawingPerformance { | |
| } | |
| -} | |
| ¥ No newline at end of file | |
| +} | |
| diff --git a/TerminalEmulator/XTerm.cs b/TerminalEmulator/XTerm.cs | |
| index 7aac73f..75673aa 100644 | |
| --- a/TerminalEmulator/XTerm.cs | |
| +++ b/TerminalEmulator/XTerm.cs | |
| @@ -51,6 +51,7 @@ private enum MouseTrackingProtocol { | |
| private MouseTrackingState _mouseTrackingState = MouseTrackingState.Off; | |
| private MouseTrackingProtocol _mouseTrackingProtocol = MouseTrackingProtocol.Normal; | |
| + private bool _focusReportingMode = false; | |
| private int _prevMouseRow = -1; | |
| private int _prevMouseCol = -1; | |
| private MouseButtons _mouseButton = MouseButtons.None; | |
| @@ -68,6 +69,10 @@ public XTerm(TerminalInitializeInfo info) | |
| InitTabStops(); | |
| } | |
| + public override bool GetFocusReportingMode() { | |
| + return _focusReportingMode; | |
| + } | |
| + | |
| public override void ProcessChar(char ch) { | |
| if (_gotEscape) { | |
| _gotEscape = false; | |
| @@ -639,8 +644,7 @@ public XTerm(TerminalInitializeInfo info) | |
| ResetMouseTracking((set) ? MouseTrackingState.Any : MouseTrackingState.Off); | |
| return ProcessCharResult.Processed; | |
| case "1004": // Send FocusIn/FocusOut events | |
| - // Not supported | |
| - ResetMouseTracking(MouseTrackingState.Off); | |
| + _focusReportingMode = set; | |
| return ProcessCharResult.Processed; | |
| case "1005": // Enable UTF8 Mouse Mode | |
| if (set) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment