LogTerminal 1.1.2
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Framework 4.7.2
This package targets .NET Framework 4.7.2. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
Requires NuGet 3.3.0 or higher.
dotnet add package LogTerminal --version 1.1.2
NuGet\Install-Package LogTerminal -Version 1.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LogTerminal" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LogTerminal" Version="1.1.2" />
<PackageReference Include="LogTerminal" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LogTerminal --version 1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LogTerminal, 1.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LogTerminal@1.1.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LogTerminal&version=1.1.2
#tool nuget:?package=LogTerminal&version=1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#How to use
1/ In MainWidow.xaml
Add namespace
<Window
...
xmlns:term="clr-namespace:Microsoft.Terminal.Wpf;assembly=Microsoft.Terminal.Wpf"
...
>
<Grid>
<term:TerminalControl
x:Name="Terminal"
BuffSzie="512"
Focusable="true" />
</Grid>
</Window>
2/ In MainWindow.xaml.cs
using Microsoft.Terminal.Wpf;
using System;
using System.Windows;
namespace WpfApp1
{
public class EchoConnection : Microsoft.Terminal.Wpf.ITerminalConnection
{
public event EventHandler<TerminalOutputEventArgs> TerminalOutput;
public event EventHandler<TerminalLogOutputEventArgs> TerminalLogOutput;
public void Resize(uint rows, uint columns)
{
return;
}
public void Start()
{
TerminalOutput.Invoke(this, new TerminalOutputEventArgs("ECHO CONNECTION\r\n^A: toggle printable ESC\r\n^B: toggle SGR mouse mode\r\n^C: toggle win32 input mode\r\n\r\n"));
return;
}
private bool _escapeMode;
private bool _mouseMode;
private bool _win32InputMode;
int count = 0;
public void WriteInput(string data)
{
if (data.Length == 0)
{
return;
}
if (data[0] == '\x01') // ^A
{
_escapeMode = !_escapeMode;
TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"Printable ESC mode: {_escapeMode}\r\n"));
}
else if (data[0] == '\x02') // ^B
{
_mouseMode = !_mouseMode;
var decSet = _mouseMode ? "h" : "l";
TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"\x1b[?1003{decSet}\x1b[?1006{decSet}"));
TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"SGR Mouse mode (1003, 1006): {_mouseMode}\r\n"));
}
else if ((data[0] == '\x03') ||(data == "\x1b[67;46;3;1;8;1_")) // ^C
{
_win32InputMode = !_win32InputMode;
var decSet = _win32InputMode ? "h" : "l";
TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"\x1b[?9001{decSet}"));
TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"Win32 input mode: {_win32InputMode}\r\n"));
// If escape mode isn't currently enabled, turn it on now.
if (_win32InputMode && !_escapeMode)
{
_escapeMode = true;
TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"Printable ESC mode: {_escapeMode}\r\n"));
}
}
else
{
// Echo back to the terminal, but make backspace/newline work properly.
var str = data.Replace("\r", "\r\n").Replace("\x7f", "\x08 \x08");
if (_escapeMode)
{
str = str.Replace("\x1b", "\u241b");
}
//direct output
//TerminalOutput.Invoke(this, new TerminalOutputEventArgs(str));
TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Verbose, "Verbose test log. User input:" + str));
TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Info, "Info test log. User input:" + str));
TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Warning, "Warning test log. User input:" + str));
TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Error, "Error test log. User input:" + str));
TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Fatel, "Fatel test log. User input:" + str));
}
}
public void Close()
{
return;
}
}
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Terminal.Loaded += Terminal_Loaded;
}
private void Terminal_Loaded(object sender, RoutedEventArgs e)
{
var theme = new TerminalTheme
{
DefaultBackground = 0x0c0c0c,
DefaultForeground = 0xcccccc,
DefaultSelectionBackground = 0xcccccc,
SelectionBackgroundAlpha = 0.5f,
CursorStyle = CursorStyle.BlinkingBar,
// This is Campbell.
ColorTable = new uint[] { 0x0C0C0C, 0x1F0FC5, 0x0EA113, 0x009CC1, 0xDA3700, 0x981788, 0xDD963A, 0xCCCCCC, 0x767676, 0x5648E7, 0x0CC616, 0xA5F1F9, 0xFF783B, 0x9E00B4, 0xD6D661, 0xF2F2F2 },
};
Terminal.Connection = new EchoConnection();
Terminal.SetTheme(theme, "Cascadia Code", 12);
Terminal.Focus();
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7.2
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on LogTerminal:
| Package | Downloads |
|---|---|
|
Serilog.Sinks.LogTerminal
Serilog sink for LogTerminal |
GitHub repositories
This package is not used by any popular GitHub repositories.