diff options
author | Nico Weber <thakis@chromium.org> | 2020-08-05 16:28:19 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-05 22:33:42 +0200 |
commit | 19ac1f6368c91cc00a68717001ea4eae65567a47 (patch) | |
tree | 65e4e9a85f0a39085c80bf954d5889e396e0ee4e /Libraries/LibGUI | |
parent | 9664bac281c72822da59e7f83af65d4f411d10a5 (diff) | |
download | serenity-19ac1f6368c91cc00a68717001ea4eae65567a47.zip |
Revert "Unicode: s/codepoint/code_point/g"
This reverts commit ea9ac3155d1774f13ac4e9a96605c0e85a8f299e.
It replaced "codepoint" with "code_points", not "code_point".
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r-- | Libraries/LibGUI/EmojiInputDialog.cpp | 20 | ||||
-rw-r--r-- | Libraries/LibGUI/Event.h | 2 | ||||
-rw-r--r-- | Libraries/LibGUI/TextDocument.cpp | 76 | ||||
-rw-r--r-- | Libraries/LibGUI/TextDocument.h | 6 | ||||
-rw-r--r-- | Libraries/LibGUI/TextEditor.cpp | 20 |
5 files changed, 62 insertions, 62 deletions
diff --git a/Libraries/LibGUI/EmojiInputDialog.cpp b/Libraries/LibGUI/EmojiInputDialog.cpp index e4141ec191..f345cf7f49 100644 --- a/Libraries/LibGUI/EmojiInputDialog.cpp +++ b/Libraries/LibGUI/EmojiInputDialog.cpp @@ -37,9 +37,9 @@ namespace GUI { -static Vector<u32> supported_emoji_code_pointss() +static Vector<u32> supported_emoji_codepoints() { - Vector<u32> code_pointss; + Vector<u32> codepoints; Core::DirIterator dt("/res/emoji", Core::DirIterator::SkipDots); while (dt.has_next()) { auto filename = dt.next_path(); @@ -49,10 +49,10 @@ static Vector<u32> supported_emoji_code_pointss() auto basename = lexical_path.basename(); if (!basename.starts_with("U+")) continue; - u32 code_points = strtoul(basename.characters() + 2, nullptr, 16); - code_pointss.append(code_points); + u32 codepoint = strtoul(basename.characters() + 2, nullptr, 16); + codepoints.append(codepoint); } - return code_pointss; + return codepoints; } EmojiInputDialog::EmojiInputDialog(Window* parent_window) @@ -67,20 +67,20 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window) auto& main_layout = main_widget.set_layout<VerticalBoxLayout>(); main_layout.set_spacing(0); - auto code_pointss = supported_emoji_code_pointss(); + auto codepoints = supported_emoji_codepoints(); size_t index = 0; size_t columns = 6; - size_t rows = ceil_div(code_pointss.size(), columns); + size_t rows = ceil_div(codepoints.size(), columns); - for (size_t row = 0; row < rows && index < code_pointss.size(); ++row) { + for (size_t row = 0; row < rows && index < codepoints.size(); ++row) { auto& horizontal_container = main_widget.add<Widget>(); auto& horizontal_layout = horizontal_container.set_layout<HorizontalBoxLayout>(); horizontal_layout.set_spacing(0); for (size_t column = 0; column < columns; ++column) { - if (index < code_pointss.size()) { + if (index < codepoints.size()) { StringBuilder builder; - builder.append(Utf32View(&code_pointss[index++], 1)); + builder.append(Utf32View(&codepoints[index++], 1)); auto emoji_text = builder.to_string(); auto& button = horizontal_container.add<Button>(emoji_text); button.set_button_style(Gfx::ButtonStyle::CoolBar); diff --git a/Libraries/LibGUI/Event.h b/Libraries/LibGUI/Event.h index 76f7859138..f5ab95ce14 100644 --- a/Libraries/LibGUI/Event.h +++ b/Libraries/LibGUI/Event.h @@ -298,7 +298,7 @@ public: String text() const { StringBuilder sb; - sb.append_code_points(m_code_point); + sb.append_codepoint(m_code_point); return sb.to_string(); } u32 scancode() const { return m_scancode; } diff --git a/Libraries/LibGUI/TextDocument.cpp b/Libraries/LibGUI/TextDocument.cpp index b8d86977da..4d13b99510 100644 --- a/Libraries/LibGUI/TextDocument.cpp +++ b/Libraries/LibGUI/TextDocument.cpp @@ -87,8 +87,8 @@ void TextDocument::set_text(const StringView& text) size_t TextDocumentLine::first_non_whitespace_column() const { for (size_t i = 0; i < length(); ++i) { - auto code_points = code_pointss()[i]; - if (!isspace(code_points)) + auto codepoint = codepoints()[i]; + if (!isspace(codepoint)) return i; } return length(); @@ -131,35 +131,35 @@ void TextDocumentLine::set_text(TextDocument& document, const StringView& text) } m_text.clear(); Utf8View utf8_view(text); - for (auto code_points : utf8_view) - m_text.append(code_points); + for (auto codepoint : utf8_view) + m_text.append(codepoint); document.update_views({}); } -void TextDocumentLine::append(TextDocument& document, const u32* code_pointss, size_t length) +void TextDocumentLine::append(TextDocument& document, const u32* codepoints, size_t length) { if (length == 0) return; - m_text.append(code_pointss, length); + m_text.append(codepoints, length); document.update_views({}); } -void TextDocumentLine::append(TextDocument& document, u32 code_points) +void TextDocumentLine::append(TextDocument& document, u32 codepoint) { - insert(document, length(), code_points); + insert(document, length(), codepoint); } -void TextDocumentLine::prepend(TextDocument& document, u32 code_points) +void TextDocumentLine::prepend(TextDocument& document, u32 codepoint) { - insert(document, 0, code_points); + insert(document, 0, codepoint); } -void TextDocumentLine::insert(TextDocument& document, size_t index, u32 code_points) +void TextDocumentLine::insert(TextDocument& document, size_t index, u32 codepoint) { if (index == length()) { - m_text.append(code_points); + m_text.append(codepoint); } else { - m_text.insert(index, code_points); + m_text.insert(index, codepoint); } document.update_views({}); } @@ -274,7 +274,7 @@ String TextDocument::text_in_range(const TextRange& a_range) const auto& line = this->line(i); size_t selection_start_column_on_line = range.start().line() == i ? range.start().column() : 0; size_t selection_end_column_on_line = range.end().line() == i ? range.end().column() : line.length(); - builder.append(Utf32View(line.code_pointss() + selection_start_column_on_line, selection_end_column_on_line - selection_start_column_on_line)); + builder.append(Utf32View(line.codepoints() + selection_start_column_on_line, selection_end_column_on_line - selection_start_column_on_line)); if (i != range.end().line()) builder.append('\n'); } @@ -282,13 +282,13 @@ String TextDocument::text_in_range(const TextRange& a_range) const return builder.to_string(); } -u32 TextDocument::code_points_at(const TextPosition& position) const +u32 TextDocument::codepoint_at(const TextPosition& position) const { ASSERT(position.line() < line_count()); auto& line = this->line(position.line()); if (position.column() == line.length()) return '\n'; - return line.code_pointss()[position.column()]; + return line.codepoints()[position.column()]; } TextPosition TextDocument::next_position_after(const TextPosition& position, SearchShouldWrap should_wrap) const @@ -333,7 +333,7 @@ TextRange TextDocument::find_next(const StringView& needle, const TextPosition& size_t needle_index = 0; do { - auto ch = code_points_at(position); + auto ch = codepoint_at(position); // FIXME: This is not the right way to use a Unicode needle! if (ch == (u32)needle[needle_index]) { if (needle_index == 0) @@ -365,7 +365,7 @@ TextRange TextDocument::find_previous(const StringView& needle, const TextPositi size_t needle_index = needle.length() - 1; do { - auto ch = code_points_at(position); + auto ch = codepoint_at(position); // FIXME: This is not the right way to use a Unicode needle! if (ch == (u32)needle[needle_index]) { if (needle_index == needle.length() - 1) @@ -439,11 +439,11 @@ TextPosition TextDocument::first_word_break_before(const TextPosition& position, auto target = position; auto line = this->line(target.line()); - auto is_start_alphanumeric = isalnum(line.code_pointss()[target.column() - (start_at_column_before ? 1 : 0)]); + auto is_start_alphanumeric = isalnum(line.codepoints()[target.column() - (start_at_column_before ? 1 : 0)]); while (target.column() > 0) { - auto prev_code_points = line.code_pointss()[target.column() - 1]; - if ((is_start_alphanumeric && !isalnum(prev_code_points)) || (!is_start_alphanumeric && isalnum(prev_code_points))) + auto prev_codepoint = line.codepoints()[target.column() - 1]; + if ((is_start_alphanumeric && !isalnum(prev_codepoint)) || (!is_start_alphanumeric && isalnum(prev_codepoint))) break; target.set_column(target.column() - 1); } @@ -463,11 +463,11 @@ TextPosition TextDocument::first_word_break_after(const TextPosition& position) return TextPosition(position.line() + 1, 0); } - auto is_start_alphanumeric = isalnum(line.code_pointss()[target.column()]); + auto is_start_alphanumeric = isalnum(line.codepoints()[target.column()]); while (target.column() < line.length()) { - auto next_code_points = line.code_pointss()[target.column()]; - if ((is_start_alphanumeric && !isalnum(next_code_points)) || (!is_start_alphanumeric && isalnum(next_code_points))) + auto next_codepoint = line.codepoints()[target.column()]; + if ((is_start_alphanumeric && !isalnum(next_codepoint)) || (!is_start_alphanumeric && isalnum(next_codepoint))) break; target.set_column(target.column() + 1); } @@ -555,26 +555,26 @@ TextPosition TextDocument::insert_at(const TextPosition& position, const StringV { TextPosition cursor = position; Utf8View utf8_view(text); - for (auto code_points : utf8_view) - cursor = insert_at(cursor, code_points, client); + for (auto codepoint : utf8_view) + cursor = insert_at(cursor, codepoint, client); return cursor; } -TextPosition TextDocument::insert_at(const TextPosition& position, u32 code_points, const Client* client) +TextPosition TextDocument::insert_at(const TextPosition& position, u32 codepoint, const Client* client) { bool automatic_indentation_enabled = client ? client->is_automatic_indentation_enabled() : false; size_t m_soft_tab_width = client ? client->soft_tab_width() : 4; bool at_head = position.column() == 0; bool at_tail = position.column() == line(position.line()).length(); - if (code_points == '\n') { + if (codepoint == '\n') { if (at_tail || at_head) { String new_line_contents; if (automatic_indentation_enabled && at_tail) { size_t leading_spaces = 0; auto& old_line = lines()[position.line()]; for (size_t i = 0; i < old_line.length(); ++i) { - if (old_line.code_pointss()[i] == ' ') + if (old_line.codepoints()[i] == ' ') ++leading_spaces; else break; @@ -586,23 +586,23 @@ TextPosition TextDocument::insert_at(const TextPosition& position, u32 code_poin size_t row = position.line(); Vector<u32> line_content; for (size_t i = position.column(); i < line(row).length(); i++) - line_content.append(line(row).code_pointss()[i]); + line_content.append(line(row).codepoints()[i]); insert_line(position.line() + (at_tail ? 1 : 0), make<TextDocumentLine>(*this, new_line_contents)); notify_did_change(); return { position.line() + 1, line(position.line() + 1).length() }; } auto new_line = make<TextDocumentLine>(*this); - new_line->append(*this, line(position.line()).code_pointss() + position.column(), line(position.line()).length() - position.column()); + new_line->append(*this, line(position.line()).codepoints() + position.column(), line(position.line()).length() - position.column()); Vector<u32> line_content; for (size_t i = 0; i < new_line->length(); i++) - line_content.append(new_line->code_pointss()[i]); + line_content.append(new_line->codepoints()[i]); line(position.line()).truncate(*this, position.column()); insert_line(position.line() + 1, move(new_line)); notify_did_change(); return { position.line() + 1, 0 }; } - if (code_points == '\t') { + if (codepoint == '\t') { size_t next_soft_tab_stop = ((position.column() + m_soft_tab_width) / m_soft_tab_width) * m_soft_tab_width; size_t spaces_to_insert = next_soft_tab_stop - position.column(); for (size_t i = 0; i < spaces_to_insert; ++i) { @@ -611,7 +611,7 @@ TextPosition TextDocument::insert_at(const TextPosition& position, u32 code_poin notify_did_change(); return { position.line(), next_soft_tab_stop }; } - line(position.line()).insert(*this, position.column(), code_points); + line(position.line()).insert(*this, position.column(), codepoint); notify_did_change(); return { position.line(), position.column() + 1 }; } @@ -644,10 +644,10 @@ void TextDocument::remove(const TextRange& unnormalized_range) ASSERT(range.start().line() == range.end().line() - 1); auto& first_line = line(range.start().line()); auto& second_line = line(range.end().line()); - Vector<u32> code_pointss; - code_pointss.append(first_line.code_pointss(), range.start().column()); - code_pointss.append(second_line.code_pointss() + range.end().column(), second_line.length() - range.end().column()); - first_line.set_text(*this, move(code_pointss)); + Vector<u32> codepoints; + codepoints.append(first_line.codepoints(), range.start().column()); + codepoints.append(second_line.codepoints() + range.end().column(), second_line.length() - range.end().column()); + first_line.set_text(*this, move(codepoints)); remove_line(range.end().line()); } diff --git a/Libraries/LibGUI/TextDocument.h b/Libraries/LibGUI/TextDocument.h index 062589a7c8..8fa922dd2f 100644 --- a/Libraries/LibGUI/TextDocument.h +++ b/Libraries/LibGUI/TextDocument.h @@ -113,7 +113,7 @@ public: TextPosition next_position_after(const TextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const; TextPosition previous_position_before(const TextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const; - u32 code_points_at(const TextPosition&) const; + u32 codepoint_at(const TextPosition&) const; TextRange range_for_entire_line(size_t line_index) const; @@ -159,8 +159,8 @@ public: String to_utf8() const; - Utf32View view() const { return { code_pointss(), length() }; } - const u32* code_pointss() const { return m_text.data(); } + Utf32View view() const { return { codepoints(), length() }; } + const u32* codepoints() const { return m_text.data(); } size_t length() const { return m_text.size(); } void set_text(TextDocument&, const StringView&); void set_text(TextDocument&, Vector<u32>); diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp index 50cd6b989f..bb2796b7fa 100644 --- a/Libraries/LibGUI/TextEditor.cpp +++ b/Libraries/LibGUI/TextEditor.cpp @@ -172,7 +172,7 @@ TextPosition TextEditor::text_position_at(const Gfx::IntPoint& a_position) const int glyph_x = 0; size_t i = 0; for (; i < view.length(); ++i) { - int advance = font().glyph_width(view.code_pointss()[i]) + font().glyph_spacing(); + int advance = font().glyph_width(view.codepoints()[i]) + font().glyph_spacing(); if ((glyph_x + (advance / 2)) >= position.x()) break; glyph_x += advance; @@ -465,7 +465,7 @@ void TextEditor::paint_event(PaintEvent& event) } else { Gfx::IntRect character_rect = { visual_line_rect.location(), { 0, line_height() } }; for (size_t i = 0; i < visual_line_text.length(); ++i) { - u32 code_points = visual_line_text.substring_view(i, 1).code_pointss()[0]; + u32 codepoint = visual_line_text.substring_view(i, 1).codepoints()[0]; const Gfx::Font* font = &this->font(); Color color; Optional<Color> background_color; @@ -482,7 +482,7 @@ void TextEditor::paint_event(PaintEvent& event) underline = span.is_underlined; break; } - character_rect.set_width(font->glyph_width(code_points) + font->glyph_spacing()); + character_rect.set_width(font->glyph_width(codepoint) + font->glyph_spacing()); if (background_color.has_value()) painter.fill_rect(character_rect, background_color.value()); painter.draw_text(character_rect, visual_line_text.substring_view(i, 1), *font, m_text_alignment, color); @@ -524,9 +524,9 @@ void TextEditor::paint_event(PaintEvent& event) painter.fill_rect(selection_rect, background_color); - if (visual_line_text.code_pointss()) { + if (visual_line_text.codepoints()) { Utf32View visual_selected_text { - visual_line_text.code_pointss() + start_of_selection_within_visual_line, + visual_line_text.codepoints() + start_of_selection_within_visual_line, end_of_selection_within_visual_line - start_of_selection_within_visual_line }; @@ -660,7 +660,7 @@ void TextEditor::sort_selected_lines() auto end = lines.begin() + (int)last_line + 1; quick_sort(start, end, [](auto& a, auto& b) { - return strcmp_utf32(a.code_pointss(), b.code_pointss(), min(a.length(), b.length())) < 0; + return strcmp_utf32(a.codepoints(), b.codepoints(), min(a.length(), b.length())) < 0; }); did_change(); @@ -939,7 +939,7 @@ void TextEditor::keydown_event(KeyEvent& event) if (is_editable() && !event.ctrl() && !event.alt() && event.code_point() != 0) { StringBuilder sb; - sb.append_code_points(event.code_point()); + sb.append_codepoint(event.code_point()); insert_at_cursor_or_replace_selection(sb.to_string()); return; @@ -1525,8 +1525,8 @@ void TextEditor::recompute_visual_lines(size_t line_index) auto glyph_spacing = font().glyph_spacing(); for (size_t i = 0; i < line.length(); ++i) { - auto code_points = line.code_pointss()[i]; - auto glyph_width = font().glyph_or_emoji_width(code_points); + auto codepoint = line.codepoints()[i]; + auto glyph_width = font().glyph_or_emoji_width(codepoint); if ((line_width_so_far + glyph_width + glyph_spacing) > available_width) { visual_data.visual_line_breaks.append(i); line_width_so_far = glyph_width + glyph_spacing; @@ -1555,7 +1555,7 @@ void TextEditor::for_each_visual_line(size_t line_index, Callback callback) cons auto& visual_data = m_line_visual_data[line_index]; for (auto visual_line_break : visual_data.visual_line_breaks) { - auto visual_line_view = Utf32View(line.code_pointss() + start_of_line, visual_line_break - start_of_line); + auto visual_line_view = Utf32View(line.codepoints() + start_of_line, visual_line_break - start_of_line); Gfx::IntRect visual_line_rect { visual_data.visual_rect.x(), visual_data.visual_rect.y() + ((int)visual_line_index * line_height()), |