Added handler for xterm.js onBinary (supposed to handle legacy mouse reports)

This commit is contained in:
Felix Seidl
2020-02-29 13:24:09 +01:00
parent 0e2821eeca
commit 5ae7151916
4 changed files with 19 additions and 7 deletions
@@ -553,14 +553,14 @@ namespace FluentTerminal.App.Views
Logger.Instance.Error(error);
}
public void OnInput(string text)
public void OnInput(byte[] data)
{
if (_terminalClosed)
{
return;
}
ViewModel.Terminal.Write(Encoding.UTF8.GetBytes(text));
ViewModel.Terminal.Write(data);
}
public void Dispose()
+7 -3
View File
@@ -9,7 +9,7 @@ import { Unicode11Addon } from "xterm-addon-unicode11";
interface ExtendedWindow extends Window {
keyBindings: any[];
term: any;
term: Terminal;
terminalBridge: any;
createTerminal(options: any, theme: any, keyBindings: any): void;
@@ -24,7 +24,7 @@ interface ExtendedWindow extends Window {
declare var window: ExtendedWindow;
let term: any;
let term: Terminal;
let fitAddon: FitAddon;
let searchAddon: SearchAddon;
let serializeAddon: SerializeAddon;
@@ -106,7 +106,7 @@ window.createTerminal = (options, theme, keyBindings) => {
}
}
function findInMouseRow(str: string, mouseY: number): {col: Number, row: Number} | undefined {
function findInMouseRow(str: string, mouseY: number): {col: number, row: number} | undefined {
const lineHeight: number = Math.round(window.innerHeight / window.term.rows) - 1;
const mouseRow: number = mouseY / lineHeight;
let col: number, row: number = (mouseRow === Math.ceil(mouseRow) ? mouseRow : Math.floor(mouseRow)) - 1;
@@ -145,6 +145,10 @@ window.createTerminal = (options, theme, keyBindings) => {
window.terminalBridge.inputReceived(data);
});
term.onBinary(binary => {
window.terminalBridge.binaryReceived(binary);
});
term.onResize(({ cols, rows }) => {
window.terminalBridge.notifySizeChanged(cols, rows);
});
@@ -1,5 +1,6 @@
using FluentTerminal.RuntimeComponent.Enums;
using System;
using System.Runtime.InteropServices.WindowsRuntime;
namespace FluentTerminal.RuntimeComponent.Interfaces
{
@@ -17,7 +18,7 @@ namespace FluentTerminal.RuntimeComponent.Interfaces
void OnError(string error);
void OnInput(string text);
void OnInput([ReadOnlyArray]byte[] data);
void OnInitialized();
@@ -1,6 +1,8 @@
using FluentTerminal.RuntimeComponent.Enums;
using FluentTerminal.RuntimeComponent.Interfaces;
using System;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation.Metadata;
@@ -26,7 +28,12 @@ namespace FluentTerminal.RuntimeComponent.WebAllowedObjects
public void InputReceived(string message)
{
_terminalEventListener?.OnInput(message);
_terminalEventListener?.OnInput(Encoding.UTF8.GetBytes(message));
}
public void BinaryReceived(string binary)
{
_terminalEventListener?.OnInput(Encoding.UTF8.GetBytes(binary));
}
public void Initialized()