fixed some bugs in and doc'd get buffer api
This commit is contained in:
parent
9a59958006
commit
68487267ee
|
@ -9,6 +9,9 @@
|
|||
// to decide whether you want macro translations, without them you will
|
||||
// have to manipulate the command and parameter stack through
|
||||
// "app->" which may be more or less clear depending on your use.
|
||||
//
|
||||
// I suggest you try disabling macro translation and getting your code working
|
||||
// that way, because I'll be removing it entirely sometime soon
|
||||
#define DisableMacroTranslations 0
|
||||
|
||||
#include "4coder_custom.h"
|
||||
|
@ -52,12 +55,16 @@ bool str_match(const char *a, int len_a, const char *b, int len_b){
|
|||
}
|
||||
|
||||
HOOK_SIG(my_file_settings){
|
||||
Buffer_Summary buffer = get_active_buffer(cmd_context);
|
||||
Buffer_Summary buffer = app->get_active_buffer(cmd_context);
|
||||
|
||||
// NOTE(allen|a3.4.2): Whenever you ask for a buffer, you should check that the
|
||||
// exists flag is set to true before using it. Reasons why the buffer might not exist:
|
||||
// -The active panel does not contain a buffer and get_active_buffer was used
|
||||
// -The index provided to get_buffer was out of range [0,max) or that index is associated to a dummy buffer
|
||||
// -The name provided to get_buffer_by_name did not match any of the existing buffers
|
||||
if (buffer.exists){
|
||||
int treat_as_code = 0;
|
||||
|
||||
// NOTE(allen|a3.1): This checks buffer.file_name just in case get_active_buffer returns back
|
||||
// a null buffer (where every member is 0).
|
||||
if (buffer.file_name && buffer.size < (16 << 20)){
|
||||
int extension_len;
|
||||
char *extension = get_extension(buffer.file_name, buffer.file_name_len, &extension_len);
|
||||
|
@ -72,6 +79,7 @@ HOOK_SIG(my_file_settings){
|
|||
push_parameter(app, cmd_context, par_key_mapid, (treat_as_code)?(my_code_map):(mapid_file));
|
||||
exec_command(cmd_context, cmdid_set_settings);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_in_other){
|
||||
exec_command(cmd_context, cmdid_change_active_panel);
|
||||
|
|
|
@ -220,7 +220,8 @@ struct Buffer_Summary{
|
|||
// NOTE(allen): None of these members nor any of the data pointed to
|
||||
// by these members should be modified, I would have made them const...
|
||||
// but that actually causes problems for C++ reasons.
|
||||
int found_buffer;
|
||||
int exists;
|
||||
int ready;
|
||||
int file_id;
|
||||
|
||||
int size;
|
||||
|
|
|
@ -258,7 +258,6 @@ exec_command_(Application_Links *app, void *cmd_context, Custom_Command_Function
|
|||
|
||||
#define exec_command_keep_stack app->exec_command_keep_stack
|
||||
#define clear_parameters app->clear_parameters
|
||||
#define get_active_buffer app->get_active_buffer
|
||||
|
||||
#define exec_command(cmd_context, cmd) exec_command_(app, cmd_context, cmd)
|
||||
|
||||
|
|
9
4ed.cpp
9
4ed.cpp
|
@ -541,7 +541,7 @@ COMMAND_DECL(word_complete){
|
|||
|
||||
file_ptr = working_set->files;
|
||||
for (i = 0, j = 2; i < buffer_count; ++i, ++file_ptr){
|
||||
if (file_ptr != file && !file_ptr->state.is_dummy && file_is_ready(file_ptr)){
|
||||
if (file_ptr != file && !file_ptr->state.is_dummy){
|
||||
ranges[j].buffer = &file_ptr->state.buffer;
|
||||
ranges[j].start = 0;
|
||||
ranges[j].size = buffer_size(ranges[j].buffer);
|
||||
|
@ -2011,7 +2011,8 @@ globalvar Command_Function command_table[cmdid_count];
|
|||
|
||||
internal void
|
||||
fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *working_set){
|
||||
buffer->found_buffer = 1;
|
||||
buffer->exists = 1;
|
||||
buffer->exists = file_is_ready(file);
|
||||
buffer->file_id = (int)(file - working_set->files);
|
||||
buffer->size = file->state.buffer.size;
|
||||
buffer->file_cursor_pos = file->state.cursor_pos;
|
||||
|
@ -2085,7 +2086,7 @@ extern "C"{
|
|||
|
||||
if (index >= 0 && index < max){
|
||||
file = working_set->files + index;
|
||||
if (!file->state.is_dummy && file_is_ready(file)){
|
||||
if (!file->state.is_dummy){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 0
|
||||
fill_buffer_summary(&buffer, file, working_set);
|
||||
#endif
|
||||
|
@ -2107,7 +2108,7 @@ extern "C"{
|
|||
file = view->file;
|
||||
working_set = cmd->working_set;
|
||||
|
||||
if (file && !file->state.is_dummy && file_is_ready(file)){
|
||||
if (file && !file->state.is_dummy){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 0
|
||||
fill_buffer_summary(&buffer, file, working_set);
|
||||
#endif
|
||||
|
|
|
@ -1789,6 +1789,9 @@ main(int argc, char **argv){
|
|||
|
||||
system_acquire_lock(FRAME_LOCK);
|
||||
|
||||
SetForegroundWindow(window_handle);
|
||||
SetActiveWindow(window_handle);
|
||||
|
||||
ResumeThread(win32vars.update_loop_thread);
|
||||
|
||||
MSG msg;
|
||||
|
|
Loading…
Reference in New Issue