89882d90f3
The card's output area is now an xterm.dart emulator kept per run by the controller: it is fed the raw stream in order, takes typing and paste while the command runs (with a key toolbar and a soft-keyboard field on touch platforms), resizes the process to its layout, opens printed links, shrinks finished runs to their output and opens full screen. A reconnect resumes from the byte the card holds; Copy output copies the server's plain text.
99 lines
2.9 KiB
Dart
99 lines
2.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/text/monospace.dart';
|
|
import 'chat_shell_runs_controller.dart';
|
|
import 'chat_shell_terminal_keys.dart';
|
|
import 'chat_shell_terminal_view.dart';
|
|
|
|
/// Opens [runId]'s terminal full screen: the same emulator the card draws,
|
|
/// sized to the window (a running process is resized to match), with the key
|
|
/// toolbar while it runs. Resolves when the page is closed.
|
|
Future<void> openChatShellTerminalPage(
|
|
BuildContext context, {
|
|
required ChatShellRunsController controller,
|
|
required String runId,
|
|
required bool cupertino,
|
|
}) {
|
|
Widget page(BuildContext _) => ChatShellTerminalPage(
|
|
controller: controller,
|
|
runId: runId,
|
|
cupertino: cupertino,
|
|
);
|
|
return Navigator.of(context).push<void>(
|
|
cupertino
|
|
? CupertinoPageRoute<void>(builder: page)
|
|
: MaterialPageRoute<void>(builder: page),
|
|
);
|
|
}
|
|
|
|
class ChatShellTerminalPage extends StatelessWidget {
|
|
const ChatShellTerminalPage({
|
|
super.key,
|
|
required this.controller,
|
|
required this.runId,
|
|
required this.cupertino,
|
|
});
|
|
|
|
final ChatShellRunsController controller;
|
|
final String runId;
|
|
final bool cupertino;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListenableBuilder(
|
|
listenable: controller,
|
|
builder: (context, _) {
|
|
final run = controller.run(runId);
|
|
final title = Text(
|
|
run == null ? 'Command' : '\$ ${run.command}',
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(fontFamily: appMonospaceFamily),
|
|
);
|
|
Widget body = const SizedBox.shrink();
|
|
if (run != null) {
|
|
final session = controller.terminals.session(run);
|
|
body = SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Expanded(
|
|
child: ChatShellTerminalView(
|
|
session: session,
|
|
cupertino: cupertino,
|
|
fill: true,
|
|
autofocus: true,
|
|
),
|
|
),
|
|
if (session.live)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8),
|
|
child: ChatShellTerminalKeys(
|
|
session: session,
|
|
cupertino: cupertino,
|
|
field: chatShellTouchFirst(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
if (cupertino) {
|
|
return CupertinoPageScaffold(
|
|
navigationBar: CupertinoNavigationBar(middle: title),
|
|
child: body,
|
|
);
|
|
}
|
|
return Scaffold(
|
|
appBar: AppBar(title: title),
|
|
body: body,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|