rpos
A cursor manager on table for Rust.
Overview
rpos provides a simple and intuitive way to manage cursor position on a 2D table. The cursor can navigate within the table using directional movements (up, down, left, right) or by setting specific positions. By default, movement wraps at edges, and clamp mode can be enabled when needed.
Installation
Add this to your Cargo.toml:
[]
= "0.3.1"
Usage
Creating a Table with Cursor
use Table;
Moving the Cursor
use Table;
Setting Cursor Position
use Table;
Wraparound Movement
Wrap mode is the default and wraps around table edges when moving:
use Table;
Clamp Mode
Clamp mode keeps the cursor at the table edges:
use ;
API Reference
Table
| Method | Description |
|---|---|
Table::new(height, width) |
Creates a new table with specified dimensions |
Table::new_with_wrap_mode(height, width, wrap_mode) |
Creates a new table with a specified wrap mode |
WrapMode
| Variant | Description |
|---|---|
WrapMode::Wrap |
Wraps cursor movement at table edges |
WrapMode::Clamp |
Clamps cursor movement at table edges |
Cursor
| Method | Description |
|---|---|
current() |
Returns current position as (line, column) |
set(line, column) |
Sets cursor to specific position |
set_line(line) |
Sets cursor line (row) |
set_column(column) |
Sets cursor column |
wrap_mode() |
Returns current wrap mode |
set_wrap_mode(wrap_mode) |
Sets wrap mode for movement |
up() |
Moves cursor up one position |
down() |
Moves cursor down one position |
left() |
Moves cursor left one position |
right() |
Moves cursor right one position |
License
MIT License - see LICENSE for details.