From: Good Guy Date: Sun, 29 Oct 2017 23:05:02 +0000 (-0600) Subject: wide char tweaks, Features5 update, subtitle triple clk segv X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=c7fa9dc718ca872dd8068d7ddd9f58a81b696a87;p=goodguy%2Fhistory.git wide char tweaks, Features5 update, subtitle triple clk segv --- diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index d7301b48..ec03790a 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -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 *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; diff --git a/cinelerra-5.1/cinelerra/plugindialog.C b/cinelerra-5.1/cinelerra/plugindialog.C index 6068ce1c..9fec465d 100644 --- a/cinelerra-5.1/cinelerra/plugindialog.C +++ b/cinelerra-5.1/cinelerra/plugindialog.C @@ -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; ititle; - if( text && text[0] && !strcasestr(title, text) ) continue; + if( text && text[0] && !bstrcasestr(title, text) ) continue; standalone_data.append(new PluginDialogListItem(title, i)); } diff --git a/cinelerra-5.1/cinelerra/swindow.C b/cinelerra-5.1/cinelerra/swindow.C index fd173764..5764aeae 100644 --- a/cinelerra-5.1/cinelerra/swindow.C +++ b/cinelerra-5.1/cinelerra/swindow.C @@ -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 *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; } } diff --git a/cinelerra-5.1/guicast/cstrdup.h b/cinelerra-5.1/guicast/cstrdup.h index fabac813..59227cbe 100644 --- a/cinelerra-5.1/guicast/cstrdup.h +++ b/cinelerra-5.1/guicast/cstrdup.h @@ -2,7 +2,9 @@ #define __CSTRDUP_H__ #include +#include #include +#include 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 diff --git a/cinelerra-5.1/guicast/language.h b/cinelerra-5.1/guicast/language.h index 178e8daf..ae5f9803 100644 --- a/cinelerra-5.1/guicast/language.h +++ b/cinelerra-5.1/guicast/language.h @@ -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; }