mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 18:00:16 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
64
Libraries/LibUnicode/Segmenter.h
Normal file
64
Libraries/LibUnicode/Segmenter.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace Unicode {
|
||||
|
||||
enum class SegmenterGranularity {
|
||||
Grapheme,
|
||||
Sentence,
|
||||
Word,
|
||||
};
|
||||
SegmenterGranularity segmenter_granularity_from_string(StringView);
|
||||
StringView segmenter_granularity_to_string(SegmenterGranularity);
|
||||
|
||||
class Segmenter {
|
||||
public:
|
||||
static NonnullOwnPtr<Segmenter> create(SegmenterGranularity segmenter_granularity);
|
||||
static NonnullOwnPtr<Segmenter> create(StringView locale, SegmenterGranularity segmenter_granularity);
|
||||
virtual ~Segmenter() = default;
|
||||
|
||||
static bool should_continue_beyond_word(Utf8View const&);
|
||||
|
||||
SegmenterGranularity segmenter_granularity() const { return m_segmenter_granularity; }
|
||||
|
||||
virtual NonnullOwnPtr<Segmenter> clone() const = 0;
|
||||
|
||||
virtual void set_segmented_text(String) = 0;
|
||||
virtual void set_segmented_text(Utf16View const&) = 0;
|
||||
|
||||
virtual size_t current_boundary() = 0;
|
||||
|
||||
enum class Inclusive {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
virtual Optional<size_t> previous_boundary(size_t index, Inclusive = Inclusive::No) = 0;
|
||||
virtual Optional<size_t> next_boundary(size_t index, Inclusive = Inclusive::No) = 0;
|
||||
|
||||
using SegmentationCallback = Function<IterationDecision(size_t)>;
|
||||
virtual void for_each_boundary(String, SegmentationCallback) = 0;
|
||||
virtual void for_each_boundary(Utf16View const&, SegmentationCallback) = 0;
|
||||
virtual void for_each_boundary(Utf32View const&, SegmentationCallback) = 0;
|
||||
|
||||
virtual bool is_current_boundary_word_like() const = 0;
|
||||
|
||||
protected:
|
||||
explicit Segmenter(SegmenterGranularity segmenter_granularity)
|
||||
: m_segmenter_granularity(segmenter_granularity)
|
||||
{
|
||||
}
|
||||
|
||||
SegmenterGranularity m_segmenter_granularity { SegmenterGranularity::Grapheme };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue