Skip to content

Commit

Permalink
Add option to merge cell text
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiolo committed Oct 11, 2023
1 parent dea9fee commit 9f42183
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,12 @@ struct Document {
} else { // prevent Ctrl+H from being treated as Backspace
break;
}
case WXK_RETURN: return Action(dc, shift ? A_ENTERGRID : A_ENTERCELL);
case WXK_RETURN:
if (!ctrl) {
return Action(dc, shift ? A_ENTERGRID : A_ENTERCELL);
} else { // prevent Ctrl+M from being treated as Return
break;
}
case WXK_ESCAPE: // docs say it can be used as a menu accelerator, but it does not
// trigger from there?
return Action(dc, A_CANCELEDIT);
Expand Down Expand Up @@ -1435,6 +1440,22 @@ struct Document {
}
return nullptr;

case A_MERGE: {
if (selected.xs * selected.ys == 1) return nullptr;
auto fc = selected.GetFirst();
fc->parent->AddUndo(this);
loopallcellssel(ci, false) {
if (ci != fc) {
fc->text.t += " " + ci->text.t;
ci->text.t.Clear();
}
ci->ResetChildren();
ci->ResetLayout();
}
Refresh();
return nullptr;
}

case A_SELALL:
selected.SelAll();
Refresh();
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum {
A_CUT,
A_COPY,
A_PASTE,
A_MERGE,
A_NEWGRID,
A_UNDO,
A_ABOUT,
Expand Down
1 change: 1 addition & 0 deletions src/myframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ struct MyFrame : wxFrame {
MyAppend(editmenu, A_PASTE, _(L"&Paste\tCTRL+v"));
MyAppend(editmenu, A_PASTESTYLE, _(L"Paste Style Only\tCTRL+SHIFT+v"),
_(L"only sets the colors and style of the copied cell, and keeps the text"));
MyAppend(editmenu, A_MERGE, _("&Merge Text\tCTRL+m"));
editmenu->AppendSeparator();
MyAppend(editmenu, A_UNDO, _(L"&Undo\tCTRL+z"), _(L"revert the changes, one step at a time"));
MyAppend(editmenu, A_REDO, _(L"&Redo\tCTRL+y"),
Expand Down

0 comments on commit 9f42183

Please sign in to comment.