#include "bcsignals.h"
#include "bchash.h"
#include "cache.h"
+#include "cstrdup.h"
#include "clip.h"
#include "clippopup.h"
#include "cursors.h"
(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;
*/
#include "condition.h"
+#include "cstrdup.h"
#include "edl.h"
#include "edlsession.h"
#include "language.h"
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));
}
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;
return;
}
load_script(fp);
+ script_text_no = -1;
+ load_selection(script_entry_no=0, 0);
}
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);
}
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");
// 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);
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;
}
}
#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);
#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
*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;
}