feat: add Selection.from_pos function
This commit is contained in:
parent
81a1c88847
commit
65eb6bc7ad
1 changed files with 13 additions and 0 deletions
|
@ -19,6 +19,19 @@ pub fn from_cursor(cursor: *const Cursor) Self {
|
||||||
return .{ .begin = cursor.*, .end = cursor.* };
|
return .{ .begin = cursor.*, .end = cursor.* };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_pos(sel: Self, root: Buffer.Root, metrics: Buffer.Metrics) error{NotFound}!Self {
|
||||||
|
return .{
|
||||||
|
.begin = .{
|
||||||
|
.row = sel.begin.row,
|
||||||
|
.col = try root.pos_to_width(sel.begin.row, sel.begin.col, metrics),
|
||||||
|
},
|
||||||
|
.end = .{
|
||||||
|
.row = sel.end.row,
|
||||||
|
.col = try root.pos_to_width(sel.end.row, sel.end.col, metrics),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn line_from_cursor(cursor: Cursor, root: Buffer.Root, mtrx: Buffer.Metrics) Self {
|
pub fn line_from_cursor(cursor: Cursor, root: Buffer.Root, mtrx: Buffer.Metrics) Self {
|
||||||
var begin = cursor;
|
var begin = cursor;
|
||||||
var end = cursor;
|
var end = cursor;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue