Fixed font pixels, added delete file command
parent
e15451976e
commit
291bfa2e32
|
@ -1035,6 +1035,36 @@ CUSTOM_DOC("Saves all buffers marked dirty (showing the '*' indicator).")
|
|||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(delete_file)
|
||||
CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate access rights.")
|
||||
{
|
||||
View_Summary view = get_active_view(app, AccessAll);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll);
|
||||
|
||||
if (buffer.file_name != 0){
|
||||
String file_name = {0};
|
||||
file_name = make_string(buffer.file_name, buffer.file_name_len);
|
||||
|
||||
String path = path_of_directory(file_name);
|
||||
|
||||
char space[4096];
|
||||
String cmd = make_fixed_width_string(space);
|
||||
|
||||
#if defined(_WIN32)
|
||||
append(&cmd, "del ");
|
||||
#elif defined(__linux__) && defined(__APPLE__) && defined(__MACH__)
|
||||
append(&cmd, "rm ");
|
||||
#else
|
||||
# error no delete file command for this platform
|
||||
#endif
|
||||
append(&cmd, front_of_directory(file_name));
|
||||
|
||||
exec_system_command(app, 0, buffer_identifier(0), path.str, path.size, cmd.str, cmd.size, 0);
|
||||
|
||||
kill_buffer(app, buffer_identifier(buffer.buffer_id), view.view_id, BufferKill_AlwaysKill);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// cmdid wrappers
|
||||
//
|
||||
|
|
|
@ -692,30 +692,33 @@ CUSTOM_DOC("Execute a 'long form' command.")
|
|||
end_query_bar(app, &bar, 0);
|
||||
|
||||
if (match_ss(bar.string, make_lit_string("load project"))){
|
||||
exec_command(app, load_project);
|
||||
load_project(app);
|
||||
}
|
||||
else if (match_ss(bar.string, make_lit_string("open all code"))){
|
||||
exec_command(app, open_all_code);
|
||||
open_all_code(app);
|
||||
}
|
||||
else if (match_ss(bar.string, make_lit_string("open all code recursive"))){
|
||||
exec_command(app, open_all_code_recursive);
|
||||
open_all_code_recursive(app);
|
||||
}
|
||||
else if(match_ss(bar.string, make_lit_string("close all code"))){
|
||||
exec_command(app, close_all_code);
|
||||
close_all_code(app);
|
||||
}
|
||||
else if (match_ss(bar.string, make_lit_string("dos lines")) ||
|
||||
match_ss(bar.string, make_lit_string("dosify"))){
|
||||
exec_command(app, eol_dosify);
|
||||
eol_dosify(app);
|
||||
}
|
||||
else if (match_ss(bar.string, make_lit_string("nix lines")) ||
|
||||
match_ss(bar.string, make_lit_string("nixify"))){
|
||||
exec_command(app, eol_nixify);
|
||||
eol_nixify(app);
|
||||
}
|
||||
else if (match_ss(bar.string, make_lit_string("remap"))){
|
||||
exec_command(app, remap_interactive);
|
||||
remap_interactive(app);
|
||||
}
|
||||
else if (match_ss(bar.string, make_lit_string("new project"))){
|
||||
exec_command(app, setup_new_project);
|
||||
setup_new_project(app);
|
||||
}
|
||||
else if (match_ss(bar.string, make_lit_string("delete file"))){
|
||||
delete_file(app);
|
||||
}
|
||||
else{
|
||||
print_message(app, literal("unrecognized command\n"));
|
||||
|
|
|
@ -232,17 +232,16 @@ API_EXPORT bool32
|
|||
Exec_System_Command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer_id, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags)
|
||||
/*
|
||||
DOC_PARAM(view, If the view parameter is non-null it specifies a view to display the command's output buffer, otherwise the command will still work but if there is a buffer capturing the output it will not automatically be displayed.)
|
||||
DOC_PARAM(buffer_id, The buffer the command will output to is specified by the buffer parameter. See Buffer_Identifier for information on how this type specifies a buffer. The command will cause a crash if no buffer is specified.)
|
||||
DOC_PARAM(buffer_id, The buffer the command will output to is specified by the buffer parameter. See Buffer_Identifier for information on how this type specifies a buffer. If output from the command should just be ignored, then buffer_identifier(0) can be specified to indicate no output buffer.)
|
||||
DOC_PARAM(path, The path parameter specifies the current working directory in which the command shall be executed. The string need not be null terminated.)
|
||||
DOC_PARAM(path_len, The parameter path_len specifies the length of the path string.)
|
||||
DOC_PARAM(command, The command parameter specifies the command that shall be executed. The string need not be null terminated.)
|
||||
DOC_PARAM(command_len, The parameter command_len specifies the length of the command string.)
|
||||
DOC_PARAM(flags, Flags for the behavior of the call are specified in the flags parameter.)
|
||||
DOC_RETURN(This call returns non-zero on success.)
|
||||
DOC(A call to exec_system_command executes a command as if called from the command line, and sends the output to a buffer. The buffer identifier can name a new buffer that does not exist, name a buffer that does exist, or provide the id of a buffer that does exist.
|
||||
DOC(A call to exec_system_command executes a command as if called from the command line, and sends the output to a buffer. To output to an existing buffer, the buffer identifier can name a new buffer that does not exist, or provide the id of a buffer that does exist. If the buffer identifier uses a name for a buffer that does not exist, the buffer is created and used. If the buffer identifier uses an id that does not belong to an open buffer, then no buffer is used.
|
||||
|
||||
If the buffer is not already in an open view and the view parameter is not NULL,
|
||||
then the provided view will display the output buffer.
|
||||
If there in an output buffer and it is not already in an open view and the view parameter is not NULL, then the provided view will display the output buffer.
|
||||
|
||||
If the view parameter is NULL, no view will switch to the output.)
|
||||
DOC_SEE(Buffer_Identifier)
|
||||
|
|
|
@ -226,7 +226,7 @@ font_load_page_pixels(Partition *part, Font_Settings *settings, Glyph_Page *page
|
|||
i32 tex_width = page->tex_width;
|
||||
i32 tex_height = page->tex_height;
|
||||
|
||||
pixels = push_array(part, u32, tex_width*tex_height);
|
||||
pixels = (u32*)sysshared_push_block(part, tex_width*tex_height*sizeof(u32));
|
||||
|
||||
if (pixels != 0){
|
||||
memset(pixels, 0, tex_width*tex_height*sizeof(u32));
|
||||
|
|
|
@ -49,7 +49,7 @@ private_draw_set_color(Render_Target *t, u32 color){
|
|||
}
|
||||
|
||||
internal void
|
||||
interpret_render_buffer(Render_Target *t){
|
||||
interpret_render_buffer(Render_Target *t, Partition *growable_scratch){
|
||||
local_persist b32 first_opengl_call = true;
|
||||
if (first_opengl_call){
|
||||
first_opengl_call = false;
|
||||
|
@ -169,11 +169,10 @@ interpret_render_buffer(Render_Target *t){
|
|||
}
|
||||
|
||||
if (!page->has_gpu_setup){
|
||||
Partition *part = &target.buffer;
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
Temp_Memory temp = begin_temp_memory(growable_scratch);
|
||||
i32 tex_width = 0;
|
||||
i32 tex_height = 0;
|
||||
u32 *pixels = font_load_page_pixels(part, font.settings, page, page_number, &tex_width, &tex_height);
|
||||
u32 *pixels = font_load_page_pixels(growable_scratch, font.settings, page, page_number, &tex_width, &tex_height);
|
||||
page->has_gpu_setup = true;
|
||||
page->gpu_tex = private_texture_initialize(tex_width, tex_height, pixels);
|
||||
end_temp_memory(temp);
|
||||
|
|
|
@ -32,6 +32,10 @@ init_shared_vars(){
|
|||
void *font_scratch_memory = system_memory_allocate(font_scratch_size);
|
||||
shared_vars.font_scratch = make_part(font_scratch_memory, (i32)font_scratch_size);
|
||||
|
||||
umem pixel_scratch_size = MB(4);
|
||||
void *pixel_scratch_memory = system_memory_allocate(pixel_scratch_size);
|
||||
shared_vars.pixel_scratch = make_part(pixel_scratch_memory, (i32)pixel_scratch_size);
|
||||
|
||||
shared_vars.track_table_size = KB(16);
|
||||
shared_vars.track_table = system_memory_allocate(shared_vars.track_table_size);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ struct Shared_Vars{
|
|||
|
||||
Partition scratch;
|
||||
Partition font_scratch;
|
||||
Partition pixel_scratch;
|
||||
};
|
||||
global Shared_Vars shared_vars;
|
||||
|
||||
|
|
|
@ -1967,7 +1967,7 @@ main(int argc, char **argv){
|
|||
}
|
||||
|
||||
// NOTE(allen): Render
|
||||
interpret_render_buffer(&target);
|
||||
interpret_render_buffer(&target, &shared_vars.pixel_scratch);
|
||||
glXSwapBuffers(linuxvars.XDisplay, linuxvars.XWindow);
|
||||
|
||||
// NOTE(allen): Toggle Full Screen
|
||||
|
|
|
@ -346,11 +346,11 @@ Sys_Font_Path(name, parameters){
|
|||
}
|
||||
|
||||
OSX_Font_Match match = osx_get_font_match(name, pt_size, italic, bold);
|
||||
|
||||
|
||||
Font_Path path = {0};
|
||||
Partition *part = &shared_vars.font_scratch;
|
||||
path.temp = begin_temp_memory(part);
|
||||
|
||||
|
||||
if (match.path != 0){
|
||||
i32 len = str_size(match.path);
|
||||
char *buffer = push_array(part, char, len + 1);
|
||||
|
@ -643,7 +643,7 @@ osx_step(void){
|
|||
|
||||
// NOTE(allen): Render
|
||||
osx_begin_render();
|
||||
interpret_render_buffer(&target);
|
||||
interpret_render_buffer(&target, &shared_vars.pixel_scratch);
|
||||
osx_end_render();
|
||||
|
||||
// NOTE(allen): Toggle Full Screen
|
||||
|
|
|
@ -298,7 +298,8 @@ win32_post_clipboard(char *text, i32 len){
|
|||
HANDLE memory_handle = GlobalAlloc(GMEM_MOVEABLE, len + 1);
|
||||
if (memory_handle){
|
||||
char *dest = (char*)GlobalLock(memory_handle);
|
||||
memmove(dest, text, len + 1);
|
||||
memmove(dest, text, len);
|
||||
dest[len] = 0;
|
||||
GlobalUnlock(memory_handle);
|
||||
SetClipboardData(CF_TEXT, memory_handle);
|
||||
win32vars.next_clipboard_is_self = true;
|
||||
|
@ -1574,7 +1575,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
|
||||
// NOTE(allen): Render
|
||||
HDC hdc = GetDC(win32vars.window_handle);
|
||||
interpret_render_buffer(&target);
|
||||
interpret_render_buffer(&target, &shared_vars.pixel_scratch);
|
||||
SwapBuffers(hdc);
|
||||
ReleaseDC(win32vars.window_handle, hdc);
|
||||
|
||||
|
|
Loading…
Reference in New Issue