Fix status message when there's nothing to show.
I was using "refresh requested" for debugging, but this is better.
This commit is contained in:
10
.idea/workspace.xml
generated
10
.idea/workspace.xml
generated
@@ -36,14 +36,6 @@
|
|||||||
<list default="true" id="e1fe3ab0-3650-4fca-8664-a247d5dfa457" name="Changes" comment="">
|
<list default="true" id="e1fe3ab0-3650-4fca-8664-a247d5dfa457" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Command.cc" beforeDir="false" afterPath="$PROJECT_DIR$/Command.cc" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Command.cc" beforeDir="false" afterPath="$PROJECT_DIR$/Command.cc" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Command.h" beforeDir="false" afterPath="$PROJECT_DIR$/Command.h" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/GUIFrontend.cc" beforeDir="false" afterPath="$PROJECT_DIR$/GUIFrontend.cc" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/GUIInputHandler.cc" beforeDir="false" afterPath="$PROJECT_DIR$/GUIInputHandler.cc" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/GUIRenderer.cc" beforeDir="false" afterPath="$PROJECT_DIR$/GUIRenderer.cc" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/TerminalFrontend.cc" beforeDir="false" afterPath="$PROJECT_DIR$/TerminalFrontend.cc" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/TerminalInputHandler.cc" beforeDir="false" afterPath="$PROJECT_DIR$/TerminalInputHandler.cc" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/TerminalRenderer.cc" beforeDir="false" afterPath="$PROJECT_DIR$/TerminalRenderer.cc" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/main.cc" beforeDir="false" afterPath="$PROJECT_DIR$/main.cc" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -148,7 +140,7 @@
|
|||||||
<option name="number" value="Default" />
|
<option name="number" value="Default" />
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1764457173148</updated>
|
<updated>1764457173148</updated>
|
||||||
<workItem from="1764457174208" duration="19741000" />
|
<workItem from="1764457174208" duration="20181000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
50
Command.cc
50
Command.cc
@@ -87,7 +87,8 @@ inverse_render_to_source_col(const std::string &line, std::size_t rx_target, std
|
|||||||
{
|
{
|
||||||
// Find source column that best matches given rendered x (with tabs expanded)
|
// Find source column that best matches given rendered x (with tabs expanded)
|
||||||
std::size_t rx = 0;
|
std::size_t rx = 0;
|
||||||
if (rx_target == 0) return 0;
|
if (rx_target == 0)
|
||||||
|
return 0;
|
||||||
std::size_t best_col = 0;
|
std::size_t best_col = 0;
|
||||||
std::size_t best_dist = rx_target; // max
|
std::size_t best_dist = rx_target; // max
|
||||||
for (std::size_t i = 0; i <= line.size(); ++i) {
|
for (std::size_t i = 0; i <= line.size(); ++i) {
|
||||||
@@ -96,7 +97,8 @@ inverse_render_to_source_col(const std::string &line, std::size_t rx_target, std
|
|||||||
best_dist = dist;
|
best_dist = dist;
|
||||||
best_col = i;
|
best_col = i;
|
||||||
}
|
}
|
||||||
if (i == line.size()) break;
|
if (i == line.size())
|
||||||
|
break;
|
||||||
if (line[i] == '\t') {
|
if (line[i] == '\t') {
|
||||||
rx += tabw - (rx % tabw);
|
rx += tabw - (rx % tabw);
|
||||||
} else {
|
} else {
|
||||||
@@ -106,7 +108,8 @@ inverse_render_to_source_col(const std::string &line, std::size_t rx_target, std
|
|||||||
// next iteration will evaluate i+1 with updated rx
|
// next iteration will evaluate i+1 with updated rx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best_col > line.size()) best_col = line.size();
|
if (best_col > line.size())
|
||||||
|
best_col = line.size();
|
||||||
return best_col;
|
return best_col;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,13 +131,19 @@ cmd_move_cursor_to(CommandContext &ctx)
|
|||||||
if (!a.empty()) {
|
if (!a.empty()) {
|
||||||
bool screen = false;
|
bool screen = false;
|
||||||
std::size_t start = 0;
|
std::size_t start = 0;
|
||||||
if (!a.empty() && a[0] == '@') { screen = true; start = 1; }
|
if (!a.empty() && a[0] == '@') {
|
||||||
|
screen = true;
|
||||||
|
start = 1;
|
||||||
|
}
|
||||||
std::size_t p = a.find(':', start);
|
std::size_t p = a.find(':', start);
|
||||||
if (p != std::string::npos) {
|
if (p != std::string::npos) {
|
||||||
try {
|
try {
|
||||||
long ay = std::stol(a.substr(start, p - start));
|
long ay = std::stol(a.substr(start, p - start));
|
||||||
long ax = std::stol(a.substr(p + 1));
|
long ax = std::stol(a.substr(p + 1));
|
||||||
if (ay < 0) ay = 0; if (ax < 0) ax = 0;
|
if (ay < 0)
|
||||||
|
ay = 0;
|
||||||
|
if (ax < 0)
|
||||||
|
ax = 0;
|
||||||
if (screen) {
|
if (screen) {
|
||||||
// Translate screen to buffer coordinates using offsets and tab expansion for x
|
// Translate screen to buffer coordinates using offsets and tab expansion for x
|
||||||
std::size_t vy = static_cast<std::size_t>(ay);
|
std::size_t vy = static_cast<std::size_t>(ay);
|
||||||
@@ -144,8 +153,11 @@ cmd_move_cursor_to(CommandContext &ctx)
|
|||||||
std::size_t by = bro + vy;
|
std::size_t by = bro + vy;
|
||||||
// Clamp by to existing lines later
|
// Clamp by to existing lines later
|
||||||
auto &lines2 = buf->Rows();
|
auto &lines2 = buf->Rows();
|
||||||
if (lines2.empty()) { lines2.emplace_back(""); }
|
if (lines2.empty()) {
|
||||||
if (by >= lines2.size()) by = lines2.size() - 1;
|
lines2.emplace_back("");
|
||||||
|
}
|
||||||
|
if (by >= lines2.size())
|
||||||
|
by = lines2.size() - 1;
|
||||||
const std::string &line2 = lines2[by];
|
const std::string &line2 = lines2[by];
|
||||||
std::size_t rx_target = bco + vx;
|
std::size_t rx_target = bco + vx;
|
||||||
std::size_t sx = inverse_render_to_source_col(line2, rx_target, 8);
|
std::size_t sx = inverse_render_to_source_col(line2, rx_target, 8);
|
||||||
@@ -164,9 +176,11 @@ cmd_move_cursor_to(CommandContext &ctx)
|
|||||||
if (lines.empty()) {
|
if (lines.empty()) {
|
||||||
lines.emplace_back("");
|
lines.emplace_back("");
|
||||||
}
|
}
|
||||||
if (row >= lines.size()) row = lines.size() - 1;
|
if (row >= lines.size())
|
||||||
|
row = lines.size() - 1;
|
||||||
const std::string &line = lines[row];
|
const std::string &line = lines[row];
|
||||||
if (col > line.size()) col = line.size();
|
if (col > line.size())
|
||||||
|
col = line.size();
|
||||||
buf->SetCursor(col, row);
|
buf->SetCursor(col, row);
|
||||||
ensure_cursor_visible(ctx.editor, *buf);
|
ensure_cursor_visible(ctx.editor, *buf);
|
||||||
return true;
|
return true;
|
||||||
@@ -357,7 +371,7 @@ cmd_refresh(CommandContext &ctx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Otherwise just a hint; renderer will redraw
|
// Otherwise just a hint; renderer will redraw
|
||||||
ctx.editor.SetStatus("Refresh requested");
|
ctx.editor.SetStatus("");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,13 +936,15 @@ cmd_page_up(CommandContext &ctx)
|
|||||||
// Clamp to valid range
|
// Clamp to valid range
|
||||||
if (rows.size() > content_rows) {
|
if (rows.size() > content_rows) {
|
||||||
std::size_t max_top = rows.size() - content_rows;
|
std::size_t max_top = rows.size() - content_rows;
|
||||||
if (rowoffs > max_top) rowoffs = max_top;
|
if (rowoffs > max_top)
|
||||||
|
rowoffs = max_top;
|
||||||
} else {
|
} else {
|
||||||
rowoffs = 0;
|
rowoffs = 0;
|
||||||
}
|
}
|
||||||
// Move cursor to first visible line, column 0
|
// Move cursor to first visible line, column 0
|
||||||
std::size_t y = rowoffs;
|
std::size_t y = rowoffs;
|
||||||
if (y >= rows.size()) y = rows.empty() ? 0 : rows.size() - 1;
|
if (y >= rows.size())
|
||||||
|
y = rows.empty() ? 0 : rows.size() - 1;
|
||||||
buf->SetOffsets(rowoffs, 0);
|
buf->SetOffsets(rowoffs, 0);
|
||||||
buf->SetCursor(0, y);
|
buf->SetCursor(0, y);
|
||||||
ensure_cursor_visible(ctx.editor, *buf);
|
ensure_cursor_visible(ctx.editor, *buf);
|
||||||
@@ -1151,8 +1167,10 @@ InstallDefaultCommands()
|
|||||||
CommandRegistry::Register({CommandId::Refresh, "refresh", "Force redraw", cmd_refresh});
|
CommandRegistry::Register({CommandId::Refresh, "refresh", "Force redraw", cmd_refresh});
|
||||||
CommandRegistry::Register(
|
CommandRegistry::Register(
|
||||||
{CommandId::KPrefix, "k-prefix", "Entering k-command prefix (show hint)", cmd_kprefix});
|
{CommandId::KPrefix, "k-prefix", "Entering k-command prefix (show hint)", cmd_kprefix});
|
||||||
CommandRegistry::Register({CommandId::UnknownKCommand, "unknown-k", "Unknown k-command (status)",
|
CommandRegistry::Register({
|
||||||
cmd_unknown_kcommand});
|
CommandId::UnknownKCommand, "unknown-k", "Unknown k-command (status)",
|
||||||
|
cmd_unknown_kcommand
|
||||||
|
});
|
||||||
CommandRegistry::Register({CommandId::FindStart, "find-start", "Begin incremental search", cmd_find_start});
|
CommandRegistry::Register({CommandId::FindStart, "find-start", "Begin incremental search", cmd_find_start});
|
||||||
CommandRegistry::Register({
|
CommandRegistry::Register({
|
||||||
CommandId::OpenFileStart, "open-file-start", "Begin open-file prompt", cmd_open_file_start
|
CommandId::OpenFileStart, "open-file-start", "Begin open-file prompt", cmd_open_file_start
|
||||||
@@ -1175,7 +1193,9 @@ InstallDefaultCommands()
|
|||||||
CommandRegistry::Register({CommandId::PageDown, "page-down", "Page down", cmd_page_down});
|
CommandRegistry::Register({CommandId::PageDown, "page-down", "Page down", cmd_page_down});
|
||||||
CommandRegistry::Register({CommandId::WordPrev, "word-prev", "Move to previous word", cmd_word_prev});
|
CommandRegistry::Register({CommandId::WordPrev, "word-prev", "Move to previous word", cmd_word_prev});
|
||||||
CommandRegistry::Register({CommandId::WordNext, "word-next", "Move to next word", cmd_word_next});
|
CommandRegistry::Register({CommandId::WordNext, "word-next", "Move to next word", cmd_word_next});
|
||||||
CommandRegistry::Register({CommandId::MoveCursorTo, "move-cursor-to", "Move cursor to y:x", cmd_move_cursor_to});
|
CommandRegistry::Register({
|
||||||
|
CommandId::MoveCursorTo, "move-cursor-to", "Move cursor to y:x", cmd_move_cursor_to
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user