new utf8 <-> utf16 code
parent
64a2a75300
commit
59267a6418
|
@ -1,39 +1,39 @@
|
|||
enum{
|
||||
key_back = 57344,
|
||||
key_up = 57345,
|
||||
key_down = 57346,
|
||||
key_left = 57347,
|
||||
key_right = 57348,
|
||||
key_del = 57349,
|
||||
key_insert = 57350,
|
||||
key_home = 57351,
|
||||
key_end = 57352,
|
||||
key_page_up = 57353,
|
||||
key_page_down = 57354,
|
||||
key_esc = 57355,
|
||||
key_mouse_left = 57356,
|
||||
key_mouse_right = 57357,
|
||||
key_mouse_left_release = 57358,
|
||||
key_mouse_right_release = 57359,
|
||||
key_f1 = 57360,
|
||||
key_f2 = 57361,
|
||||
key_f3 = 57362,
|
||||
key_f4 = 57363,
|
||||
key_f5 = 57364,
|
||||
key_f6 = 57365,
|
||||
key_f7 = 57366,
|
||||
key_f8 = 57367,
|
||||
key_f9 = 57368,
|
||||
key_f10 = 57369,
|
||||
key_f11 = 57370,
|
||||
key_f12 = 57371,
|
||||
key_f13 = 57372,
|
||||
key_f14 = 57373,
|
||||
key_f15 = 57374,
|
||||
key_f16 = 57375,
|
||||
key_back = 55296,
|
||||
key_up = 55297,
|
||||
key_down = 55298,
|
||||
key_left = 55299,
|
||||
key_right = 55300,
|
||||
key_del = 55301,
|
||||
key_insert = 55302,
|
||||
key_home = 55303,
|
||||
key_end = 55304,
|
||||
key_page_up = 55305,
|
||||
key_page_down = 55306,
|
||||
key_esc = 55307,
|
||||
key_mouse_left = 55308,
|
||||
key_mouse_right = 55309,
|
||||
key_mouse_left_release = 55310,
|
||||
key_mouse_right_release = 55311,
|
||||
key_f1 = 55312,
|
||||
key_f2 = 55313,
|
||||
key_f3 = 55314,
|
||||
key_f4 = 55315,
|
||||
key_f5 = 55316,
|
||||
key_f6 = 55317,
|
||||
key_f7 = 55318,
|
||||
key_f8 = 55319,
|
||||
key_f9 = 55320,
|
||||
key_f10 = 55321,
|
||||
key_f11 = 55322,
|
||||
key_f12 = 55323,
|
||||
key_f13 = 55324,
|
||||
key_f14 = 55325,
|
||||
key_f15 = 55326,
|
||||
key_f16 = 55327,
|
||||
};
|
||||
static char*
|
||||
global_key_name(int32_t key_code, int32_t *size){
|
||||
global_key_name(uint32_t key_code, int32_t *size){
|
||||
char *result = 0;
|
||||
switch(key_code){
|
||||
case key_back: result = "back"; *size = sizeof("back")-1; break;
|
||||
|
|
|
@ -13,6 +13,8 @@ TYPE: 'drop-in-command-pack'
|
|||
#include "4coder_helper/4coder_helper.h"
|
||||
#include "4coder_helper/4coder_long_seek.h"
|
||||
|
||||
#include "4coder_lib/4coder_utf8.h"
|
||||
|
||||
//
|
||||
// Fundamental Editing Commands
|
||||
//
|
||||
|
|
|
@ -33,11 +33,10 @@ TYPE: 'major-system-include'
|
|||
#include "4coder_lib/4coder_string.h"
|
||||
#include "4coder_lib/4coder_table.h"
|
||||
#include "4coder_lib/4coder_mem.h"
|
||||
#include "4coder_lib/4coder_utf8.h"
|
||||
|
||||
#include "4cpp/4cpp_lexer.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//
|
||||
// Seeks Using Default Framework Memory
|
||||
//
|
||||
|
|
|
@ -63,7 +63,7 @@ to_writable_char(Key_Code long_character){
|
|||
character = '\t';
|
||||
}
|
||||
}
|
||||
else if (long_character >= ' ' && long_character <= 255 && long_character != 127){
|
||||
else if (long_character <= 255 && long_character != 127){
|
||||
character = (char)long_character;
|
||||
}
|
||||
return(character);
|
||||
|
|
|
@ -7,6 +7,8 @@ recognized, you are granted a perpetual, irrevocable license to copy,
|
|||
distribute, and modify this file as you see fit.
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#if !defined(FCODER_MEM_H)
|
||||
#define FCODER_MEM_H
|
||||
|
||||
|
@ -24,6 +26,8 @@ typedef uint16_t u16_4tech;
|
|||
typedef uint32_t u32_4tech;
|
||||
typedef uint64_t u64_4tech;
|
||||
|
||||
typedef u64_4tech umem_4tech;
|
||||
|
||||
typedef float f32_4tech;
|
||||
typedef double f64_4tech;
|
||||
|
||||
|
@ -349,3 +353,5 @@ general_memory_reallocate_nocopy(General_Memory *general, void *old, i32_4tech s
|
|||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ typedef uint16_t u16_4tech;
|
|||
typedef uint32_t u32_4tech;
|
||||
typedef uint64_t u64_4tech;
|
||||
|
||||
typedef u64_4tech umem_4tech;
|
||||
|
||||
typedef float f32_4tech;
|
||||
typedef double f64_4tech;
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ typedef uint16_t u16_4tech;
|
|||
typedef uint32_t u32_4tech;
|
||||
typedef uint64_t u64_4tech;
|
||||
|
||||
typedef u64_4tech umem_4tech;
|
||||
|
||||
typedef float f32_4tech;
|
||||
typedef double f64_4tech;
|
||||
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 17.02.2017
|
||||
*
|
||||
* Code for converting to and from utf8 to ANSI and utf16 text encodings.
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#if !defined(FED_UTF8_CONVERSION_H)
|
||||
#define FED_UTF8_CONVERSION_H
|
||||
|
||||
// 4tech_standard_preamble.h
|
||||
#if !defined(FTECH_INTEGERS)
|
||||
#define FTECH_INTEGERS
|
||||
#include <stdint.h>
|
||||
typedef int8_t i8_4tech;
|
||||
typedef int16_t i16_4tech;
|
||||
typedef int32_t i32_4tech;
|
||||
typedef int64_t i64_4tech;
|
||||
|
||||
typedef uint8_t u8_4tech;
|
||||
typedef uint16_t u16_4tech;
|
||||
typedef uint32_t u32_4tech;
|
||||
typedef uint64_t u64_4tech;
|
||||
|
||||
typedef u64_4tech umem_4tech;
|
||||
|
||||
typedef float f32_4tech;
|
||||
typedef double f64_4tech;
|
||||
|
||||
typedef int8_t b8_4tech;
|
||||
typedef int32_t b32_4tech;
|
||||
#endif
|
||||
|
||||
#if !defined(Assert)
|
||||
# define Assert(n) do{ if (!(n)) *(int*)0 = 0xA11E; }while(0)
|
||||
#endif
|
||||
// standard preamble end
|
||||
|
||||
static u32_4tech
|
||||
utf8_to_u32_unchecked(u8_4tech *buffer){
|
||||
u32_4tech result = 0;
|
||||
|
||||
if (buffer[0] <= 0x7F){
|
||||
result = (u32_4tech)buffer[0];
|
||||
}
|
||||
else if (buffer[0] <= 0xE0){
|
||||
result = ((u32_4tech)((buffer[0])&0x1F)) << 6;
|
||||
result |= ((u32_4tech)((buffer[1])&0x3F));
|
||||
}
|
||||
else if (buffer[0] <= 0xF0){
|
||||
result = ((u32_4tech)((buffer[0])&0x0F)) << 12;
|
||||
result |= ((u32_4tech)((buffer[1])&0x3F)) << 6;
|
||||
result |= ((u32_4tech)((buffer[2])&0x3F));
|
||||
}
|
||||
else{
|
||||
result = ((u32_4tech)((buffer[0])&0x07)) << 18;
|
||||
result |= ((u32_4tech)((buffer[1])&0x3F)) << 12;
|
||||
result |= ((u32_4tech)((buffer[2])&0x3F)) << 6;
|
||||
result |= ((u32_4tech)((buffer[3])&0x3F));
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
static umem_4tech
|
||||
utf8_to_utf16_minimal_checking(u16_4tech *dst, umem_4tech max_wchars, u8_4tech *src, umem_4tech length, b32_4tech *error){
|
||||
u8_4tech *s = src;
|
||||
u8_4tech *s_end = s + length;
|
||||
|
||||
u16_4tech *d = dst;
|
||||
u16_4tech *d_end = d + max_wchars;
|
||||
umem_4tech limit = length;
|
||||
|
||||
umem_4tech needed_max = 0;
|
||||
u32_4tech advance = 1;
|
||||
|
||||
*error = false;
|
||||
for(; s < s_end;){
|
||||
u32_4tech code_point = 0;
|
||||
u32_4tech utf8_size = 0;
|
||||
|
||||
if (s[0] <= 0x7F){
|
||||
code_point = (u32_4tech)s[0];
|
||||
utf8_size = 1;
|
||||
}
|
||||
else if (s[0] <= 0xE0){
|
||||
if (limit <= 1){
|
||||
*error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
code_point = ((u32_4tech)((s[0])&0x1F)) << 6;
|
||||
code_point |= ((u32_4tech)((s[1])&0x3F));
|
||||
utf8_size = 2;
|
||||
}
|
||||
else if (s[0] <= 0xF0){
|
||||
if (limit <= 2){
|
||||
*error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
code_point = ((u32_4tech)((s[0])&0x0F)) << 12;
|
||||
code_point |= ((u32_4tech)((s[1])&0x3F)) << 6;
|
||||
code_point |= ((u32_4tech)((s[2])&0x3F));
|
||||
utf8_size = 3;
|
||||
}
|
||||
else{
|
||||
if (limit > 3){
|
||||
*error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
code_point = ((u32_4tech)((s[0])&0x07)) << 18;
|
||||
code_point |= ((u32_4tech)((s[1])&0x3F)) << 12;
|
||||
code_point |= ((u32_4tech)((s[2])&0x3F)) << 6;
|
||||
code_point |= ((u32_4tech)((s[3])&0x3F));
|
||||
utf8_size = 4;
|
||||
}
|
||||
|
||||
s += utf8_size;
|
||||
limit -= utf8_size;
|
||||
|
||||
if (code_point <= 0xD7FF || (code_point >= 0xE000 && code_point <= 0xFFFF)){
|
||||
*d = (u16_4tech)(code_point);
|
||||
d += advance;
|
||||
needed_max += 1;
|
||||
}
|
||||
else if (code_point >= 0x10000 && code_point <= 0x10FFFF){
|
||||
code_point -= 0x10000;
|
||||
|
||||
u32_4tech high = (code_point >> 10) & 0x03FF;
|
||||
u32_4tech low = (code_point) & 0x03FF;
|
||||
|
||||
high += 0xD800;
|
||||
low += 0xDC00;
|
||||
|
||||
if (d + advance < d_end){
|
||||
*d = (u16_4tech)high;
|
||||
d += advance;
|
||||
*d = (u16_4tech)low;
|
||||
d += advance;
|
||||
}
|
||||
else{
|
||||
advance = 0;
|
||||
}
|
||||
|
||||
needed_max += 2;
|
||||
}
|
||||
else{
|
||||
*error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (d >= d_end){
|
||||
advance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return(needed_max);
|
||||
}
|
||||
|
||||
static umem_4tech
|
||||
utf16_to_utf8_minimal_checking(u8_4tech *dst, umem_4tech max_chars, u16_4tech *src, umem_4tech length, b32_4tech *error){
|
||||
u16_4tech *s = src;
|
||||
u16_4tech *s_end = s + max_chars;
|
||||
|
||||
u8_4tech *d = dst;
|
||||
u8_4tech *d_end = d + length;
|
||||
umem_4tech limit = length;
|
||||
|
||||
umem_4tech needed_max = 0;
|
||||
|
||||
*error = false;
|
||||
|
||||
for (; s < s_end;){
|
||||
u32_4tech code_point = 0;
|
||||
u32_4tech utf16_size = 0;
|
||||
|
||||
if (s[0] <= 0xD7FF || (s[0] >= 0xE000 && s[0] <= 0xFFFF)){
|
||||
code_point = s[0];
|
||||
utf16_size = 1;
|
||||
}
|
||||
else{
|
||||
if (s[0] >= 0xD800 && s[0] <= 0xDBFF){
|
||||
if (limit <= 1){
|
||||
*error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
u32_4tech high = s[0] - 0xD800;
|
||||
u32_4tech low = s[1] - 0xDC00;
|
||||
code_point = ((high << 10) | (low)) + 0x10000;
|
||||
utf16_size = 2;
|
||||
}
|
||||
else{
|
||||
*error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s += utf16_size;
|
||||
limit -= utf16_size;
|
||||
|
||||
u8_4tech d_fill[4];
|
||||
u32_4tech d_fill_count = 0;
|
||||
|
||||
if (code_point <= 0x7F){
|
||||
d_fill[0] = (u8_4tech)code_point;
|
||||
d_fill_count = 1;
|
||||
}
|
||||
else if (code_point <= 0x7FF){
|
||||
d_fill[0] = (u8_4tech)(0xC0 | (code_point >> 6));
|
||||
d_fill[1] = (u8_4tech)(0x80 | (code_point & 0x3F));
|
||||
d_fill_count = 2;
|
||||
}
|
||||
else if (code_point <= 0xFFFF){
|
||||
d_fill[0] = (u8_4tech)(0xE0 | (code_point >> 12));
|
||||
d_fill[1] = (u8_4tech)(0x80 | ((code_point >> 6) & 0x3F));
|
||||
d_fill[2] = (u8_4tech)(0x80 | (code_point & 0x3F));
|
||||
d_fill_count = 3;
|
||||
}
|
||||
else if (code_point <= 0x10FFFF){
|
||||
d_fill[0] = (u8_4tech)(0xF0 | (code_point >> 18));
|
||||
d_fill[1] = (u8_4tech)(0x80 | ((code_point >> 12) & 0x3F));
|
||||
d_fill[2] = (u8_4tech)(0x80 | ((code_point >> 6) & 0x3F));
|
||||
d_fill[3] = (u8_4tech)(0x80 | (code_point & 0x3F));
|
||||
d_fill_count = 4;
|
||||
}
|
||||
else{
|
||||
*error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (d + d_fill_count <= d_end){
|
||||
for (u32_4tech i = 0; i < d_fill_count; ++i){
|
||||
*d = d_fill[i];
|
||||
++d;
|
||||
}
|
||||
}
|
||||
needed_max += d_fill_count;
|
||||
}
|
||||
|
||||
return(needed_max);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
30
4ed.cpp
30
4ed.cpp
|
@ -579,8 +579,7 @@ app_links_init(System_Functions *system, Application_Links *app_links, void *dat
|
|||
internal void
|
||||
setup_ui_commands(Command_Map *commands, Partition *part, Command_Map *parent){
|
||||
map_init(commands, part, 32, parent);
|
||||
|
||||
commands->vanilla_keyboard_default.function = command_null;
|
||||
map_clear(commands);
|
||||
|
||||
// TODO(allen): This is hacky, when the new UI stuff happens, let's fix it,
|
||||
// and by that I mean actually fix it, don't just say you fixed it with
|
||||
|
@ -1294,27 +1293,28 @@ App_Init_Sig(app_init){
|
|||
i32 mapid = unit->map_begin.mapid;
|
||||
i32 count = map_get_max_count(models, mapid);
|
||||
i32 table_max = count * 3 / 2;
|
||||
b32 auto_clear = false;
|
||||
if (mapid == mapid_global){
|
||||
map_ptr = &models->map_top;
|
||||
map_init(map_ptr, &models->mem.part, table_max, global_map);
|
||||
auto_clear = map_init(map_ptr, &models->mem.part, table_max, global_map);
|
||||
did_top = true;
|
||||
}
|
||||
else if (mapid == mapid_file){
|
||||
map_ptr = &models->map_file;
|
||||
map_init(map_ptr, &models->mem.part, table_max, global_map);
|
||||
auto_clear = map_init(map_ptr, &models->mem.part, table_max, global_map);
|
||||
did_file = true;
|
||||
}
|
||||
else if (mapid < mapid_global){
|
||||
i32 index = get_or_add_map_index(models, mapid);
|
||||
Assert(index < user_map_count);
|
||||
map_ptr = models->user_maps + index;
|
||||
map_init(map_ptr, &models->mem.part, table_max, global_map);
|
||||
auto_clear = map_init(map_ptr, &models->mem.part, table_max, global_map);
|
||||
}
|
||||
else{
|
||||
map_ptr = 0;
|
||||
}
|
||||
|
||||
if (map_ptr && unit->map_begin.replace){
|
||||
if (map_ptr && (unit->map_begin.replace || auto_clear)){
|
||||
map_clear(map_ptr);
|
||||
}
|
||||
}break;
|
||||
|
@ -1339,9 +1339,12 @@ App_Init_Sig(app_init){
|
|||
if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count)
|
||||
func = command_table[unit->binding.command_id];
|
||||
if (func){
|
||||
if (unit->binding.code == 0 && unit->binding.modifiers == 0){
|
||||
map_ptr->vanilla_keyboard_default.function = func;
|
||||
map_ptr->vanilla_keyboard_default.custom_id = unit->binding.command_id;
|
||||
if (unit->binding.code == 0){
|
||||
u32 index = 0;
|
||||
if (map_get_modifiers_hash(unit->binding.modifiers, &index)){
|
||||
map_ptr->vanilla_keyboard_default[index].function = func;
|
||||
map_ptr->vanilla_keyboard_default[index].custom_id = unit->binding.command_id;
|
||||
}
|
||||
}
|
||||
else{
|
||||
map_add(map_ptr, unit->binding.code, unit->binding.modifiers, func, unit->binding.command_id);
|
||||
|
@ -1354,9 +1357,12 @@ App_Init_Sig(app_init){
|
|||
Command_Function func = command_user_callback;
|
||||
Custom_Command_Function *custom = unit->callback.func;
|
||||
if (func){
|
||||
if (unit->callback.code == 0 && unit->callback.modifiers == 0){
|
||||
map_ptr->vanilla_keyboard_default.function = func;
|
||||
map_ptr->vanilla_keyboard_default.custom = custom;
|
||||
if (unit->callback.code == 0){
|
||||
u32 index = 0;
|
||||
if (map_get_modifiers_hash(unit->binding.modifiers, &index)){
|
||||
map_ptr->vanilla_keyboard_default[index].function = func;
|
||||
map_ptr->vanilla_keyboard_default[index].custom = custom;
|
||||
}
|
||||
}
|
||||
else{
|
||||
map_add(map_ptr, unit->callback.code, unit->callback.modifiers, func, custom);
|
||||
|
|
|
@ -26,7 +26,7 @@ static Command_Binding null_command_binding = {0};
|
|||
|
||||
struct Command_Map{
|
||||
Command_Map *parent;
|
||||
Command_Binding vanilla_keyboard_default;
|
||||
Command_Binding vanilla_keyboard_default[8];
|
||||
Command_Binding *commands;
|
||||
u32 count, max;
|
||||
};
|
||||
|
@ -121,24 +121,46 @@ internal void
|
|||
map_clear(Command_Map *commands){
|
||||
u32 max = commands->max;
|
||||
memset(commands->commands, 0, max*sizeof(*commands->commands));
|
||||
commands->vanilla_keyboard_default = null_command_binding;
|
||||
memset(commands->vanilla_keyboard_default, 0, sizeof(commands->vanilla_keyboard_default));
|
||||
commands->count = 0;
|
||||
}
|
||||
|
||||
internal void
|
||||
internal b32
|
||||
map_init(Command_Map *commands, Partition *part, u32 max, Command_Map *parent){
|
||||
b32 result = false;
|
||||
if (commands->commands == 0){
|
||||
max = clamp_bottom((u32)6, max);
|
||||
commands->parent = parent;
|
||||
commands->commands = push_array(part, Command_Binding, max);
|
||||
commands->count = 0;
|
||||
commands->max = max;
|
||||
result = true;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal b32
|
||||
map_get_modifiers_hash(u8 modifiers, u32 *hash_out){
|
||||
b32 result = true;
|
||||
u32 hash = 0;
|
||||
if (modifiers & MDFR_SHIFT){
|
||||
hash += 0x1;
|
||||
}
|
||||
if (modifiers & MDFR_CTRL){
|
||||
hash += 0x2;
|
||||
}
|
||||
if (modifiers & MDFR_ALT){
|
||||
hash += 0x4;
|
||||
}
|
||||
*hash_out = hash;
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal void
|
||||
map_get_vanilla_keyboard_default(Command_Map *map, u8 command, Command_Binding *bind_out){
|
||||
if (command == MDFR_NONE){
|
||||
*bind_out = map->vanilla_keyboard_default;
|
||||
u32 modifiers_hashed = 0;
|
||||
if (map_get_modifiers_hash(command, &modifiers_hashed)){
|
||||
*bind_out = map->vanilla_keyboard_default[modifiers_hashed];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5704,10 +5704,7 @@ to_writable_char(Key_Code long_character){
|
|||
}
|
||||
|
||||
internal Input_Process_Result
|
||||
do_step_file_view(System_Functions *system,
|
||||
View *view, i32_Rect rect, b32 is_active,
|
||||
Input_Summary *user_input,
|
||||
GUI_Scroll_Vars vars, i32_Rect region, i32 max_y){
|
||||
do_step_file_view(System_Functions *system, View *view, i32_Rect rect, b32 is_active, Input_Summary *user_input, GUI_Scroll_Vars vars, i32_Rect region, i32 max_y){
|
||||
Input_Process_Result result = {0};
|
||||
b32 is_file_scroll = 0;
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 17.02.2017
|
||||
*
|
||||
* File for reading and writing utf8.
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#if !defined(FED_UTF8_CONVERSION_H)
|
||||
#define FED_UTF8_CONVERSION_H
|
||||
|
||||
internal u32
|
||||
utf8_to_u32_unchecked(u8 *buffer){
|
||||
u32 result = 0;
|
||||
|
||||
if (buffer[0] <= 0x7F){
|
||||
result = (u32)buffer[0];
|
||||
}
|
||||
else if (buffer[0] <= 0xE0){
|
||||
result = ((u32)((buffer[0])&0x1F)) << 6;
|
||||
result |= ((u32)((buffer[1])&0x3F));
|
||||
}
|
||||
else if (buffer[0] <= 0xF0){
|
||||
result = ((u32)((buffer[0])&0x0F)) << 12;
|
||||
result |= ((u32)((buffer[1])&0x3F)) << 6;
|
||||
result |= ((u32)((buffer[2])&0x3F));
|
||||
}
|
||||
else{
|
||||
result = ((u32)((buffer[0])&0x07)) << 18;
|
||||
result |= ((u32)((buffer[1])&0x3F)) << 12;
|
||||
result |= ((u32)((buffer[2])&0x3F)) << 6;
|
||||
result |= ((u32)((buffer[3])&0x3F));
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -158,14 +158,7 @@ add_listener(File_Track_System *system, char *filename){
|
|||
if (node){
|
||||
if (CreateIoCompletionPort(dir, vars->iocp, (ULONG_PTR)node, 1)){
|
||||
ZeroStruct(node->listener.overlapped);
|
||||
if (ReadDirectoryChangesW(dir,
|
||||
node->listener.result,
|
||||
sizeof(node->listener.result),
|
||||
1,
|
||||
FLAGS,
|
||||
0,
|
||||
&node->listener.overlapped,
|
||||
0)){
|
||||
if (ReadDirectoryChangesW(dir, node->listener.result, sizeof(node->listener.result), 1, FLAGS, 0, &node->listener.overlapped, 0)){
|
||||
node->listener.dir = dir;
|
||||
node->listener.user_count = 1;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ Allen Webster
|
|||
|
||||
#include "4coder_default_include.cpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <intrin.h>
|
||||
|
@ -50,7 +51,7 @@ CUSTOM_COMMAND_SIG(load_lots_of_files){
|
|||
if (!info->folder){
|
||||
append_ss(&str, make_string(info->filename, info->filename_len));
|
||||
Buffer_Summary buffer = create_buffer(app, str.str, str.size,
|
||||
BufferCreate_Background);
|
||||
BufferCreate_Background);
|
||||
assert(buffer.size != 0);
|
||||
str.size = size;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "4tech_defines.h"
|
||||
#include "4coder_API/version.h"
|
||||
|
||||
#include "4coder_lib/4coder_utf8.h"
|
||||
|
||||
#if defined(FRED_SUPER)
|
||||
# include "4coder_API/keycodes.h"
|
||||
# include "4coder_API/style.h"
|
||||
|
@ -37,8 +39,6 @@
|
|||
#include "4ed_rendering.h"
|
||||
#include "4ed.h"
|
||||
|
||||
#include "4ed_utf8_conversions.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
|
|
@ -74,7 +74,7 @@ internal void
|
|||
generate_keycode_enum(){
|
||||
char *filename_keycodes = KEYCODES_FILE;
|
||||
|
||||
uint16_t code = 0xE000;
|
||||
uint16_t code = 0xD800;
|
||||
|
||||
String out = make_out_string(10 << 20);
|
||||
|
||||
|
|
|
@ -424,6 +424,7 @@ do_buildsuper(char *cdir, i32 custom_option){
|
|||
static void
|
||||
build_main(char *cdir, u32 flags){
|
||||
DECL_STR(dir, BUILD_DIR);
|
||||
|
||||
{
|
||||
DECL_STR(file, "4ed_app_target.cpp");
|
||||
BEGIN_TIME_SECTION();
|
||||
|
@ -440,8 +441,6 @@ build_main(char *cdir, u32 flags){
|
|||
|
||||
static void
|
||||
standard_build(char *cdir, u32 flags){
|
||||
//run_update("4coder_string.h");
|
||||
//run_update("4cpp/4cpp_lexer.h 4cpp/4cpp_lexer.h 4cpp/4cpp_lexer.h");
|
||||
fsm_generator(cdir);
|
||||
metagen(cdir);
|
||||
do_buildsuper(cdir, Custom_Experiments);
|
||||
|
|
|
@ -12,6 +12,8 @@ typedef uint16_t u16_4tech;
|
|||
typedef uint32_t u32_4tech;
|
||||
typedef uint64_t u64_4tech;
|
||||
|
||||
typedef u64_4tech umem_4tech;
|
||||
|
||||
typedef float f32_4tech;
|
||||
typedef double f64_4tech;
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "4tech_defines.h"
|
||||
#include "4coder_API/version.h"
|
||||
|
||||
#include "4coder_lib/4coder_utf8.h"
|
||||
|
||||
#if defined(FRED_SUPER)
|
||||
# include "4coder_API/keycodes.h"
|
||||
# include "4coder_API/style.h"
|
||||
|
@ -285,12 +287,14 @@ Sys_Free_Memory_Sig(system_free_memory){
|
|||
#define Win32ScratchPartitionGrow sysshared_partition_grow
|
||||
#define Win32ScratchPartitionDouble sysshared_partition_double
|
||||
|
||||
#if 0
|
||||
#if FRED_INTERNAL
|
||||
internal void
|
||||
INTERNAL_system_debug_message(char *message){
|
||||
OutputDebugStringA(message);
|
||||
OutputDebugStringW(message);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
|
@ -749,7 +753,7 @@ Sys_Set_File_List_Sig(system_set_file_list){
|
|||
HANDLE dir_handle = CreateFile(dir.str, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, 0);
|
||||
|
||||
if (dir_handle != INVALID_HANDLE_VALUE){
|
||||
DWORD final_length = GetFinalPathNameByHandleA(dir_handle, dir_space, sizeof(dir_space), 0);
|
||||
DWORD final_length = GetFinalPathNameByHandle(dir_handle, dir_space, sizeof(dir_space), 0);
|
||||
CloseHandle(dir_handle);
|
||||
|
||||
if (final_length < sizeof(dir_space)){
|
||||
|
@ -778,7 +782,7 @@ Sys_Set_File_List_Sig(system_set_file_list){
|
|||
}
|
||||
|
||||
WIN32_FIND_DATA find_data;
|
||||
HANDLE search = FindFirstFileA(c_str_dir, &find_data);
|
||||
HANDLE search = FindFirstFile(c_str_dir, &find_data);
|
||||
|
||||
if (search != INVALID_HANDLE_VALUE){
|
||||
i32 character_count = 0;
|
||||
|
@ -806,7 +810,7 @@ Sys_Set_File_List_Sig(system_set_file_list){
|
|||
file_list->infos = (File_Info*)file_list->block;
|
||||
char *name = (char*)(file_list->infos + file_count);
|
||||
if (file_list->block != 0){
|
||||
search = FindFirstFileA(c_str_dir, &find_data);
|
||||
search = FindFirstFile(c_str_dir, &find_data);
|
||||
|
||||
if (search != INVALID_HANDLE_VALUE){
|
||||
File_Info *info = file_list->infos;
|
||||
|
@ -848,7 +852,6 @@ Sys_Set_File_List_Sig(system_set_file_list){
|
|||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
internal u32
|
||||
win32_canonical_ascii_name(char *src, u32 len, char *dst, u32 max){
|
||||
u32 result = 0;
|
||||
|
@ -861,7 +864,7 @@ win32_canonical_ascii_name(char *src, u32 len, char *dst, u32 max){
|
|||
HANDLE file = CreateFile(src_space, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
|
||||
if (file != INVALID_HANDLE_VALUE){
|
||||
DWORD final_length = GetFinalPathNameByHandleA(file, dst, max, 0);
|
||||
DWORD final_length = GetFinalPathNameByHandle(file, dst, max, 0);
|
||||
|
||||
if (final_length < max && final_length >= 4){
|
||||
if (dst[final_length-1] == 0){
|
||||
|
@ -886,7 +889,7 @@ win32_canonical_ascii_name(char *src, u32 len, char *dst, u32 max){
|
|||
HANDLE dir = CreateFile(src_space, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, 0);
|
||||
|
||||
if (dir != INVALID_HANDLE_VALUE){
|
||||
DWORD final_length = GetFinalPathNameByHandleA(dir, dst, max, 0);
|
||||
DWORD final_length = GetFinalPathNameByHandle(dir, dst, max, 0);
|
||||
|
||||
if (final_length < max && final_length >= 4){
|
||||
if (dst[final_length-1] == 0){
|
||||
|
@ -909,7 +912,7 @@ win32_canonical_ascii_name(char *src, u32 len, char *dst, u32 max){
|
|||
return(result);
|
||||
}
|
||||
|
||||
#else
|
||||
#if 0
|
||||
internal u32
|
||||
win32_canonical_ascii_name(char *src, u32 len, char *dst, u32 max){
|
||||
char *wrt = dst;
|
||||
|
@ -1065,10 +1068,10 @@ Sys_Now_Time_Sig(system_now_time){
|
|||
return(result);
|
||||
}
|
||||
|
||||
b32 Win32DirectoryExists(char *path){
|
||||
DWORD attrib = GetFileAttributesA(path);
|
||||
return (attrib != INVALID_FILE_ATTRIBUTES &&
|
||||
(attrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
internal b32
|
||||
Win32DirectoryExists(char *path){
|
||||
DWORD attrib = GetFileAttributes(path);
|
||||
return (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
internal
|
||||
|
@ -2216,7 +2219,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
|
||||
if (win32vars.custom_api.get_alpha_4coder_version == 0 ||
|
||||
win32vars.custom_api.get_alpha_4coder_version(MAJOR, MINOR, PATCH) == 0){
|
||||
MessageBoxA(0,"Error: The application and custom version numbers don't match.\n", "Error",0);
|
||||
MessageBox(0,"Error: The application and custom version numbers don't match.\n", "Error",0);
|
||||
exit(1);
|
||||
}
|
||||
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)
|
||||
|
@ -2224,7 +2227,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
}
|
||||
|
||||
if (win32vars.custom_api.get_bindings == 0){
|
||||
MessageBoxA(0,"Error: The custom dll is missing.\n", "Error",0);
|
||||
MessageBox(0,"Error: The custom dll is missing.\n", "Error",0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -2277,7 +2280,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
window_style |= WS_MAXIMIZE;
|
||||
}
|
||||
|
||||
win32vars.window_handle = CreateWindowA(window_class.lpszClassName, WINDOW_NAME, window_style, window_x, window_y, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, 0, 0, hInstance, 0);
|
||||
win32vars.window_handle = CreateWindow(window_class.lpszClassName, WINDOW_NAME, window_style, window_x, window_y, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, 0, 0, hInstance, 0);
|
||||
|
||||
if (win32vars.window_handle == 0){
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue