mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
bugfix in Button.ProcessKey and expose a new function for all drivers (#253)
* added a public api function called SetTerminalResized for drivers * bugfix: overflow exception has occurred on (Rune)c when c is an integer => casting to uint solved the problem * Apply suggestions from code review Co-Authored-By: Marius Ungureanu <teromario@yahoo.com>
This commit is contained in:
committed by
Miguel de Icaza
parent
401c872b31
commit
a50d79bd7b
@@ -253,6 +253,8 @@ namespace Terminal.Gui {
|
||||
/// ConsoleDriver is an abstract class that defines the requirements for a console driver. One implementation if the CursesDriver, and another one uses the .NET Console one.
|
||||
/// </summary>
|
||||
public abstract class ConsoleDriver {
|
||||
protected Action TerminalResized;
|
||||
|
||||
/// <summary>
|
||||
/// The current number of columns in the terminal.
|
||||
/// </summary>
|
||||
@@ -323,6 +325,11 @@ namespace Terminal.Gui {
|
||||
/// <param name="backgroundColorId">Background color identifier.</param>
|
||||
public abstract void SetColors (short foregroundColorId, short backgroundColorId);
|
||||
|
||||
public void SetTerminalResized(Action terminalResized)
|
||||
{
|
||||
TerminalResized = terminalResized;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a frame on the specified region with the specified padding around the frame.
|
||||
/// </summary>
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace Terminal.Gui {
|
||||
/// This is the Curses driver for the gui.cs/Terminal framework.
|
||||
/// </summary>
|
||||
public class CursesDriver : ConsoleDriver {
|
||||
Action terminalResized;
|
||||
|
||||
public override int Cols => Curses.Cols;
|
||||
public override int Rows => Curses.Lines;
|
||||
|
||||
@@ -159,7 +157,7 @@ namespace Terminal.Gui {
|
||||
if (code == Curses.KEY_CODE_YES) {
|
||||
if (wch == Curses.KeyResize) {
|
||||
if (Curses.CheckWinChange ()) {
|
||||
terminalResized ();
|
||||
TerminalResized?.Invoke ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -226,7 +224,7 @@ namespace Terminal.Gui {
|
||||
|
||||
Curses.Window.Standard.keypad (true);
|
||||
reportableMouseEvents = Curses.mousemask (Curses.Event.AllEvents | Curses.Event.ReportMousePosition, out oldMouseEvents);
|
||||
this.terminalResized = terminalResized;
|
||||
TerminalResized = terminalResized;
|
||||
if (reportableMouseEvents.HasFlag (Curses.Event.ReportMousePosition))
|
||||
StartReportingMouseMoves ();
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace Terminal.Gui {
|
||||
public override bool ProcessKey (KeyEvent kb)
|
||||
{
|
||||
var c = kb.KeyValue;
|
||||
if (c == '\n' || c == ' ' || Rune.ToUpper ((Rune)c) == hot_key) {
|
||||
if (c == '\n' || c == ' ' || Rune.ToUpper ((uint)c) == hot_key) {
|
||||
if (Clicked != null)
|
||||
Clicked ();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user