Pass entire context to select_coord
This allows a following commit to record selection history inside select_coord() instead of at every call site.
This commit is contained in:
parent
3165f28a3c
commit
aeae2fba37
|
@ -140,8 +140,10 @@ void select_and_set_last(Context& context, Func&& func)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<SelectMode mode = SelectMode::Replace>
|
template<SelectMode mode = SelectMode::Replace>
|
||||||
void select_coord(Buffer& buffer, BufferCoord coord, SelectionList& selections)
|
void select_coord(Context& context, BufferCoord coord)
|
||||||
{
|
{
|
||||||
|
Buffer& buffer = context.buffer();
|
||||||
|
SelectionList& selections = context.selections();
|
||||||
coord = buffer.clamp(coord);
|
coord = buffer.clamp(coord);
|
||||||
if (mode == SelectMode::Replace)
|
if (mode == SelectMode::Replace)
|
||||||
selections = SelectionList{ buffer, coord };
|
selections = SelectionList{ buffer, coord };
|
||||||
|
@ -212,7 +214,7 @@ void goto_commands(Context& context, NormalParams params)
|
||||||
if (params.count != 0)
|
if (params.count != 0)
|
||||||
{
|
{
|
||||||
context.push_jump();
|
context.push_jump();
|
||||||
select_coord<mode>(context.buffer(), LineCount{params.count - 1}, context.selections());
|
select_coord<mode>(context, LineCount{params.count - 1});
|
||||||
if (context.has_window())
|
if (context.has_window())
|
||||||
context.window().center_line(LineCount{params.count-1});
|
context.window().center_line(LineCount{params.count-1});
|
||||||
}
|
}
|
||||||
|
@ -229,7 +231,7 @@ void goto_commands(Context& context, NormalParams params)
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'k':
|
case 'k':
|
||||||
context.push_jump();
|
context.push_jump();
|
||||||
select_coord<mode>(buffer, BufferCoord{0,0}, context.selections());
|
select_coord<mode>(context, BufferCoord{0,0});
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
select<mode, select_to_line_end<true>>(context, {});
|
select<mode, select_to_line_end<true>>(context, {});
|
||||||
|
@ -242,17 +244,17 @@ void goto_commands(Context& context, NormalParams params)
|
||||||
break;
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
context.push_jump();
|
context.push_jump();
|
||||||
select_coord<mode>(buffer, buffer.line_count() - 1, context.selections());
|
select_coord<mode>(context, buffer.line_count() - 1);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
context.push_jump();
|
context.push_jump();
|
||||||
select_coord<mode>(buffer, buffer.back_coord(), context.selections());
|
select_coord<mode>(context, buffer.back_coord());
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (context.has_window())
|
if (context.has_window())
|
||||||
{
|
{
|
||||||
auto line = context.window().position().line;
|
auto line = context.window().position().line;
|
||||||
select_coord<mode>(buffer, line, context.selections());
|
select_coord<mode>(context, line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -260,7 +262,7 @@ void goto_commands(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
auto& window = context.window();
|
auto& window = context.window();
|
||||||
auto line = window.position().line + window.dimensions().line - 1;
|
auto line = window.position().line + window.dimensions().line - 1;
|
||||||
select_coord<mode>(buffer, line, context.selections());
|
select_coord<mode>(context, line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
@ -268,7 +270,7 @@ void goto_commands(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
auto& window = context.window();
|
auto& window = context.window();
|
||||||
auto line = window.position().line + window.dimensions().line / 2;
|
auto line = window.position().line + window.dimensions().line / 2;
|
||||||
select_coord<mode>(buffer, line, context.selections());
|
select_coord<mode>(context, line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -328,7 +330,7 @@ void goto_commands(Context& context, NormalParams params)
|
||||||
throw runtime_error("no last modification position");
|
throw runtime_error("no last modification position");
|
||||||
if (*pos >= buffer.back_coord())
|
if (*pos >= buffer.back_coord())
|
||||||
pos = buffer.back_coord();
|
pos = buffer.back_coord();
|
||||||
select_coord<mode>(buffer, *pos, context.selections());
|
select_coord<mode>(context, *pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user