fullHelpView method

String fullHelpView(
  1. List<List<KeyBinding>> groups
)

Renders a full help view from grouped key bindings.

Each inner list is rendered as a column of key bindings.

Implementation

String fullHelpView(List<List<KeyBinding>> groups) {
  if (groups.isEmpty) return '';

  final columns = <String>[];
  var totalWidth = 0;

  for (var i = 0; i < groups.length; i++) {
    final group = groups[i];
    if (!_shouldRenderColumn(group)) continue;

    // Build column
    final keys = <String>[];
    final descs = <String>[];

    for (final binding in group) {
      if (!binding.enabled) continue;
      keys.add(binding.help.key);
      descs.add(binding.help.desc);
    }

    // Format column with keys and descriptions side by side
    final column = _formatColumn(keys, descs, i > 0);
    final colWidth = _columnWidth(keys, descs);

    // Check if we need to truncate
    if (width > 0 && totalWidth + colWidth > width) {
      final ellipsis = ' ${styles.ellipsis}';
      if (totalWidth + Style.visibleLength(ellipsis) < width) {
        columns.add(ellipsis);
      }
      break;
    }

    columns.add(column);
    totalWidth += colWidth;
  }

  // Join columns horizontally
  return _joinColumnsHorizontally(columns);
}