Browse Source

Applications: Use thousands separator for numbers shown in status bar

TextEditor, HackStudio and SQLStudio now print the current line and
column number, as well as the number of currently selected words, with
thousands separators.

TextEditor also uses thousands seperators for the current word and
character count.
Tim Ledbetter 2 năm trước cách đây
mục cha
commit
0829101eb8

+ 4 - 4
Userland/Applications/TextEditor/MainWidget.cpp

@@ -230,7 +230,7 @@ MainWidget::MainWidget()
     m_statusbar->segment(1).set_clickable(true);
     m_statusbar->segment(1).set_menu(m_syntax_statusbar_menu);
     m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
-    auto width = font().width("Ln 0000, Col 000"sv) + font().max_glyph_width();
+    auto width = font().width("Ln 0,000  Col 000"sv) + font().max_glyph_width();
     m_statusbar->segment(2).set_fixed_width(width);
     m_statusbar->segment(2).set_clickable(true);
     m_statusbar->segment(2).set_menu(m_line_column_statusbar_menu);
@@ -923,11 +923,11 @@ void MainWidget::update_statusbar()
     if (m_editor->has_selection()) {
         DeprecatedString 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("{:'d} {} ({:'d} {}) selected", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
     } else {
         DeprecatedString 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");
+        builder.appendff("{:'d} {} ({:'d} {})", text.length(), text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
     }
     m_statusbar->set_text(0, builder.to_deprecated_string());
 
@@ -935,7 +935,7 @@ void MainWidget::update_statusbar()
         auto language = m_editor->syntax_highlighter()->language();
         m_statusbar->set_text(1, Syntax::language_to_string(language));
     }
-    m_statusbar->set_text(2, DeprecatedString::formatted("Ln {}, Col {}", m_editor->cursor().line() + 1, m_editor->cursor().column()));
+    m_statusbar->set_text(2, DeprecatedString::formatted("Ln {:'d}  Col {:'d}", m_editor->cursor().line() + 1, m_editor->cursor().column()));
 }
 
 void MainWidget::find_text(GUI::TextEditor::SearchDirection direction, ShowMessageIfNoResults show_message)

+ 3 - 3
Userland/DevTools/HackStudio/HackStudioWidget.cpp

@@ -152,7 +152,7 @@ ErrorOr<NonnullRefPtr<HackStudioWidget>> HackStudioWidget::create(DeprecatedStri
     widget->m_statusbar = widget->add<GUI::Statusbar>(3);
     widget->m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Auto);
     widget->m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
-    auto width = widget->font().width("Ln 0000, Col 000"sv) + widget->font().max_glyph_width();
+    auto width = widget->font().width("Ln 0,000  Col 000"sv) + widget->font().max_glyph_width();
     widget->m_statusbar->segment(2).set_fixed_width(width);
     widget->update_statusbar();
 
@@ -1611,12 +1611,12 @@ void HackStudioWidget::update_statusbar()
     if (current_editor().has_selection()) {
         DeprecatedString selected_text = current_editor().selected_text();
         auto word_count = current_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: {:'d} {} ({:'d} {})", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
     }
 
     m_statusbar->set_text(0, builder.to_deprecated_string());
     m_statusbar->set_text(1, Syntax::language_to_string(current_editor_wrapper().editor().code_document().language().value_or(Syntax::Language::PlainText)));
-    m_statusbar->set_text(2, DeprecatedString::formatted("Ln {}, Col {}", current_editor().cursor().line() + 1, current_editor().cursor().column()));
+    m_statusbar->set_text(2, DeprecatedString::formatted("Ln {:'d}  Col {:'d}", current_editor().cursor().line() + 1, current_editor().cursor().column()));
 }
 
 void HackStudioWidget::handle_external_file_deletion(DeprecatedString const& filepath)

+ 3 - 3
Userland/DevTools/SQLStudio/MainWidget.cpp

@@ -238,7 +238,7 @@ MainWidget::MainWidget()
     m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Auto);
     m_statusbar->set_text(1, "Disconnected"sv);
     m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
-    m_statusbar->segment(2).set_fixed_width(font().width("Ln 0000, Col 000"sv) + font().max_glyph_width());
+    m_statusbar->segment(2).set_fixed_width(font().width("Ln 0,000  Col 000"sv) + font().max_glyph_width());
 
     GUI::Application::the()->on_action_enter = [this](GUI::Action& action) {
         auto text = action.status_tip();
@@ -422,11 +422,11 @@ void MainWidget::update_statusbar(ScriptEditor* editor)
     if (editor->has_selection()) {
         auto character_count = editor->selected_text().length();
         auto word_count = editor->number_of_selected_words();
-        builder.appendff("Selected: {} {} ({} {})", character_count, character_count == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
+        builder.appendff("Selected: {:'d} {} ({:'d} {})", character_count, character_count == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
     }
 
     m_statusbar->set_text(0, builder.to_deprecated_string());
-    m_statusbar->set_text(2, DeprecatedString::formatted("Ln {}, Col {}", editor->cursor().line() + 1, editor->cursor().column()));
+    m_statusbar->set_text(2, DeprecatedString::formatted("Ln {:'d}  Col {:'d}", editor->cursor().line() + 1, editor->cursor().column()));
 }
 
 void MainWidget::update_editor_actions(ScriptEditor* editor)