Add text editor, misc changes
This commit is contained in:
@@ -633,27 +633,27 @@ struct Array {
|
||||
|
||||
struct UTF32Result {
|
||||
uint32_t out_str;
|
||||
int advance;
|
||||
int error;
|
||||
int64_t advance;
|
||||
int64_t error;
|
||||
};
|
||||
|
||||
struct UTF8Result {
|
||||
uint8_t out_str[4];
|
||||
int len;
|
||||
int error;
|
||||
int64_t len;
|
||||
int64_t error;
|
||||
};
|
||||
|
||||
struct UTF16Result {
|
||||
uint16_t out_str[2];
|
||||
int len;
|
||||
int error;
|
||||
int64_t len;
|
||||
int64_t error;
|
||||
};
|
||||
|
||||
struct UTF8Iter {
|
||||
char *data;
|
||||
int len;
|
||||
int utf8_codepoint_byte_size;
|
||||
int i;
|
||||
int64_t len;
|
||||
int64_t utf8_codepoint_byte_size;
|
||||
int64_t i;
|
||||
uint32_t item;
|
||||
|
||||
UTF8Iter &operator++() {
|
||||
@@ -664,7 +664,7 @@ struct UTF8Iter {
|
||||
friend bool operator!=(const UTF8Iter &a, const UTF8Iter &b) { return a.item != b.item; }
|
||||
UTF8Iter &operator*() { return *this; }
|
||||
UTF8Iter begin() {
|
||||
UTF8Iter IterateUTF8Ex(char *data, int len);
|
||||
UTF8Iter IterateUTF8Ex(char *data, int64_t len);
|
||||
return {IterateUTF8Ex(data, len)};
|
||||
}
|
||||
UTF8Iter end() { return {}; }
|
||||
@@ -674,7 +674,7 @@ using String = Slice<char>;
|
||||
using String16 = Slice<wchar_t>;
|
||||
bool IsValid(UTF8Iter &iter);
|
||||
void Advance(UTF8Iter *iter);
|
||||
UTF8Iter IterateUTF8Ex(char *data, int len);
|
||||
UTF8Iter IterateUTF8Ex(char *data, int64_t len);
|
||||
UTF8Iter IterateUTF8(char *data);
|
||||
UTF8Iter IterateUTF8(String string);
|
||||
|
||||
@@ -758,7 +758,7 @@ struct Table {
|
||||
size_t old_cap = cap;
|
||||
|
||||
values = (Entry *)AllocSize(allocator, sizeof(Entry) * size);
|
||||
for (int i = 0; i < size; i += 1) values[i] = {};
|
||||
for (int64_t i = 0; i < size; i += 1) values[i] = {};
|
||||
cap = size;
|
||||
|
||||
Assert(!(old_values == 0 && len != 0));
|
||||
@@ -983,7 +983,7 @@ struct Scratch {
|
||||
//
|
||||
#ifdef BASIC_IMPL
|
||||
|
||||
UTF32Result UTF16ToUTF32(uint16_t *c, int max_advance) {
|
||||
UTF32Result UTF16ToUTF32(uint16_t *c, int64_t max_advance) {
|
||||
UTF32Result result;
|
||||
MemoryZero(&result, sizeof(result));
|
||||
if (max_advance >= 1) {
|
||||
@@ -1032,7 +1032,7 @@ UTF8Result UTF32ToUTF8(uint32_t codepoint) {
|
||||
return result;
|
||||
}
|
||||
|
||||
UTF32Result UTF8ToUTF32(char *c, int max_advance) {
|
||||
UTF32Result UTF8ToUTF32(char *c, int64_t max_advance) {
|
||||
UTF32Result result;
|
||||
MemoryZero(&result, sizeof(result));
|
||||
|
||||
@@ -1101,7 +1101,7 @@ UTF16Result UTF32ToUTF16(uint32_t codepoint) {
|
||||
int64_t CreateCharFromWidechar(char *buffer, int64_t buffer_size, wchar_t *in, int64_t inlen) {
|
||||
int64_t outlen = 0;
|
||||
for (int64_t i = 0; i < inlen && in[i];) {
|
||||
UTF32Result decode = UTF16ToUTF32((uint16_t *)(in + i), (int)(inlen - i));
|
||||
UTF32Result decode = UTF16ToUTF32((uint16_t *)(in + i), (int64_t)(inlen - i));
|
||||
if (!decode.error) {
|
||||
i += decode.advance;
|
||||
UTF8Result encode = UTF32ToUTF8(decode.out_str);
|
||||
@@ -1122,7 +1122,7 @@ int64_t CreateCharFromWidechar(char *buffer, int64_t buffer_size, wchar_t *in, i
|
||||
int64_t CreateWidecharFromChar(wchar_t *buffer, int64_t buffer_size, char *in, int64_t inlen) {
|
||||
int64_t outlen = 0;
|
||||
for (int64_t i = 0; i < inlen;) {
|
||||
UTF32Result decode = UTF8ToUTF32(in + i, (int)(inlen - i));
|
||||
UTF32Result decode = UTF8ToUTF32(in + i, (int64_t)(inlen - i));
|
||||
if (!decode.error) {
|
||||
i += decode.advance;
|
||||
UTF16Result encode = UTF32ToUTF16(decode.out_str);
|
||||
@@ -1156,7 +1156,7 @@ void Advance(UTF8Iter *iter) {
|
||||
iter->item = r.out_str;
|
||||
}
|
||||
|
||||
UTF8Iter IterateUTF8Ex(char *data, int len) {
|
||||
UTF8Iter IterateUTF8Ex(char *data, int64_t len) {
|
||||
UTF8Iter result;
|
||||
MemoryZero(&result, sizeof(result));
|
||||
result.data = data;
|
||||
@@ -1166,7 +1166,7 @@ UTF8Iter IterateUTF8Ex(char *data, int len) {
|
||||
}
|
||||
|
||||
UTF8Iter IterateUTF8(char *data) {
|
||||
int length = 0;
|
||||
int64_t length = 0;
|
||||
while (data[length]) length += 1;
|
||||
return IterateUTF8Ex(data, length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user