wide char tweaks, Features5 update, subtitle triple clk segv
authorGood Guy <good1.2guy@gmail.com>
Sun, 29 Oct 2017 23:05:02 +0000 (17:05 -0600)
committerGood Guy <good1.2guy@gmail.com>
Sun, 29 Oct 2017 23:05:02 +0000 (17:05 -0600)
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/plugindialog.C
cinelerra-5.1/cinelerra/swindow.C
cinelerra-5.1/doc/Features5.pdf
cinelerra-5.1/guicast/bctextbox.C
cinelerra-5.1/guicast/cstrdup.h
cinelerra-5.1/guicast/language.h

index d7301b48c5ac256c076fb50a6d1c3a870abb3455..ec03790af2e61e640fa64a9ecaaa3864ef1e2066 100644 (file)
@@ -29,6 +29,7 @@
 #include "bcsignals.h"
 #include "bchash.h"
 #include "cache.h"
+#include "cstrdup.h"
 #include "clip.h"
 #include "clippopup.h"
 #include "cursors.h"
@@ -1196,7 +1197,7 @@ void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
                    (picon->indexable && picon->indexable->awindow_folder == folder) ||
                    (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
                        const char *text = search_text->get_text();
-                       int hidden = text && text[0] && !strcasestr(picon->get_text(), text);
+                       int hidden = text && text[0] && !bstrcasestr(picon->get_text(), text);
                        if( picon->vicon ) picon->vicon->hidden = hidden;
                        if( hidden ) continue;
                        BC_ListBoxItem *item2, *item1;
index 6068ce1c73bf74ff6007b914dd706d7c40f2f37a..9fec465d3a1e1c6752a4b5b369ffc6e83df43bda 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "condition.h"
+#include "cstrdup.h"
 #include "edl.h"
 #include "edlsession.h"
 #include "language.h"
@@ -753,7 +754,7 @@ void PluginDialog::load_plugin_list(int redraw)
 
        for( int i=0; i<plugindb.total; ++i ) {
                const char *title = plugindb.values[i]->title;
-               if( text && text[0] && !strcasestr(title, text) ) continue;
+               if( text && text[0] && !bstrcasestr(title, text) ) continue;
                standalone_data.append(new PluginDialogListItem(title, i));
        }
 
index fd173764f8eab5d61e4d4218c986e0a3af099422..5764aeae49875e09f8ad924cb86a2fbc951cd72a 100644 (file)
@@ -743,7 +743,7 @@ void ScriptEntry::set_text(char *text, int isz)
 
 int ScriptEntry::handle_event()
 {
-       if( sw_gui->get_button_down() &&
+       if( ttext && sw_gui->get_button_down() &&
            sw_gui->get_buttonpress() == 1 &&
            sw_gui->get_triple_click() ) {
                int ibeam = get_ibeam_letter(), row = 0;
@@ -795,6 +795,8 @@ void SWindowGUI::load_script()
                return;
        }
        load_script(fp);
+       script_text_no = -1;
+       load_selection(script_entry_no=0, 0);
 }
 
 void SWindowGUI::load_script(FILE *fp)
@@ -816,7 +818,6 @@ void SWindowGUI::load_script(FILE *fp)
        script_scroll->update_length(script.size(), script_entry_no, hw, 0);
        script_position->update(script_entry_no);
        script_position->set_boundaries((int64_t)0, (int64_t)script.size()-1);
-
        fclose(fp);
 }
 
@@ -835,9 +836,11 @@ void SWindowGUI::save_spumux_data()
        for( Track *track=tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_SUBTITLE ) continue;
                if( !track->record ) continue;
-               char *cp = track_title;
-               for( char *bp=track->title; *bp; ++bp,++cp )
-                       *cp = !isalnum(*bp) ? '_' : *bp;
+               char *cp = track_title, *ep = cp+sizeof(track_title)-6;
+               for( const char *bp=track->title; cp<ep && *bp!=0; ) {
+                       int b = butf8(bp), c = !iswalnum(b) ? '_' : b;
+                       butf8(c, cp);
+               }
                *cp = 0;
                snprintf(ext,len,"-%s.udvd",track_title);
                FILE *fp = fopen(filename, "w");
index 0b5df7886e97b184b9380ad8c202b4b63dfad5d4..6f10adc7a1d224e286e7e67d9e84071ca7afb483 100644 (file)
Binary files a/cinelerra-5.1/doc/Features5.pdf and b/cinelerra-5.1/doc/Features5.pdf differ
index 506b578da030d88d710bd38ed32432f14bea0a59..2a34c18096952024b3c7c5fa9eb1a40a8432843c 100644 (file)
@@ -402,9 +402,9 @@ void BC_TextBox::set_suggestions(ArrayList<char*> *suggestions, int column)
 // Show the highlighted text
                if( suggestions->size() == 1 ) {
                        highlight_letter1 = wtext_update();
-                       text_update(wtext,wlen, text,tsize);
+                       int len = text_update(wtext,wlen, text,tsize);
                        char *current_suggestion = suggestions->get(0);
-                       int col = highlight_letter1 - suggestion_column;
+                       int col = len - suggestion_column;
                        if( col < 0 ) col = 0;
                        char *cur = current_suggestion + col;
                        tstrcat(cur);
@@ -2078,6 +2078,7 @@ void BC_TextBox::paste_selection(int clipboard_num)
                len = BC_Resources::encode(BC_Resources::encoding, BC_Resources::wide_encoding,
                        cstring,len, (char *)wstring,(len+1)*sizeof(wchar_t)) / sizeof(wchar_t);
                insert_text(wstring, len);
+               last_keypress = 0;
        }
 }
 
index fabac81338a2f3c3a9d356129b1910a4cc80933c..59227cbe56ecea58ec160a500bc4e82a4a6a3d1c 100644 (file)
@@ -2,7 +2,9 @@
 #define __CSTRDUP_H__
 
 #include <stdarg.h>
+#include <stdint.h>
 #include <string.h>
+#include <wctype.h>
 
 static inline char *cstrcat(int n, ...) {
   int len = 0;  va_list va;  va_start(va,n);
@@ -20,4 +22,62 @@ static inline char *cstrdup(const char *cp) {
 #define lengthof(ary) ((int)(sizeof(ary)/sizeof(ary[0])))
 #endif
 
+static inline int butf8(const char *&cp)
+{
+       const unsigned char *bp = (const unsigned char *)cp;
+       int ret = *bp++;
+       if( ret >= 0x80 ) {
+               int v = ret - 0xc0;
+               static const int64_t sz = 0x5433222211111111;
+               int n = v < 0 ? 0 : (sz >> (v&0x3c)) & 0x0f;
+               for( int i=n; --i>=0; ret+=*bp++ ) ret <<= 6;
+               static const uint32_t ofs[6] = {
+                       0x00000000U, 0x00003080U, 0x000E2080U,
+                       0x03C82080U, 0xFA082080U, 0x82082080U
+               };
+               ret -= ofs[n];
+       }
+       cp = (const char *)bp;
+       return ret;
+}
+static inline int butf8(unsigned int v, char *&cp)
+{
+       unsigned char *bp = (unsigned char *)cp;
+       if( v >= 0x00000080 ) {
+               int i = v < 0x00000800 ? 2 : v < 0x00010000 ? 3 :
+                       v < 0x00200000 ? 4 : v < 0x04000000 ? 5 : 6;
+               int m = 0xff00 >> i;
+               *bp++ = (v>>(6*--i)) | m;
+               while( --i >= 0 ) *bp++ = ((v>>(6*i)) & 0x3f) | 0x80;
+       }
+       else
+               *bp++ = v;
+       int ret = bp - (unsigned char *)cp;
+       cp = (char *)bp;
+       return ret;
+}
+
+static inline int bstrcasecmp(const char *ap, const char *bp)
+{
+       int a, b, ret;
+       do {
+               a = towlower(butf8(ap));  b = towlower(butf8(bp));
+       } while( !(ret=a-b) && a && b );
+       return ret;
+}
+
+static inline const char *bstrcasestr(const char *src, const char *tgt)
+{
+       int ssz = strlen(src), tsz = strlen(tgt), ret = 0;
+       const char *cp = tgt;
+       wchar_t wtgt[tsz + 1], *tp = wtgt;
+       while( *cp ) *tp++ = towlower(butf8(cp));
+       for( tsz=tp-wtgt; ssz>=tsz; ++src,--ssz ) {
+               cp = src;   tp = wtgt;
+               for( int i=tsz; --i>=0 && !(ret=towlower(butf8(cp))-*tp); ++tp );
+               if( !ret ) return src;
+       }
+       return 0;
+}
+
 #endif
index 178e8dafad6a45b55e6fd0ec6d4d6d4535bc4bb6..ae5f9803d1319f29e13d3866753d00165667fcdb 100644 (file)
@@ -60,7 +60,7 @@ static inline char *msgqual(const char *msgqual,const char *msgid)
   *cp++ = '#';
   for( const char *bp=msgid; *bp!=0; *cp++=*bp++ );
   *cp = 0;
-  if( (cp=gettext(msg)) == msg ) cp = (char*)msgid;
+  if( (cp=gettext(msg)) == msg ) cp = gettext(msgid);
   return cp;
 }