pager function

Future<void> pager(
  1. String content, {
  2. int width = 80,
  3. int height = 20,
  4. List<ProgramOption> options = const [],
})

Show content in a scrollable pager. Scroll with the usual viewport keys; press q/Esc to exit. Completes when the user quits.

In plain mode (see withPlainMode) it writes content as it is.

Implementation

Future<void> pager(
  String content, {
  int width = 80,
  int height = 20,
  List<ProgramOption> options = const [],
}) async {
  final program = Program(options: options);
  final plain = PlainSession.open(program);
  if (plain != null) {
    plain.write(content.endsWith('\n') ? content : '$content\n');
    return;
  }
  final model = _PagerModel(
    ViewportModel(content: content, width: width, height: height),
  );
  await program.run(model);
}