From e031a3d3fc79cf005c258d8eb252b000760f1b25 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 27 Jul 2014 18:47:08 -0400 Subject: [PATCH] tweaked rake scripts --- Rakefile | 16 +++++++++++++--- source/input.c | 12 +++++++++--- source/screen.c | 26 +++++++++++++++++++------- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Rakefile b/Rakefile index 7f93db2..36869d0 100644 --- a/Rakefile +++ b/Rakefile @@ -24,8 +24,7 @@ Env = Rscons::Environment.new do |env| env.build_dir('modules','build/obj/modules') env['LIBS'] = ['ncurses'] env['CPPPATH'] += Dir['modules/data-structures/source/**/'] - env['CFLAGS'] += ['-Wall'] - env['CFLAGS'] += ['-Werror', '-pedantic', '--std=c99'] + env['CFLAGS'] += ['-Wall', '-Werror', '-pedantic', '--std=c99'] # Platform-specific Defines # ------------------------- @@ -60,5 +59,16 @@ task(:clean) { Rscons.clean } desc "Remove all generated artifacts and directories as well as any git submodules" task :clobber => [:clean] do - sh 'git submodule deinit -f .' + sh 'git submodule deinit -f .' +end + +task :valgrind => [:build] do + sh "valgrind --leak-check=full ./build/afm 2> ./build/valgrind.txt" +end + +task :splint do + include_dirs = Dir['source/**/','modules/**/source/**/'].map{|e| "-I#{e}" } + sources = Dir['source/**/*.c', 'modules/data-structures/source/**/*.c'] + cmd = ['splint', '+posixlib'] + include_dirs + sources + sh *cmd end diff --git a/source/input.c b/source/input.c index 4333454..6916a2b 100644 --- a/source/input.c +++ b/source/input.c @@ -38,23 +38,27 @@ static void handle_cd(void) { static void handle_scroll_to_top(void) { workdir_scroll_to_top(state_get_focused_frame()->workdir); } + static void handle_scroll_to_bottom(void) { workdir_scroll_to_bot(state_get_focused_frame()->workdir); } + static void handle_page_up(void){ screen_frame_page_up(state_get_focused_frame()); } + static void handle_page_down(void){ screen_frame_page_down(state_get_focused_frame()); } + static void handle_expand(void){ workdir_expand_selected(state_get_focused_frame()->workdir); } + static void handle_collapse(void){ workdir_collapse_selected(state_get_focused_frame()->workdir); } - static void search_mode(void){ int searchcap = 8; char* searchstr = malloc(sizeof(char)*searchcap); @@ -121,14 +125,15 @@ void input_handle_key(char ch) { } /* If we got a valid key then process it */ - if(ERR != ch) { + if((char)ERR != ch) { + int i; /* Put the key in the buffer */ len++; Key_Buffer[len-1] = ch; Key_Buffer[len] = '\0'; /* Loop over the bindings */ - for(int i = 0; i < num_entries; i++) { + for(i = 0; i < num_entries; i++) { binding_t binding = Default_Bindings[i]; char* seq = binding.sequence; @@ -138,6 +143,7 @@ void input_handle_key(char ch) { { more_matches = true; } + /* If the current string matches exactly then execute it's handler */ if (0 == strcmp(Key_Buffer, seq)) { diff --git a/source/screen.c b/source/screen.c index ccabe5c..96a1484 100644 --- a/source/screen.c +++ b/source/screen.c @@ -15,16 +15,15 @@ #include "aardvark.h" #include "workdir.h" -//number of lines to leave before/after dir contents in frame -static int FrameTopBuffer = 2; -static int FrameBotBuffer = 2; - static void screen_place_windows(void); +static void screen_refresh_curr_frame(void); static frame_t* screen_frame_new(void); static void screen_frame_free(void* p_frame); void screen_frame_draw_files(frame_t* frame); static list_t* Screen_List; +static int FrameTopBuffer = 2; +static int FrameBotBuffer = 2; static frame_t* master_frame(void){ return (frame_t*) Screen_List->head->contents; @@ -44,11 +43,11 @@ void screen_update(void) { /* Clear screen and update LINES and COLS */ if(state_get_screen_resized()){ endwin(); + screen_place_windows(); state_set_screen_resized(false); + } else { + screen_refresh_curr_frame(); } - clear(); - refresh(); - screen_place_windows(); if(state_get_aardvark_mode()) aardvark_draw(); /* Refresh and mark complete */ state_set_screen_dirty(false); @@ -57,6 +56,7 @@ void screen_update(void) { void screen_open(void) { list_push_back(Screen_List, screen_frame_new()); state_set_screen_dirty(true); + state_set_screen_resized(true); } void screen_close(void) { @@ -66,6 +66,7 @@ void screen_close(void) { state_set_focused_frame(master_frame()); } state_set_screen_dirty(true); + state_set_screen_resized(true); } static void screen_place_windows(void) { @@ -108,6 +109,16 @@ static void screen_place_windows(void) { } } + +static void screen_refresh_curr_frame(void) { + /* Print the master frame */ + frame_t* p_frame = list_at(Screen_List,0)->contents; + wclear(p_frame->p_win); + screen_frame_draw_files(p_frame); + box(p_frame->p_win, 0 , 0); + wrefresh(p_frame->p_win); +} + //get the curent directory and copy it into a ref-counted memory block //return a pointer to the new block char* pwd(){ @@ -194,6 +205,7 @@ int realrows(frame_t* p_frame){ (void) cols; return rows - FrameTopBuffer - FrameBotBuffer; } + void screen_frame_page_up(frame_t* p_frame){ workdir_set_idx(p_frame->workdir, p_frame->workdir->idx - realrows(p_frame)); } -- 2.52.0