textbox/suggestion fixups, update to lossless, canvas scaling
authorGood Guy <good1.2guy@gmail.com>
Mon, 30 Jan 2017 21:19:59 +0000 (14:19 -0700)
committerGood Guy <good1.2guy@gmail.com>
Mon, 30 Jan 2017 21:19:59 +0000 (14:19 -0700)
14 files changed:
cinelerra-5.1/cinelerra/asset.C
cinelerra-5.1/cinelerra/batchrender.C
cinelerra-5.1/cinelerra/batchrender.h
cinelerra-5.1/cinelerra/formattools.C
cinelerra-5.1/cinelerra/formattools.h
cinelerra-5.1/cinelerra/indexfile.C
cinelerra-5.1/cinelerra/recordbatches.C
cinelerra-5.1/cinelerra/recordbatches.h
cinelerra-5.1/cinelerra/resourcepixmap.C
cinelerra-5.1/cinelerra/swindow.C
cinelerra-5.1/cinelerra/swindow.h
cinelerra-5.1/ffmpeg/format/bluray
cinelerra-5.1/guicast/bctextbox.C
cinelerra-5.1/guicast/bctextbox.h

index fd17a1422a89b9bfdcca138e25f47ab5085b9f85..3133649b9ae161077c3b1afdb49e8327452c9213 100644 (file)
@@ -332,11 +332,13 @@ int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
                if( out_path ) {
                        if( *apath != '/' ) {
                                char *cp = cstrcat(2, out_path, apath);
-                               delete [] apath;  apath = cp;
+                               delete [] apath;  apath = FileSystem::basepath(cp);
+                               delete [] cp;
                        }
                        if( *tpath != '/' ) {
                                char *cp = cstrcat(2, out_path, tpath);
-                               delete [] tpath;  tpath = cp;
+                               delete [] tpath;  tpath = FileSystem::basepath(cp);
+                               delete [] cp;
                        }
                }
                if( strcmp(apath, tpath) ) result = 1;
index bbd66d47fa955d1756cdd70a35f147bc587812a3..bea451cef030c9d5816beac9a81caac5f4345e59 100644 (file)
@@ -203,7 +203,6 @@ BatchRenderThread::BatchRenderThread(MWindow *mwindow)
        preferences = 0;
        warn = 1;
        render = 0;
-       file_entries = 0;
        batch_path[0] = 0;
 }
 
@@ -219,7 +218,6 @@ BatchRenderThread::BatchRenderThread()
        preferences = 0;
        warn = 1;
        render = 0;
-       file_entries = 0;
        batch_path[0] = 0;
 }
 
@@ -229,10 +227,6 @@ BatchRenderThread::~BatchRenderThread()
        delete boot_defaults;
        delete preferences;
        delete render;
-       if( file_entries ) {
-               file_entries->remove_all_objects();
-               delete file_entries;
-       }
 }
 
 void BatchRenderThread::reset(const char *path)
@@ -245,10 +239,6 @@ void BatchRenderThread::reset(const char *path)
        rendering_job = -1;
        delete default_job;  default_job = 0;
        jobs.remove_all_objects();
-       if(file_entries) {
-               file_entries->remove_all_objects();
-               delete file_entries;  file_entries = 0;
-       }
 }
 
 void BatchRenderThread::handle_close_event(int result)
@@ -264,23 +254,6 @@ BC_Window* BatchRenderThread::new_gui()
        current_start = 0.0;
        current_end = 0.0;
        default_job = new BatchRenderJob(mwindow->preferences);
-
-
-       if(!file_entries)
-       {
-               file_entries = new ArrayList<BC_ListBoxItem*>;
-               FileSystem fs;
-               char string[BCTEXTLEN];
-       // Load current directory
-               fs.update(getcwd(string, BCTEXTLEN));
-               for(int i = 0; i < fs.total_files(); i++)
-               {
-                       file_entries->append(
-                               new BC_ListBoxItem(
-                                       fs.get_entry(i)->get_name()));
-               }
-       }
-
        load_jobs(batch_path, mwindow->preferences);
        load_defaults(mwindow->defaults);
        this->gui = new BatchRenderGUI(mwindow,
@@ -1051,9 +1024,7 @@ BatchRenderEDLPath::BatchRenderEDLPath(BatchRenderThread *thread,
 
 int BatchRenderEDLPath::handle_event()
 {
-// Suggestions
-       calculate_suggestions(thread->file_entries);
-
+       calculate_suggestions();
        strcpy(thread->get_current_edl(), get_text());
        thread->gui->create_list(1);
        return 1;
index 09d98052b3b62eeea61066f2767458826d0a94c0..356ebf7e82fa476275b37e936f7bc6214be29c47 100644 (file)
@@ -137,7 +137,6 @@ public:
        int rendering_job;
        int is_rendering;
        int warn;
-       ArrayList<BC_ListBoxItem*> *file_entries;
 };
 
 
index 60295e4b46c76088d288a191b5cf9f3928e5c492..d3d5ca29e6ec0fae5e83a8225a81310f1ad68c16 100644 (file)
@@ -68,7 +68,6 @@ FormatTools::FormatTools(MWindow *mwindow,
        channels_title = 0;
        channels_button = 0;
        multiple_files = 0;
-       file_entries = 0;
        w = window->get_w();
 
        recording = 0;
@@ -104,12 +103,6 @@ SET_TRACE
        if(vparams_thread) delete vparams_thread;
 SET_TRACE
        if(channels_tumbler) delete channels_tumbler;
-SET_TRACE
-       if(file_entries)
-       {
-               file_entries->remove_all_objects();
-               delete file_entries;
-       }
 }
 
 void FormatTools::create_objects(int &init_x,
@@ -141,19 +134,6 @@ void FormatTools::create_objects(int &init_x,
        this->prompt_video_compression = prompt_video_compression;
        this->strategy = strategy;
 
-
-       file_entries = new ArrayList<BC_ListBoxItem*>;
-       FileSystem fs;
-       char string[BCTEXTLEN];
-// Load current directory
-       fs.update(getcwd(string, BCTEXTLEN));
-       for(int i = 0; i < fs.total_files(); i++)
-       {
-               file_entries->append(
-                       new BC_ListBoxItem(
-                               fs.get_entry(i)->get_name()));
-       }
-
 //printf("FormatTools::create_objects 1\n");
 
 // Modify strategy depending on render farm
@@ -749,11 +729,7 @@ FormatPathText::~FormatPathText()
 }
 int FormatPathText::handle_event()
 {
-// Suggestions
-       calculate_suggestions(format->file_entries);
-
-
-
+       calculate_suggestions();
        strcpy(format->asset->path, get_text());
        format->handle_event();
        return 1;
index 3929bbff5ec02f0058f5c6e001e8d6a73dcfacb3..d471db8b6825fe2bb49923bb04bdcc9c2192698f 100644 (file)
@@ -116,8 +116,6 @@ public:
 
        FormatMultiple *multiple_files;
 
-// Suggestions for the textbox
-       ArrayList<BC_ListBoxItem*> *file_entries;
        ArrayList<PluginServer*> *plugindb;
        MWindow *mwindow;
        const char *locked_compressor;
index dfb5d6b2d21b36993198bd81a7f570c440b2f54a..b62379b2c71108630c1d5f23fb33464da23c7462 100644 (file)
@@ -738,9 +738,7 @@ SET_TRACE
        int prev_y2 = center_pixel;
        int first_frame = 1;
        int zoom_y = mwindow->edl->local_session->zoom_y, zoom_y2 = zoom_y / 2;
-       int max_y = canvas->get_h();
-       int zmax_y = center_pixel + zoom_y2 - 1;
-       if( zmax_y < max_y ) max_y = zmax_y;
+       int max_y = center_pixel + zoom_y2 - 1;
 SET_TRACE
 
        for(int bufferposition = 0;
index 861538c468c80ea21e5b9e1dc3def8e588e5e99a..df576ed175eb9060558d516f9f4749f4e1f7e164 100644 (file)
@@ -354,21 +354,10 @@ RecordBatchesGUI::Dir::
 int RecordBatchesGUI::Dir::
 handle_event()
 {
-       strncpy(directory, get_text(),sizeof(directory));
-       char *bp, *cp, *dp = &directory[0];
-       if( *dp ) {
-               if( dp[0] != '~' || dp[1] != 0 ) {
-                       for( cp=dp; *cp; ++cp ) {
-                               if( *cp != '/' ) continue;
-                               for( bp=cp; *bp=='/'; ++bp );
-                               if( *bp ) dp = cp;
-                       }
-                       if( *--cp != '/' ) return 1;
-                       while( cp>dp && *cp=='/' ) *cp-- = 0;
-               }
-               load_dirs(directory);
-               calculate_suggestions(dir_entries);
-       }
+       char *path = FileSystem::basepath(directory);
+       load_dirs(path);
+       calculate_suggestions(dir_entries);
+       delete [] path;
        return 1;
 }
 
@@ -392,28 +381,17 @@ Path(RecordBatches &batches, int x, int y)
  : BC_TextBox(x, y, 200, 1, batches.get_editing_batch()->asset->path),
    batches(batches)
 {
-       file_entries = new ArrayList<BC_ListBoxItem*>;
-       FileSystem fs;  char string[BCTEXTLEN];
-// Load current directory
-       fs.update(getcwd(string, BCTEXTLEN));
-       int total_files = fs.total_files();
-       for(int i = 0; i < total_files; i++) {
-               const char *name = fs.get_entry(i)->get_name();
-               file_entries->append(new BC_ListBoxItem(name));
-       }
 }
 
 RecordBatchesGUI::Path::
 ~Path()
 {
-       file_entries->remove_all_objects();
-       delete file_entries;
 }
 
 int RecordBatchesGUI::Path::
 handle_event()
 {
-       calculate_suggestions(file_entries);
+       calculate_suggestions();
        Batch *batch = batches.gui->get_editing_batch();
        strcpy(batch->asset->path, get_text());
        batches.gui->update_batches();
index fffb5366df759891b1b039120a6a1e7ac688a5b1..b0a4be2b7558f10dc2b95840e4e0ac52c8c09e8e 100644 (file)
@@ -95,7 +95,6 @@ public:
        class Path : public BC_TextBox {
        public:
                RecordBatches &batches;
-               ArrayList<BC_ListBoxItem*> *file_entries;
 
                int handle_event();
 
index f184e2fe17d23f5757aaa88a4ae39b86c6b31e6e..61b9452303e3dbf744d2ba820c3bd93d5213133e 100644 (file)
@@ -617,9 +617,7 @@ void ResourcePixmap::draw_audio_source(TrackCanvas *canvas,
                center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
 
        int64_t scale_y = mwindow->edl->local_session->zoom_y;
-       int y_max = canvas->get_h();
-       int max_y = center_pixel + scale_y / 2 - 1;
-       if( y_max > max_y ) y_max = max_y;
+       int y_max = center_pixel + scale_y / 2 - 1;
 // Single sample zoom
        if(mwindow->edl->local_session->zoom_sample == 1)
        {
@@ -984,9 +982,7 @@ void ResourcePixmap::draw_subttl_resource(TrackCanvas *canvas,
        int x0 = edit_x;
        if( x0 < 0 ) x0 = -x0;
         int x1 = (int)(pixmap_x - x0 + x);
-       int y_max = canvas->get_h();
-       int max_y = center_pixel + scale_y / 2 - 1;
-       if( y_max > max_y ) y_max = max_y;
+       int y_max = center_pixel + scale_y / 2 - 1;
        int font = MEDIUMFONT, color = WHITE;
        canvas->set_font(font);
        canvas->set_color(color);
index a4315b50febf1e877dfb3bab7bf5fb46c257315b..423dd55d0ada2e3e1ec1cd2fa51346ac65ac3b65 100644 (file)
@@ -76,27 +76,15 @@ SWindowLoadPath::SWindowLoadPath(SWindowGUI *gui, int x, int y, char *path)
  : BC_TextBox(x, y, 200, 1, path)
 {
        this->sw_gui = gui;
-
-       file_entries = new ArrayList<BC_ListBoxItem*>;
-       FileSystem fs;  char string[BCTEXTLEN];
-// Load current directory
-       fs.update(getcwd(string, BCTEXTLEN));
-       int total_files = fs.total_files();
-       for(int i = 0; i < total_files; i++) {
-               const char *name = fs.get_entry(i)->get_name();
-               file_entries->append(new BC_ListBoxItem(name));
-       }
 }
 
 SWindowLoadPath::~SWindowLoadPath()
 {
-       file_entries->remove_all_objects();
-       delete file_entries;
 }
 
 int SWindowLoadPath::handle_event()
 {
-       calculate_suggestions(file_entries);
+       calculate_suggestions();
        strcpy(sw_gui->script_path, get_text());
        return 1;
 }
index 8ba4e7447c51c88c95880ac56b269e4c77d9f644..04e08b556e3004b79dc8f0baf9d88980f0ca146b 100644 (file)
@@ -57,7 +57,6 @@ class SWindowLoadPath : public BC_TextBox
 {
 public:
        SWindowGUI *sw_gui;
-       ArrayList<BC_ListBoxItem*> *file_entries;
 
        SWindowLoadPath(SWindowGUI *gui, int x, int y, char *path);
        ~SWindowLoadPath();
index 292b00cf3df33dd1262cb454fb34542c444a4340..10cc4cd1285b41c0734ce234fb37b880aaf98357 100644 (file)
@@ -1,5 +1,6 @@
 mpegts
 mpegts_m2ts_mode=2
+mpegts_start_pid=1024
 mpegts_pmt_start_pid=256
 sdt_period=-1
 packetsize 2048
index 5a9cac03f0c1dc783036e6326caa01b1f7c9e711..52aa85d3e28f54c77cdb0abc6763f6e73e24ccb5 100644 (file)
@@ -314,143 +314,91 @@ void BC_TextBox::set_precision(int precision)
 }
 
 // Compute suggestions for a path
-int BC_TextBox::calculate_suggestions(ArrayList<BC_ListBoxItem*> *entries)
+int BC_TextBox::calculate_suggestions(ArrayList<BC_ListBoxItem*> *entries, const char *filter)
 {
 // Let user delete suggestion
-       if(get_last_keypress() != BACKSPACE)
-       {
-
+       if(get_last_keypress() != BACKSPACE) {
 // Compute suggestions
                FileSystem fs;
                ArrayList<char*> suggestions;
                const char *current_text = get_text();
-
+               int suggestion_column = 0;
+               char dirname[BCTEXTLEN];  dirname[0] = 0;
+               if( current_text[0] == '/' || current_text[0] == '~' )
+                       strncpy(dirname, current_text, sizeof(dirname));
+               else if( !entries )
+                       getcwd(dirname, sizeof(dirname));
 // If directory, tabulate it
-               if(current_text[0] == '/' ||
-                       current_text[0] == '~')
-               {
-//printf("BC_TextBox::calculate_suggestions %d\n", __LINE__);
-                       char string[BCTEXTLEN];
-                       strncpy(string, current_text, sizeof(string));
-                       char *ptr = strrchr(string, '/');
-                       if(!ptr) ptr = strrchr(string, '~');
-
-//printf("BC_TextBox::calculate_suggestions %d\n", __LINE__);
-                       *(ptr + 1) = 0;
-                       int suggestion_column = ptr + 1 - string;
-
-                       fs.set_filter(get_resources()->filebox_filter);
-//                     fs.set_sort_order(filebox->sort_order);
-//                     fs.set_sort_field(filebox->column_type[filebox->sort_column]);
-
-
-//printf("BC_TextBox::calculate_suggestions %d %c %s\n", __LINE__, *ptr, string);
-                       if(current_text[0] == '~' && *ptr != '/')
-                       {
-                               fs.update("/home");
-                       }
-                       else
-                       {
-                               fs.parse_tildas(string);
-                               fs.update(string);
-                       }
-//printf("BC_TextBox::calculate_suggestions %d %d\n", __LINE__, fs.total_files());
-
-
-// Accept only entries with matching trailing characters
-                       ptr = strrchr((char*)current_text, '/');
-                       if(!ptr) ptr = strrchr((char*)current_text, '~');
-                       if(ptr) ptr++;
-//printf("BC_TextBox::calculate_suggestions %d %s %p\n", __LINE__, current_text, ptr);
-
-
-                       if(ptr && *ptr)
-                       {
-                               for(int i = 0; i < fs.total_files(); i++)
-                               {
-                                       char *current_name = fs.get_entry(i)->name;
-                                       if(!strncmp(ptr, current_name, strlen(ptr)))
-                                       {
-                                               suggestions.append(current_name);
-       //printf("BC_TextBox::calculate_suggestions %d %s\n", __LINE__, current_name);
-                                       }
-                               }
-                       }
-                       else
-       // Accept all entries
-                       for(int i = 0; i < fs.total_files(); i++)
-                       {
-       //printf("BC_TextBox::calculate_suggestions %d %s\n", __LINE__, fs.get_entry(i)->name);
-                               suggestions.append(fs.get_entry(i)->name);
+               if( dirname[0] ) {
+                       if( filter ) fs.set_filter(filter);
+                       char *prefix, *cp;
+                       strncpy(dirname, current_text, sizeof(dirname));
+                       if( (cp=strrchr(dirname, '/')) ||
+                           (cp=strrchr(dirname, '~')) ) *++cp = 0;
+                       fs.parse_tildas(dirname);
+                       fs.update(dirname);
+                       cp = (char *)current_text;
+                       if( (prefix=strrchr(cp, '/')) ||
+                           (prefix=strrchr(cp, '~')) ) ++prefix;
+                       suggestion_column = !prefix ? 0 : prefix - cp;
+                       int prefix_len = prefix ? strlen(prefix) : 0;
+// only include items where the filename matches the basename prefix
+                       for(int i = 0; i < fs.total_files(); i++) {
+                               char *current_name = fs.get_entry(i)->name;
+                               if( prefix_len>0 && strncmp(prefix, current_name, prefix_len) ) continue;
+                               suggestions.append(current_name);
                        }
-//printf("BC_TextBox::calculate_suggestions %d\n", __LINE__);
-
-// Add 1 to column to keep /
-                       set_suggestions(&suggestions, suggestion_column);
-//printf("BC_TextBox::calculate_suggestions %d\n", __LINE__);
                }
-               else
-// Get entries from current listbox with matching trailing characters
-               if(entries)
-               {
-// printf("BC_TextBox::calculate_suggestions %d %d\n",
-// __LINE__,
-// entries->size());
-                       for(int i = 0; i < entries->size(); i++)
-                       {
+               else if(entries) {
+                       char *prefix = (char *)current_text;
+                       int prefix_len = strlen(prefix);
+                       for(int i = 0; i < entries->size(); i++) {
                                char *current_name = entries->get(i)->get_text();
-
-//printf("BC_TextBox::calculate_suggestions %d %s %s\n", __LINE__, current_text, current_name);
-                               if(!strncmp(current_text, current_name, strlen(current_text)))
-                               {
-                                       suggestions.append(current_name);
-                               }
+                               if( prefix_len>0 && strncmp(prefix, current_name, prefix_len) ) continue;
+                               suggestions.append(current_name);
                        }
-
-                       set_suggestions(&suggestions, 0);
                }
+               set_suggestions(&suggestions, suggestion_column);
        }
 
        return 1;
 }
 
+void BC_TextBox::no_suggestions()
+{
+       if( suggestions_popup ) {
+               delete suggestions_popup;
+               suggestions_popup = 0;
+               activate();
+       }
+}
+
 void BC_TextBox::set_suggestions(ArrayList<char*> *suggestions, int column)
 {
 // Copy the array
        this->suggestions->remove_all_objects();
        this->suggestion_column = column;
 
-       if(suggestions)
-       {
-               for(int i = 0; i < suggestions->size(); i++)
-               {
+       if(suggestions) {
+               for(int i = 0; i < suggestions->size(); i++) {
                        this->suggestions->append(new BC_ListBoxItem(suggestions->get(i)));
                }
 
 // Show the popup without taking focus
-               if(suggestions->size() > 1)
-               {
-                       if(!suggestions_popup)
-                       {
-
-                               get_parent()->add_subwindow(suggestions_popup =
-                                       new BC_TextBoxSuggestions(this, x, y));
+               if( suggestions->size() > 1 ) {
+                       if( !suggestions_popup ) {
+                               suggestions_popup = new BC_TextBoxSuggestions(this, x, y);
+                               get_parent()->add_subwindow(suggestions_popup);
                                suggestions_popup->set_is_suggestions(1);
-                               suggestions_popup->activate(0);
                        }
-                       else
-                       {
-                               suggestions_popup->update(this->suggestions,
-                                       0,
-                                       0,
-                                       1);
-                               suggestions_popup->activate(0);
+                       else {
+                               suggestions_popup->update(this->suggestions, 0, 0, 1);
                        }
+                       suggestions_popup->activate(0);
                }
                else
 // Show the highlighted text
-               if(suggestions->size() == 1)
-               {
+               if( suggestions->size() == 1 ) {
                        highlight_letter1 = wtext_update();
                        text_update(wtext,wlen, text,tsize);
                        char *current_suggestion = suggestions->get(0);
@@ -458,22 +406,18 @@ void BC_TextBox::set_suggestions(ArrayList<char*> *suggestions, int column)
                        if( col < 0 ) col = 0;
                        char *cur = current_suggestion + col;
                        tstrcat(cur);
+                       draw(0);  // update positions
                        highlight_letter2 = wtext_update();
 //printf("BC_TextBox::set_suggestions %d %d\n", __LINE__, suggestion_column);
 
                        draw(1);
-
-                       delete suggestions_popup;
-                       suggestions_popup = 0;
+                       no_suggestions();
                }
        }
 
 // Clear the popup
-       if(!suggestions || !this->suggestions->size())
-       {
-               delete suggestions_popup;
-               suggestions_popup = 0;
-       }
+       if( !suggestions || !this->suggestions->size() )
+               no_suggestions();
 }
 
 void BC_TextBox::wset_selection(int char1, int char2, int ibeam)
@@ -554,10 +498,8 @@ void BC_TextBox::disable()
 {
        if(enabled) {
                enabled = 0;
-               if(top_level) {
-                       if(active) top_level->deactivate();
-                       draw(1);
-               }
+               deactivate();
+               draw(1);
        }
 }
 
@@ -811,7 +753,10 @@ int BC_TextBox::cursor_enter_event()
        if(top_level->event_win == win && enabled)
        {
                tooltip_done = 0;
-
+               if( !active ) {
+                       top_level->deactivate();
+                       activate();
+               }
                if(!highlighted)
                {
                        highlighted = 1;
@@ -829,8 +774,9 @@ int BC_TextBox::cursor_leave_event()
                highlighted = 0;
                draw_border();
                hide_tooltip();
-               flash(1);
        }
+       if( !suggestions_popup )
+               deactivate();
        return 0;
 }
 
@@ -948,28 +894,12 @@ int BC_TextBox::button_press_event()
                return 1;
        }
        else
-       if(active && (!yscroll || !yscroll->is_event_win()))
+       if(active && suggestions_popup && (!yscroll || !yscroll->is_event_win()))
        {
-//printf("BC_TextBox::button_press_event %d\n", __LINE__);
-// Suggestion popup is not active but must be deactivated.
-               if(suggestions_popup)
-               {
-                       return 0;
-// printf("BC_TextBox::button_press_event %d\n", __LINE__);
-// // Pass event to suggestions popup
-//                     if(!suggestions_popup->button_press_event())
-//                     {
-// printf("BC_TextBox::button_press_event %d\n", __LINE__);
-//                             top_level->deactivate();
-//                     }
-               }
-               else
-               {
-                       top_level->deactivate();
-               }
+               if( suggestions_popup->button_press_event() )
+                       return suggestions_popup->handle_event();
        }
 
-
        return 0;
 }
 
@@ -1047,27 +977,22 @@ int BC_TextBox::cursor_motion_event()
 
 int BC_TextBox::activate()
 {
-       top_level->active_subwindow = this;
-       active = 1;
+       if( !active ) {
+               active = 1;
+               top_level->set_active_subwindow(this);
+               top_level->set_repeat(top_level->get_resources()->blink_rate);
+       }
        draw(1);
-       top_level->set_repeat(top_level->get_resources()->blink_rate);
        return 0;
 }
 
 int BC_TextBox::deactivate()
 {
-//printf("BC_TextBox::deactivate %d suggestions_popup=%p\n", __LINE__, suggestions_popup);
-       active = 0;
-       top_level->unset_repeat(top_level->get_resources()->blink_rate);
-       if(suggestions_popup)
-       {
-// Must deactivate instead of delete since this is called from BC_ListBox::button_press_event
-//             suggestions_popup->deactivate();
-
-               delete suggestions_popup;
-               suggestions_popup = 0;
+       if( active ) {
+               active = 0;
+               top_level->set_active_subwindow(0);
+               top_level->unset_repeat(top_level->get_resources()->blink_rate);
        }
-
        draw(1);
        return 0;
 }
@@ -1193,15 +1118,11 @@ int BC_TextBox::repeat_event(int64_t duration)
 
 void BC_TextBox::default_keypress(int &dispatch_event, int &result)
 {
-       if( (top_level->get_keypress() == RETURN) ||
-           (top_level->get_keypress() > 30 && top_level->get_keypress() <= 255)) {
-               int len;
-               wchar_t *temp_string = top_level->get_wkeystring(&len);
-               if(top_level->get_keypress() == RETURN) {
-                       temp_string[0] = '\n';  temp_string[1] = 0;
-                       len = 1;
-               }
-               insert_text(temp_string, len);
+       int key = top_level->get_keypress(), len;
+       if( (key == RETURN) || ( key >= 32 && key <= 255 ) ) {
+               wchar_t *wkeys = top_level->get_wkeystring(&len);
+               if( key == RETURN ) { wkeys[0] = '\n';  wkeys[1] = 0;  len = 1; }
+               insert_text(wkeys, len);
                find_ibeam(1);
                draw(1);
                dispatch_event = 1;
@@ -1289,9 +1210,8 @@ int BC_TextBox::keypress_event()
                switch(last_keypress) {
                case ESC: {
 // Deactivate the suggestions
-                       if(suggestions && suggestions_popup) {
-                               delete suggestions_popup;
-                               suggestions_popup = 0;
+                       if( suggestions_popup ) {
+                               no_suggestions();
                                result = 1;
                        }
                        else {
@@ -1302,6 +1222,8 @@ int BC_TextBox::keypress_event()
 
                case RETURN: {
                        if( rows == 1 ) {
+                               highlight_letter1 = highlight_letter2 = 0;
+                               ibeam_letter = wtext_update();
                                top_level->deactivate();
                                dispatch_event = 1;
                                result = 0;
@@ -1405,7 +1327,7 @@ int BC_TextBox::keypress_event()
                        break; }
 
                case UP: {
-                       if(suggestions && suggestions_popup) {
+                       if( suggestions && suggestions_popup ) {
 // Pass to suggestions popup
 //printf("BC_TextBox::keypress_event %d\n", __LINE__);
                                suggestions_popup->activate(1);
@@ -1492,7 +1414,7 @@ int BC_TextBox::keypress_event()
 // __LINE__,
 // suggestions,
 // suggestions_popup);
-                       if(suggestions && suggestions_popup) {
+                       if( suggestions && suggestions_popup ) {
 // Pass to suggestions popup
                                suggestions_popup->activate(1);
                                suggestions_popup->keypress_event();
@@ -1578,8 +1500,7 @@ int BC_TextBox::keypress_event()
                        break; }
 
                case END: {
-                       delete suggestions_popup;
-                       suggestions_popup = 0;
+                       no_suggestions();
 
                        int old_ibeam_letter = ibeam_letter;
 
@@ -1611,8 +1532,7 @@ int BC_TextBox::keypress_event()
                        break; }
 
                case HOME: {
-                       delete suggestions_popup;
-                       suggestions_popup = 0;
+                       no_suggestions();
 
                        int old_ibeam_letter = ibeam_letter;
 
@@ -1650,10 +1570,7 @@ int BC_TextBox::keypress_event()
                        break; }
 
                case BACKSPACE: {
-                       if(suggestions_popup) {
-                               delete suggestions_popup;
-                               suggestions_popup = 0;
-                       }
+                       no_suggestions();
 
                        if(highlight_letter1 == highlight_letter2) {
                                if(ibeam_letter > 0) {
@@ -2149,20 +2066,9 @@ int BC_TextBox::get_rows()
 
 
 
-BC_TextBoxSuggestions::BC_TextBoxSuggestions(BC_TextBox *text_box,
-       int x,
-       int y)
- : BC_ListBox(x,
-       y,
-       text_box->get_w(),
-       200,
-       LISTBOX_TEXT,
-       text_box->suggestions,
-       0,
-       0,
-       1,
-       0,
-       1)
+BC_TextBoxSuggestions::BC_TextBoxSuggestions(BC_TextBox *text_box, int x, int y)
+ : BC_ListBox(x, y, text_box->get_w(), 200, LISTBOX_TEXT,
+       text_box->suggestions, 0, 0, 1, 0, 1)
 {
        this->text_box = text_box;
        set_use_button(0);
@@ -2173,35 +2079,6 @@ BC_TextBoxSuggestions::~BC_TextBoxSuggestions()
 {
 }
 
-int BC_TextBoxSuggestions::selection_changed()
-{
-#if 0
-//printf("BC_TextBoxSuggestions::selection_changed %d\n", __LINE__);
-       BC_ListBoxItem *item = get_selection(0, 0);
-//printf("BC_TextBoxSuggestions::selection_changed %d\n", __LINE__);
-
-       if(item)
-       {
-               char *current_suggestion = item->get_text();
-//printf("BC_TextBoxSuggestions::selection_changed %d\n", __LINE__);
-//             int text_box_len = strlen(text_box->text);
-//printf("BC_TextBoxSuggestions::selection_changed %d\n", __LINE__);
-               strcpy(text_box->text + text_box->suggestion_column, current_suggestion);
-//printf("BC_TextBoxSuggestions::selection_changed %d\n", __LINE__);
-               *(text_box->text + text_box->suggestion_column + strlen(current_suggestion)) = 0;
-
-//printf("BC_TextBoxSuggestions::selection_changed %d\n", __LINE__);
-               text_box->draw(1);
-               text_box->handle_event();
-       }
-
-       return 1;
-#else
-       return 0;
-#endif
-}
-
-
 int BC_TextBoxSuggestions::handle_event()
 {
        char *current_suggestion = 0;
index b7632ec576af410191d69423a4e4240742f40bf8..f7d38094e0ffa583fc1c1e7990c90f02e4969de3 100644 (file)
@@ -133,7 +133,7 @@ public:
 
 // Compute suggestions for a path
 // If entries is null, just search absolute paths
-       int calculate_suggestions(ArrayList<BC_ListBoxItem*> *entries);
+       int calculate_suggestions(ArrayList<BC_ListBoxItem*> *entries=0, const char *filter=0);
 
 
 // User computes suggestions after handle_event.
@@ -141,6 +141,7 @@ public:
 // A highlighted extension is added if 1 suggestion or a popup appears
 // if multiple suggestions.
 // column - starting column to replace
+       void no_suggestions();
        void set_suggestions(ArrayList<char*> *suggestions, int column);
        BC_ScrollTextBoxYScroll *yscroll;
 
@@ -217,10 +218,8 @@ public:
        BC_TextBoxSuggestions(BC_TextBox *text_box, int x, int y);
        virtual ~BC_TextBoxSuggestions();
 
-       int selection_changed();
        int handle_event();
 
-
        BC_TextBox *text_box;
 };