bunch-o compiler bitch'n
[goodguy/history.git] / cinelerra-5.1 / plugins / titler / titlerwindow.C
index d44140607b00556445ca58ebc54aac3933502b4d..74a4aadf883bf968396c6ec6c8620137612dbbbf 100644 (file)
@@ -681,7 +681,7 @@ void TitleWindow::update_justification()
 void TitleWindow::update_stats()
 {
        text_chars->update(client->config.wlen);
-       int len = MESSAGESIZE-16 - strlen(text->get_text());
+       int len = MESSAGESIZE - BCTEXTLEN - strlen(text->get_text()) - 1;
        if( len < 0 ) len = 0;
        text_bfrsz->update(len);
 }
@@ -1064,6 +1064,18 @@ int TitleText::button_press_event()
 int TitleText::handle_event()
 {
        window->fonts_popup->deactivate();
+       int text_len = strlen(get_text());
+       int avail = MESSAGESIZE - BCTEXTLEN;
+       if( text_len >= avail ) { // back off last utf8 char
+               char text[2*sizeof(client->config.wtext)];
+               strcpy(text, get_text());
+                text_len = avail;
+                while( text_len > 0 && (text[text_len-1] & 0xc0) == 0x80 )
+                        text[--text_len] = 0;
+                if( text_len > 0 )
+                        text[--text_len] = 0;
+               update(text);
+       }
        int len =  sizeof(client->config.wtext) / sizeof(wchar_t);
        wcsncpy(client->config.wtext, get_wtext(), len);
        client->config.wtext[len-1] = 0;
@@ -1411,7 +1423,7 @@ int TitleCurPopup::handle_event()
        return 1;
 }
 
-void TitleCurSubMenu::add_subitem(int popup_type, va_list ap, const char *fmt)
+void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
 {
        char item[BCSTRLEN];
        vsnprintf(item, sizeof(item)-1, fmt, ap);