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

De-duplicate code (Home/End navigation) #513

Merged
merged 1 commit into from
Sep 20, 2023
Merged
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
46 changes: 16 additions & 30 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1990,39 +1990,25 @@ struct Document {
ZoomOutIfNoGrid(dc);
return nullptr;

// FIXME: this functionality is really SCHOME, SHOME should be within line
case A_SHOME:
case A_SHOME:
case A_SEND:
case A_CHOME:
case A_CEND:
case A_HOME:
case A_END: {
DrawSelect(dc, selected);
selected.cursor = 0;
DrawSelectMove(dc, selected);
return nullptr;
case A_SEND:
DrawSelect(dc, selected);
selected.cursorend = (int)c->text.t.Len();
DrawSelectMove(dc, selected);
return nullptr;

case A_CHOME:
DrawSelect(dc, selected);
selected.cursor = selected.cursorend = 0;
DrawSelectMove(dc, selected);
return nullptr;
case A_CEND:
DrawSelect(dc, selected);
selected.cursor = selected.cursorend = selected.MaxCursor();
DrawSelectMove(dc, selected);
return nullptr;

case A_HOME:
DrawSelect(dc, selected);
c->text.HomeEnd(selected, true);
DrawSelectMove(dc, selected);
return nullptr;
case A_END:
DrawSelect(dc, selected);
c->text.HomeEnd(selected, false);
switch (k) {
case A_SHOME: // FIXME: this functionality is really SCHOME, SHOME should be within line
selected.cursor = 0; break;
case A_SEND: selected.cursorend = (int)c->text.t.Len(); break;
case A_CHOME: selected.cursor = selected.cursorend = 0; break;
case A_CEND: selected.cursor = selected.cursorend = selected.MaxCursor(); break;
case A_HOME: c->text.HomeEnd(selected, true); break;
case A_END: c->text.HomeEnd(selected, false); break;
}
DrawSelectMove(dc, selected);
return nullptr;
}
default: return _(L"Internal error: unimplemented operation!");
}
}
Expand Down