Skip to content

Commit

Permalink
Rename TerminalInputEvent to TerminalKeyboardEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
xtyxtyx committed Oct 30, 2022
1 parent 5a84480 commit df6cc30
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion example/lib/src/virtual_keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
}

@override
String? call(TerminalInputEvent event) {
String? call(TerminalKeyboardEvent event) {
return _inputHandler.call(event.copyWith(
ctrl: event.ctrl || _ctrl,
shift: event.shift || _shift,
Expand Down
22 changes: 11 additions & 11 deletions lib/src/core/input/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:xterm/src/core/state.dart';
///
/// See also:
/// - [TerminalInputHandler]
class TerminalInputEvent {
class TerminalKeyboardEvent {
final TerminalKey key;

final bool shift;
Expand All @@ -25,7 +25,7 @@ class TerminalInputEvent {

final TerminalTargetPlatform platform;

TerminalInputEvent({
TerminalKeyboardEvent({
required this.key,
required this.shift,
required this.ctrl,
Expand All @@ -35,7 +35,7 @@ class TerminalInputEvent {
required this.platform,
});

TerminalInputEvent copyWith({
TerminalKeyboardEvent copyWith({
TerminalKey? key,
bool? shift,
bool? ctrl,
Expand All @@ -44,7 +44,7 @@ class TerminalInputEvent {
bool? altBuffer,
TerminalTargetPlatform? platform,
}) {
return TerminalInputEvent(
return TerminalKeyboardEvent(
key: key ?? this.key,
shift: shift ?? this.shift,
ctrl: ctrl ?? this.ctrl,
Expand All @@ -56,12 +56,12 @@ class TerminalInputEvent {
}
}

/// TerminalInputHandler contains the logic for translating a [TerminalInputEvent]
/// TerminalInputHandler contains the logic for translating a [TerminalKeyboardEvent]
/// into escape sequences that can be recognized by the terminal.
abstract class TerminalInputHandler {
/// Translates a [TerminalInputEvent] into an escape sequence. If the event
/// Translates a [TerminalKeyboardEvent] into an escape sequence. If the event
/// cannot be translated, null is returned.
String? call(TerminalInputEvent event);
String? call(TerminalKeyboardEvent event);
}

/// A [TerminalInputHandler] that chains multiple handlers together. If any
Expand All @@ -73,7 +73,7 @@ class CascadeInputHandler implements TerminalInputHandler {
const CascadeInputHandler(this._handlers);

@override
String? call(TerminalInputEvent event) {
String? call(TerminalKeyboardEvent event) {
for (var handler in _handlers) {
final result = handler(event);
if (result != null) {
Expand Down Expand Up @@ -107,7 +107,7 @@ class KeytabInputHandler implements TerminalInputHandler {
const KeytabInputHandler();

@override
String? call(TerminalInputEvent event) {
String? call(TerminalKeyboardEvent event) {
final action = _keytab.find(
event.key,
ctrl: event.ctrl,
Expand All @@ -134,7 +134,7 @@ class CtrlInputHandler implements TerminalInputHandler {
const CtrlInputHandler();

@override
String? call(TerminalInputEvent event) {
String? call(TerminalKeyboardEvent event) {
if (!event.ctrl || event.shift || event.alt) {
return null;
}
Expand All @@ -157,7 +157,7 @@ class AltInputHandler implements TerminalInputHandler {
const AltInputHandler();

@override
String? call(TerminalInputEvent event) {
String? call(TerminalKeyboardEvent event) {
if (!event.alt || event.ctrl || event.shift) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/terminal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Terminal with Observable implements TerminalState, EscapeHandler {
bool ctrl = false,
}) {
final output = inputHandler?.call(
TerminalInputEvent(
TerminalKeyboardEvent(
key: key,
shift: shift,
alt: alt,
Expand Down
4 changes: 2 additions & 2 deletions test/src/terminal_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ void main() {
}

class _TestInputHandler implements TerminalInputHandler {
final events = <TerminalInputEvent>[];
final events = <TerminalKeyboardEvent>[];

@override
String? call(TerminalInputEvent event) {
String? call(TerminalKeyboardEvent event) {
events.add(event);
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion test/src/terminal_view_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import 'package:xterm/src/core/input/handler.dart' as _i2;
class MockTerminalInputHandler extends _i1.Mock
implements _i2.TerminalInputHandler {
@override
String? call(_i2.TerminalInputEvent? event) => (super.noSuchMethod(
String? call(_i2.TerminalKeyboardEvent? event) => (super.noSuchMethod(
Invocation.method(
#call,
[event],
Expand Down

0 comments on commit df6cc30

Please sign in to comment.