Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### main / head

* `>` now intends the current line.
* Implement `;!` to execute a shell command from the command bar
* Disabled continuous deployment in GHA. See `.github/workflows/build_artifact.yml`
for details
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ perform the following actions (alphabetically ordered):
| <kbd>]</Kbd> | Go to end of paragraph (next empty line) |
| <kbd>_</Kbd> | Go to beginning of line |
| <kbd>$</Kbd> | Go to end of line |
| <kbd>></kbd> | Indent current line |

### Command mode
Likewise, you can switch to `command` mode with the semicolon `;` key. The
Expand Down
7 changes: 7 additions & 0 deletions src/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum class ActionType {
DelCurrentLine,
DelCurrentWord,
EndOfLine,
IndentLine,
JumpEndOfWord,
JumpNextPara,
JumpPrevPara,
Expand Down Expand Up @@ -161,6 +162,12 @@ template <typename T, typename U>
v->cursor_end_of_line();
} break;

case ActionType::IndentLine: {
auto logger = spdlog::get("basic_logger");
if (logger != nullptr) { logger->info("Action called: IndentLine"); }
v->get_active_model()->indent_curr_line();
} break;

case ActionType::JumpEndOfWord: {
auto logger = spdlog::get("basic_logger");
if (logger != nullptr) { logger->info("Action called: JumpEndOfWord"); }
Expand Down
6 changes: 6 additions & 0 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ void Controller::start_action_engine() {

parse_action<void, None>(&view, Action<void> {ActionType::ToggleCase});
view.draw_line(Draw_Line_dir::None);

// Increment line
} else if (k.value() == rawterm::Key('>')) {
if (is_readonly_model()) { continue; }
parse_action<void, None>(&view, Action<void> {ActionType::IndentLine});
view.draw_line(Draw_Line_dir::None);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,7 @@ std::optional<rawterm::Pos> Model::find_next_str(std::string_view sv) {

return std::nullopt;
}

void Model::indent_curr_line() {
if (buf.at(current_line).size()) { buf.at(current_line).insert(0, TAB_SIZE, ' '); }
}
1 change: 1 addition & 0 deletions src/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct Model {
[[nodiscard]] std::vector<std::string> search_text(const std::string&) const;
void search_and_replace(const std::string&);
std::optional<rawterm::Pos> find_next_str(std::string_view);
void indent_curr_line();
};

#endif // MODEL_H
6 changes: 6 additions & 0 deletions tests/integration/normal_mode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,9 @@ def test_e_key(r: TmuxRunner):

r.press("e")
assert r.statusbar_parts()[-1] == "1:7"


@setup("tests/fixture/test_file_1.txt")
def test_right_chevron_key(r: TmuxRunner):
r.press('>')
assert " This" in r.lines()[0]
11 changes: 11 additions & 0 deletions tests/model_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,3 +702,14 @@ TEST_CASE("find_next_str", "[model]") {
REQUIRE(m.search_str == "line");
}
}

TEST_CASE("indent_curr_line", "[model]") {
auto m = Model({"foo", "bar"}, "");
m.indent_curr_line();

REQUIRE(m.buf.at(0).size() == 7);
REQUIRE(m.buf.at(1).size() == 3);

REQUIRE(m.buf.at(0).at(0) == ' ');
REQUIRE(m.buf.at(0).at(4) == 'f');
}
Loading