Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(mason_logger): upgrade pkg:win32 to ^0.5.4 #1300

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mason_logger/lib/src/ffi/unix_terminal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const _STDIN_FILENO = 0;
// The number of elements in the control chars array.
const _NCSS = 20;

class TermIOS extends Struct {
final class TermIOS extends Struct {
@tcflag_t()
external int c_iflag; // input flags
@tcflag_t()
Expand Down
28 changes: 14 additions & 14 deletions packages/mason_logger/lib/src/ffi/windows_terminal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ import 'package:win32/win32.dart';

class WindowsTerminal implements Terminal {
WindowsTerminal() {
outputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
inputHandle = GetStdHandle(STD_INPUT_HANDLE);
outputHandle = GetStdHandle(STD_HANDLE.STD_OUTPUT_HANDLE);
inputHandle = GetStdHandle(STD_HANDLE.STD_INPUT_HANDLE);
}

late final int inputHandle;
late final int outputHandle;

@override
void enableRawMode() {
const dwMode = (~ENABLE_ECHO_INPUT) &
(~ENABLE_PROCESSED_INPUT) &
(~ENABLE_LINE_INPUT) &
(~ENABLE_WINDOW_INPUT);
const dwMode = (~CONSOLE_MODE.ENABLE_ECHO_INPUT) &
(~CONSOLE_MODE.ENABLE_PROCESSED_INPUT) &
(~CONSOLE_MODE.ENABLE_LINE_INPUT) &
(~CONSOLE_MODE.ENABLE_WINDOW_INPUT);
SetConsoleMode(inputHandle, dwMode);
}

@override
void disableRawMode() {
const dwMode = ENABLE_ECHO_INPUT |
ENABLE_EXTENDED_FLAGS |
ENABLE_INSERT_MODE |
ENABLE_LINE_INPUT |
ENABLE_MOUSE_INPUT |
ENABLE_PROCESSED_INPUT |
ENABLE_QUICK_EDIT_MODE |
ENABLE_VIRTUAL_TERMINAL_INPUT;
const dwMode = CONSOLE_MODE.ENABLE_ECHO_INPUT |
CONSOLE_MODE.ENABLE_EXTENDED_FLAGS |
CONSOLE_MODE.ENABLE_INSERT_MODE |
CONSOLE_MODE.ENABLE_LINE_INPUT |
CONSOLE_MODE.ENABLE_MOUSE_INPUT |
CONSOLE_MODE.ENABLE_PROCESSED_INPUT |
CONSOLE_MODE.ENABLE_QUICK_EDIT_MODE |
CONSOLE_MODE.ENABLE_VIRTUAL_TERMINAL_INPUT;
SetConsoleMode(inputHandle, dwMode);
}
}
19 changes: 0 additions & 19 deletions packages/mason_logger/lib/src/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,16 @@ KeyStroke readKey() {
switch (escapeSequence[1]) {
case 'A':
keyStroke = KeyStroke.control(ControlCharacter.arrowUp);
break;
case 'B':
keyStroke = KeyStroke.control(ControlCharacter.arrowDown);
break;
case 'C':
keyStroke = KeyStroke.control(ControlCharacter.arrowRight);
break;
case 'D':
keyStroke = KeyStroke.control(ControlCharacter.arrowLeft);
break;
case 'H':
keyStroke = KeyStroke.control(ControlCharacter.home);
break;
case 'F':
keyStroke = KeyStroke.control(ControlCharacter.end);
break;
default:
if (escapeSequence[1].codeUnits[0] > '0'.codeUnits[0] &&
escapeSequence[1].codeUnits[0] < '9'.codeUnits[0]) {
Expand All @@ -248,37 +242,30 @@ KeyStroke readKey() {
keyStroke = KeyStroke.control(
ControlCharacter.home,
);
break;
case '3':
keyStroke = KeyStroke.control(
ControlCharacter.delete,
);
break;
case '4':
keyStroke = KeyStroke.control(
ControlCharacter.end,
);
break;
case '5':
keyStroke = KeyStroke.control(
ControlCharacter.pageUp,
);
break;
case '6':
keyStroke = KeyStroke.control(
ControlCharacter.pageDown,
);
break;
case '7':
keyStroke = KeyStroke.control(
ControlCharacter.home,
);
break;
case '8':
keyStroke = KeyStroke.control(
ControlCharacter.end,
);
break;
default:
keyStroke = KeyStroke.control(
ControlCharacter.unknown,
Expand All @@ -300,22 +287,16 @@ KeyStroke readKey() {
switch (escapeSequence[1]) {
case 'H':
keyStroke = KeyStroke.control(ControlCharacter.home);
break;
case 'F':
keyStroke = KeyStroke.control(ControlCharacter.end);
break;
case 'P':
keyStroke = KeyStroke.control(ControlCharacter.F1);
break;
case 'Q':
keyStroke = KeyStroke.control(ControlCharacter.F2);
break;
case 'R':
keyStroke = KeyStroke.control(ControlCharacter.F3);
break;
case 'S':
keyStroke = KeyStroke.control(ControlCharacter.F4);
break;
default:
}
} else if (escapeSequence[0] == 'b') {
Expand Down
4 changes: 2 additions & 2 deletions packages/mason_logger/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ documentation: https://github.com/felangel/mason/tree/master/packages/mason_logg
topics: [cli, logger, mason]

environment:
sdk: ">=2.19.0 <4.0.0"
sdk: ">=3.3.0 <4.0.0"

dependencies:
ffi: ^2.1.0
io: ^1.0.4
win32: ^5.0.7
win32: ^5.4.0

dev_dependencies:
meta: ^1.7.0
Expand Down
Loading