mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
TextEditor: Show total character and word count without selection
This commit is contained in:
parent
46043b71cb
commit
4540c1ffab
Notes:
sideshowbarker
2024-07-18 03:41:52 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/4540c1ffab7 Pull-request: https://github.com/SerenityOS/serenity/pull/10129
2 changed files with 9 additions and 3 deletions
|
@ -809,13 +809,18 @@ void MainWidget::update_statusbar()
|
|||
{
|
||||
StringBuilder builder;
|
||||
builder.appendff("Line: {}, Column: {}", m_editor->cursor().line() + 1, m_editor->cursor().column());
|
||||
|
||||
m_statusbar->set_text(0, builder.to_string());
|
||||
builder.clear();
|
||||
if (m_editor->has_selection()) {
|
||||
String selected_text = m_editor->selected_text();
|
||||
auto word_count = m_editor->number_of_selected_words();
|
||||
builder.appendff(" Selected: {} {} ({} {})", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
|
||||
builder.appendff("{} {} ({} {}) selected", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
|
||||
} else {
|
||||
String text = m_editor->text();
|
||||
auto word_count = m_editor->number_of_words();
|
||||
builder.appendff("{} {} ({} {})", text.length(), text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
|
||||
}
|
||||
m_statusbar->set_text(builder.to_string());
|
||||
m_statusbar->set_text(1, builder.to_string());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -110,5 +110,6 @@
|
|||
|
||||
@GUI::Statusbar {
|
||||
name: "statusbar"
|
||||
label_count: 2
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue