72 lines
2.3 KiB
Dart
72 lines
2.3 KiB
Dart
class TerminalScreenPatch {
|
|
const TerminalScreenPatch({
|
|
required this.sessionId,
|
|
required this.baseScreenVersion,
|
|
required this.screenVersion,
|
|
required this.sourceSequence,
|
|
required this.rows,
|
|
required this.columns,
|
|
required this.cursorRow,
|
|
required this.cursorColumn,
|
|
required this.cursorVisible,
|
|
required this.activeBuffer,
|
|
required this.operations,
|
|
});
|
|
|
|
final String sessionId;
|
|
final int baseScreenVersion;
|
|
final int screenVersion;
|
|
final int sourceSequence;
|
|
final int rows;
|
|
final int columns;
|
|
final int cursorRow;
|
|
final int cursorColumn;
|
|
final bool cursorVisible;
|
|
final String activeBuffer;
|
|
final List<TerminalScreenPatchOperation> operations;
|
|
|
|
factory TerminalScreenPatch.fromJson(Map<String, dynamic> json) {
|
|
final rawOperations = (json['operations'] as List?) ?? const <dynamic>[];
|
|
return TerminalScreenPatch(
|
|
sessionId: json['sessionId'] as String,
|
|
baseScreenVersion: (json['baseScreenVersion'] as num?)?.toInt() ?? 0,
|
|
screenVersion: (json['screenVersion'] as num?)?.toInt() ?? 0,
|
|
sourceSequence: (json['sourceSequence'] as num?)?.toInt() ?? 0,
|
|
rows: (json['rows'] as num?)?.toInt() ?? 0,
|
|
columns: (json['columns'] as num?)?.toInt() ?? 0,
|
|
cursorRow: (json['cursorRow'] as num?)?.toInt() ?? 0,
|
|
cursorColumn: (json['cursorColumn'] as num?)?.toInt() ?? 0,
|
|
cursorVisible: json['cursorVisible'] as bool? ?? true,
|
|
activeBuffer: (json['activeBuffer'] as String?) ?? 'primary',
|
|
operations: rawOperations
|
|
.map(
|
|
(item) => TerminalScreenPatchOperation.fromJson(
|
|
Map<String, dynamic>.from(item as Map),
|
|
),
|
|
)
|
|
.toList(growable: false),
|
|
);
|
|
}
|
|
}
|
|
|
|
class TerminalScreenPatchOperation {
|
|
const TerminalScreenPatchOperation({
|
|
required this.type,
|
|
required this.startRow,
|
|
required this.lines,
|
|
});
|
|
|
|
final String type;
|
|
final int startRow;
|
|
final List<String> lines;
|
|
|
|
factory TerminalScreenPatchOperation.fromJson(Map<String, dynamic> json) {
|
|
final rawLines = (json['lines'] as List?) ?? const <dynamic>[];
|
|
return TerminalScreenPatchOperation(
|
|
type: (json['type'] as String?) ?? '',
|
|
startRow: (json['startRow'] as num?)?.toInt() ?? 0,
|
|
lines: rawLines.map((item) => item as String? ?? '').toList(growable: false),
|
|
);
|
|
}
|
|
}
|