Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
mls-m5 committed Nov 1, 2023
1 parent f286e8e commit 21464d1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/modes/normalmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ std::shared_ptr<IMode> createNormalMode() {
{{"I"}, sc.combine(sc.home, sc.insert_mode)},
{{"a"}, sc.combine(sc.right, sc.insert_mode)},
{{"A"}, sc.combine(sc.end, sc.insert_mode)},
{{"s"}, sc.combine(sc.erase_after, sc.insert_mode)},
{{">"}, {sc.indent}},
{{"<"}, {sc.deindent}},
},
Expand Down
32 changes: 24 additions & 8 deletions src/script/standardcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,36 @@ StandardCommands create() {
auto &e = env->editor();
auto selection = e.selection();
if (selection.empty()) {
env->registers().save(standardRegister,
content(e.cursor()).toString());
e.cursor(erase(e.cursor()));
}
else {
auto str = std::string{};

// REPEAT {
str += toString(selection);
REPEAT {
str = toString(e.cursor()) + str;
e.cursor(erase(e.cursor()));
}
env->registers().save(standardRegister, str);
}
else {
env->registers().save(standardRegister, toString(selection));
e.cursor(erase(selection), true);
// }
}
};

DEF(erase_after) {
auto &e = env->editor();
auto selection = e.selection();
if (selection.empty()) {
auto str = std::string{};

REPEAT {
str += toString(e.cursor());
e.cursor(erase(right(e.cursor())));
}
env->registers().save(standardRegister, str);
}
else {
env->registers().save(standardRegister, toString(selection));
e.cursor(erase(selection), true);
}
};

DEF(erase_before_word) {
Expand Down
1 change: 1 addition & 0 deletions src/script/standardcommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
STD_DEF(yank) \
STD_DEF(yank_block) \
STD_DEF(erase) \
STD_DEF(erase_after) \
STD_DEF(erase_before_word) \
STD_DEF(paste_before) \
STD_DEF(paste) \
Expand Down

0 comments on commit 21464d1

Please sign in to comment.