Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to only show just the horizontal or vertical position in statusline #10883

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add-a-way-to-only-show-the-horizontal-or-vertical-position-in-statusline
  • Loading branch information
godalming committed Jun 4, 2024
commit e1b2bd501b2aa2a12bd33815cb36300d8aa1c609
26 changes: 26 additions & 0 deletions helix-term/src/ui/statusline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ where
render_primary_selection_length
}
helix_view::editor::StatusLineElement::Position => render_position,
helix_view::editor::StatusLineElement::Row => render_row,
helix_view::editor::StatusLineElement::Col => render_col,
helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage,
helix_view::editor::StatusLineElement::TotalLineNumbers => render_total_line_numbers,
helix_view::editor::StatusLineElement::Separator => render_separator,
Expand Down Expand Up @@ -348,6 +350,30 @@ where
);
}

fn render_row<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
let position = get_position(context);
write(
context,
format!(" {} ", position.row + 1),
None,
);
}

fn render_col<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
let position = get_position(context);
write(
context,
format!(" {} ", position.col + 1),
None,
);
}

fn render_total_line_numbers<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
Expand Down
6 changes: 6 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ pub enum StatusLineElement {
/// The cursor position
Position,

/// The row that the cursor is at
Row,

/// The column that the cursor is at
Col,

/// The separator string
Separator,

Expand Down