Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
editor.cpp File Reference
#include "modules/skplaintexteditor/include/editor.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkExecutor.h"
#include "include/core/SkPath.h"
#include "src/base/SkUTF.h"
#include "modules/skplaintexteditor/src/shape.h"
#include <algorithm>
#include <cfloat>

Go to the source code of this file.

Functions

static SkRect offset (SkRect r, SkIPoint p)
 
static bool valid_utf8 (const char *ptr, size_t size)
 
template<typename F >
static void readlines (const void *data, size_t size, F f)
 
static StringSlice remove_newline (const char *str, size_t len)
 
static SkPoint to_point (SkIPoint p)
 
static bool is_utf8_continuation (char v)
 
static const char * next_utf8 (const char *p, const char *end)
 
static const char * align_utf8 (const char *p, const char *begin)
 
static const char * prev_utf8 (const char *p, const char *begin)
 
static size_t count_char (const StringSlice &string, char value)
 
static void append (char **dst, size_t *count, const char *src, size_t n)
 
static const char * begin (const StringSlice &s)
 
static const char * end (const StringSlice &s)
 
static size_t align_column (const StringSlice &str, size_t p)
 
template<typename T >
static size_t find_first_larger (const std::vector< T > &list, T value)
 
static size_t find_closest_x (const std::vector< SkRect > &bounds, float x, size_t b, size_t e)
 

Variables

static constexpr SkRect kUnsetRect {-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX}
 

Function Documentation

◆ align_column()

static size_t align_column ( const StringSlice str,
size_t  p 
)
static

Definition at line 256 of file editor.cpp.

256 {
257 if (p >= str.size()) {
258 return str.size();
259 }
260 return align_utf8(begin(str) + p, begin(str)) - begin(str);
261}
std::size_t size() const
Definition stringslice.h:27
static const char * align_utf8(const char *p, const char *begin)
Definition editor.cpp:120
static const char * begin(const StringSlice &s)
Definition editor.cpp:252

◆ align_utf8()

static const char * align_utf8 ( const char *  p,
const char *  begin 
)
static

Definition at line 120 of file editor.cpp.

120 {
121 while (p > begin && is_utf8_continuation(*p)) {
122 --p;
123 }
124 return p;
125}
static bool is_utf8_continuation(char v)
Definition editor.cpp:106

◆ append()

static void append ( char **  dst,
size_t *  count,
const char *  src,
size_t  n 
)
static

Definition at line 211 of file editor.cpp.

211 {
212 if (*dst) {
213 ::memcpy(*dst, src, n);
214 *dst += n;
215 }
216 *count += n;
217}
int count
dst
Definition cp.py:12

◆ begin()

static const char * begin ( const StringSlice s)
inlinestatic

Definition at line 252 of file editor.cpp.

252{ return s.begin(); }
struct MyStruct s

◆ count_char()

static size_t count_char ( const StringSlice string,
char  value 
)
static

Definition at line 147 of file editor.cpp.

147 {
148 size_t count = 0;
149 for (char c : string) { if (c == value) { ++count; } }
150 return count;
151}

◆ end()

static const char * end ( const StringSlice s)
inlinestatic

Definition at line 254 of file editor.cpp.

254{ return s.end(); }

◆ find_closest_x()

static size_t find_closest_x ( const std::vector< SkRect > &  bounds,
float  x,
size_t  b,
size_t  e 
)
static

Definition at line 270 of file editor.cpp.

270 {
271 if (b >= e) {
272 return b;
273 }
274 SkASSERT(e <= bounds.size());
275 size_t best_index = b;
276 float best_diff = ::fabsf(bounds[best_index].x() - x);
277 for (size_t i = b + 1; i < e; ++i) {
278 float d = ::fabsf(bounds[i].x() - x);
279 if (d < best_diff) {
280 best_diff = d;
281 best_index = i;
282 }
283 }
284 return best_index;
285}
#define SkASSERT(cond)
Definition SkAssert.h:116
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
static bool b
double x
Optional< SkRect > bounds
Definition SkRecords.h:189

◆ find_first_larger()

template<typename T >
static size_t find_first_larger ( const std::vector< T > &  list,
T  value 
)
static

Definition at line 266 of file editor.cpp.

266 {
267 return (size_t)(std::upper_bound(list.begin(), list.end(), value) - list.begin());
268}

◆ is_utf8_continuation()

static bool is_utf8_continuation ( char  v)
inlinestatic

Definition at line 106 of file editor.cpp.

106 {
107 return ((unsigned char)v & 0b11000000) ==
108 0b10000000;
109}

◆ next_utf8()

static const char * next_utf8 ( const char *  p,
const char *  end 
)
static

Definition at line 111 of file editor.cpp.

111 {
112 if (p < end) {
113 do {
114 ++p;
115 } while (p < end && is_utf8_continuation(*p));
116 }
117 return p;
118}
glong glong end

◆ offset()

static SkRect offset ( SkRect  r,
SkIPoint  p 
)
inlinestatic

Definition at line 18 of file editor.cpp.

18 {
19 return r.makeOffset((float)p.x(), (float)p.y());
20}
constexpr SkRect makeOffset(float dx, float dy) const
Definition SkRect.h:976

◆ prev_utf8()

static const char * prev_utf8 ( const char *  p,
const char *  begin 
)
static

Definition at line 127 of file editor.cpp.

127 {
128 return p > begin ? align_utf8(p - 1, begin) : begin;
129}

◆ readlines()

template<typename F >
static void readlines ( const void *  data,
size_t  size,
F  f 
)
static

Definition at line 30 of file editor.cpp.

30 {
31 const char* start = (const char*)data;
32 const char* end = start + size;
33 const char* ptr = start;
34 while (ptr < end) {
35 while (*ptr++ != '\n' && ptr < end) {}
36 size_t len = ptr - start;
37 SkASSERT(len > 0);
38 f(start, len);
39 start = ptr;
40 }
41}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ remove_newline()

static StringSlice remove_newline ( const char *  str,
size_t  len 
)
static

Definition at line 43 of file editor.cpp.

43 {
44 return SkASSERT((str != nullptr) || (len == 0)),
45 StringSlice(str, (len > 0 && str[len - 1] == '\n') ? len - 1 : len);
46}

◆ to_point()

static SkPoint to_point ( SkIPoint  p)
static

Definition at line 75 of file editor.cpp.

75{ return {(float)p.x(), (float)p.y()}; }

◆ valid_utf8()

static bool valid_utf8 ( const char *  ptr,
size_t  size 
)
static

Definition at line 24 of file editor.cpp.

24{ return SkUTF::CountUTF8(ptr, size) >= 0; }
SK_SPI int CountUTF8(const char *utf8, size_t byteLength)
Definition SkUTF.cpp:47

Variable Documentation

◆ kUnsetRect

constexpr SkRect kUnsetRect {-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX}
staticconstexpr

Definition at line 22 of file editor.cpp.

22{-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX};