#include "cstrdup.h"
#include "edl.h"
#include "filesystem.h"
+#include "language.h"
#include "localsession.h"
#include "mainerror.h"
#include "mainmenu.h"
void SWindowGUI::load()
{
+ const char *script_text =
+ _("Adding Subtitles: quick \"How To\" (= or * indicates comment)\n"
+ "*2345678901234567890123456789012345678901234567890123456789\n"
+ "For regular DVD subtitles, put script in a text file. "
+ "Lines can be any length but they will be broken up "
+ "to fit according to some criteria below.\n"
+ "Running text used as script lines will be broken into multilple lines.\n"
+ "The target line length is 60 characters.\n"
+ "Punctuation may be flagged to create an early line break.\n"
+ "Single carriage return ends an individual script line.\n"
+ "Double carriage return indicates the end of an entry.\n"
+ "Whitespace at beginning or end of line is removed.\n"
+ "You can edit the active line in the Line Text box.\n"
+ "\n"
+ "== A new entry is here for illustration purposes.\n"
+ "* Entry 2\n"
+ "This is the second entry.\n");
+
if( script_path[0] && !access(script_path,R_OK) ) {
load_script();
- int text_no = script_text_no;
- script_text_no = -1;
- load_selection(script_entry_no, text_no);
}
else {
- script.remove_all_objects();
script_path[0] = 0;
load_path->update(script_path);
- script_entry_no = 0;
- script_text_no = 0;
+ FILE *fp = fmemopen((void *)script_text, strlen(script_text), "r");
+ load_script(fp);
}
+ int text_no = script_text_no;
+ script_text_no = -1;
+ load_selection(script_entry_no, text_no);
}
SWindowGUI::SWindowGUI(SWindow *swindow, int x, int y, int w, int h)
script_entry->set_text_row(0);
}
script_text_no = row;
- char line[BCTEXTLEN], *bp = line, *cp = rp;
- while( *cp && *cp!='\n' ) *bp++ = *cp++;
+ char line[BCTEXTLEN], *bp = line;
+ char *ep = bp+sizeof(line)-1, *cp = rp;
+ while( bp < ep && *cp && *cp!='\n' ) *bp++ = *cp++;
*bp = 0; bp = texts->text;
int char1 = rp-bp, char2 = cp-bp;
script_entry->set_selection(char1, char2, char2);
memmove(cp,sp,dp+1-sp);
used -= n; dp -= n; ep -= n;
}
- // constrain line_limit
- if( (n=(ep-cp)/2) < limit2 || n > line_limit )
+ // target about half remaining line, constrain line_limit
+ if( (n=(ep-1-cp)/2) < limit2 || n > line_limit )
n = line_limit;
- // search for last punct, last space
+ // search for last punct, last space before line_limit
for( bp=cp, pp=sp=0; --n>=0 && cp<ep; ++cp ) {
if( ispunct(*cp) && isspace(*(cp+1)) ) pp = cp;
else if( isspace(*cp) ) sp = cp;
}
- // long enough to break
+ // line not empty
if( cp < ep ) {
// first, after punctuation
if( pp && pp-bp >= limit4 )
for(;;) { // load non-blank lines
//int len = strlen(line);
- //if( cp[len-1] == '\n' ) cp[len-1] = 0;
+ //if( line[len-1] == '\n' ) line[len-1] = ' ';
entry->append(line);
char *cp = fgets(line,sizeof(line),fp);
- if( !cp ) return 1;
+ if( !cp ) break;
++script_line_no;
while( *cp && isspace(*cp) ) ++cp;
if( !*cp ) break;
MainError::show_error(string);
return;
}
+ load_script(fp);
+}
+void SWindowGUI::load_script(FILE *fp)
+{
script.remove_all_objects();
script_line_no = 0;
script_text_lines = 0;
if( gui ) gui->stop(1);
window_lock->unlock();
Thread::cancel();
- Thread::join();
}
+ Thread::join();
}
void SWindow::run()
SubttlSWin::SubttlSWin(MWindow *mwindow)
- : BC_MenuItem(_("SubTitle"), _("Alt-y"), 'y')
+ : BC_MenuItem(_("SubTitle..."), _("Alt-y"), 'y')
{
set_alt();
this->mwindow = mwindow;