int SWindowLoadFile::handle_event()
{
- sw_gui->load_path->set_suggestions(0,0);
- sw_gui->load_script();
- sw_gui->set_script_pos(0);
+ if( sw_gui->script_path[0] ) {
+ sw_gui->load_path->set_suggestions(0,0);
+ sw_gui->load_script();
+ sw_gui->set_script_pos(0);
+ }
+ else {
+ eprintf(_("script text file path required"));
+ }
return 1;
}
int SWindowSaveFile::handle_event()
{
- sw_gui->save_spumux_data();
+ if( sw_gui->script_path[0] ) {
+ sw_gui->save_spumux_data();
+ }
+ else {
+ eprintf(_("script microdvd file path required"));
+ }
return 1;
}
x1 = x + pad;
blank_line = new char[2];
blank_line[0] = ' '; blank_line[1] = 0;
- int rows = (ok_y - y - 4*pad) / text_rowsz - 3;
- int w1 = get_w()-x1-pad;
+ add_subwindow(script_title = new BC_Title(x1, y, _("Script Text:")));
+ y += script_title->get_h() + pad;
+ int rows = (ok_y - y - BC_Title::calculate_h(this,_("Line Text:")) -
+ 4*pad) / text_rowsz - 3;
+ int w1 = get_w() - x1 - pad;
script_entry = new ScriptEntry(this, x1, y, w1, rows, blank_line);
script_entry->create_objects();
y += script_entry->get_h() + pad;
+ add_subwindow(line_title = new BC_Title(x1, y, _("Line Text:")));
+ y += line_title->get_h() + pad;
line_entry = new ScriptEntry(this, x1, y, w1, 3);
line_entry->create_objects();
ok = new SWindowOK(this, ok_x, ok_y);
int w1 = w - x1 - pad;
script_scroll->reposition_window(x1, y, w1);
y += hh + 2*pad;
+ script_title->reposition_window(x, y);
+ y += script_title->get_h() + pad;
w1 = w - x - pad;
- int rows = (ok_y - y - 4*pad) / text_rowsz - 3;
+ int rows = (ok_y - y - line_title->get_h() - 4*pad) / text_rowsz - 3;
script_entry->reposition_window(x, y, w1, rows);
- y += script_entry->get_h() + pad;
+ y += script_entry->get_h() + 2*pad;
+ line_title->reposition_window(x, y);
+ y += line_title->get_h() + pad;
line_entry->reposition_window(x, y, w1, 3);
return 0;
}
void ScriptEntry::set_text(char *text, int isz)
{
if( !text || !*text ) return;
- if( isz < 0 ) isz = strlen(text);
+ if( isz < 0 ) isz = strlen(text)+1;
BC_ScrollTextBox::set_text(text, isz);
ttext = text;
}
+int ScriptEntry::handle_event()
+{
+ if( sw_gui->get_button_down() &&
+ sw_gui->get_buttonpress() == 1 &&
+ sw_gui->get_triple_click() ) {
+ int ibeam = get_ibeam_letter(), row = 0;
+ const char *tp = ttext;
+ while( *tp && tp-ttext < ibeam ) {
+ if( *tp++ == '\n' ) ++row;
+ }
+ int pos = sw_gui->script_entry_no;
+ sw_gui->load_selection(pos, row);
+ }
+ return 1;
+}
int SWindowGUI::load_script_line(FILE *fp)
{
if( letter1 > wtext_len ) letter1 = wtext_len;
if( letter2 > wtext_len ) letter2 = wtext_len;
if( !wtext_len ) return;
-
- while( letter1 > 0 && iswalnum(wtext[letter1]) ) --letter1;
- if( letter1 < wtext_len && iswspace(wtext[letter1]) ) ++letter1;
-
- while( letter2 < wtext_len && iswalnum(wtext[letter2]) ) ++letter2;
+ for( int i=letter1; i>=0 && iswalnum(wtext[i]); --i ) letter1 = i;
+ for( int i=letter2; i<wtext_len && iswalnum(wtext[i]); ) letter2 = ++i;
if( letter2 < wtext_len && wtext[letter2] == ' ' ) ++letter2;
}
void BC_TextBox::select_line(int &letter1, int &letter2, int ibeam_letter)
{
int wtext_len = wtext_update();
- if(!wtext_len) return;
-
letter1 = letter2 = ibeam_letter;
-
-// Rewind to previous linefeed
- do {
- if( wtext[letter1] != '\n' ) letter1--;
- } while( letter1 > 0 && wtext[letter1] != '\n' );
- if( wtext[letter1] == '\n' ) letter1++;
-
-// Advance to next linefeed
- do {
- if( wtext[letter2] != '\n' ) letter2++;
- } while( letter2 < wtext_len && wtext[letter2] != '\n' );
- if( letter2 < wtext_len && wtext[letter2] == '\n') letter2++;
-
- if(letter1 < 0) letter1 = 0;
- if(letter2 < 0) letter2 = 0;
- if(letter1 > wtext_len) letter1 = wtext_len;
- if(letter2 > wtext_len) letter2 = wtext_len;
+ if( letter1 < 0 ) letter1 = 0;
+ if( letter2 < 0 ) letter2 = 0;
+ if( letter1 > wtext_len ) letter1 = wtext_len;
+ if( letter2 > wtext_len ) letter2 = wtext_len;
+ if( !wtext_len ) return;
+ for( int i=letter1; i>=0 && wtext[i]!='\n'; --i ) letter1 = i;
+ for( int i=letter2; i<wtext_len && wtext[i]!='\n'; ) letter2 = ++i;
}
void BC_TextBox::copy_selection(int clipboard_num)
this->text->wset_selection(char1, char2, ibeam);
}
+int BC_ScrollTextBox::get_ibeam_letter()
+{
+ return this->text->get_ibeam_letter();
+}
+
int deactivate();
const char* get_text();
const wchar_t* get_wtext();
- const char* get_utf8text();
void set_text(char *text, int isz);
int get_text_rows();
// Set top left of text view
int reposition_window(int x, int y, int w = -1, int rows = -1);
int uses_text();
-#ifdef X_HAVE_UTF8_STRING
- int utf8seek(int i, int reverse);
-#endif
static int calculate_h(BC_WindowBase *gui, int font, int has_border, int rows);
static int calculate_row_h(int rows, BC_WindowBase *parent_window, int has_border = 1, int font = MEDIUMFONT);
static int pixels_to_rows(BC_WindowBase *window, int font, int pixels);
int get_h();
// Visible rows for resizing
int get_rows();
+ int get_ibeam_letter();
friend class BC_ScrollTextBoxText;
friend class BC_ScrollTextBoxYScroll;