#include "lyx.h"
#include "layout_forms.h"
#include "bullet_forms.h"
-#include "print_form.h"
#include "form1.h"
#include "lyx_main.h"
#include "lyx_cb.h"
#include "lyxrc.h"
#include "lyxtext.h"
#include "CutAndPaste.h"
+#include "TextCache.h"
using std::ifstream;
using std::copy;
using std::ios;
using std::istream_iterator;
using std::pair;
+using std::vector;
+using std::sort;
+using std::equal;
extern Combox * combo_language;
+extern Combox * combo_language2;
extern BufferList bufferlist;
extern void show_symbols_form();
extern FD_form_title * fd_form_title;
extern FD_form_quotes * fd_form_quotes;
extern FD_form_preamble * fd_form_preamble;
extern FD_form_table * fd_form_table;
-extern FD_form_print * fd_form_print;
extern FD_form_figure * fd_form_figure;
extern FD_form_screen * fd_form_screen;
extern FD_form_toc * fd_form_toc;
}
-// only called from this file, LyXView and LyXFunc
-char updatetimer = 0;
-
-
-// only called from BufferView_pimpl and LyXFunc
-void FreeUpdateTimer()
-{
- /* a real free timer would be better but I don't know
- * how to do this with xforms */
- updatetimer = 0;
-}
-
-
-// Only called from LyXFunc
-void SetUpdateTimer(float time)
-{
- fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
- updatetimer = 1;
-}
-
-
//
// Menu callbacks
//
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- if (!buffer->isDviClean()) {
- Path p(path);
- ret = MenuRunLaTeX(buffer);
- }
- return ret;
+
+ Path p(path);
+ ret = MenuRunLaTeX(buffer);
+
+ return ret;
}
return false;
/* get DVI-Filename */
if (name.empty())
- name = ChangeExtension(buffer->getLatexName(),
- ".dvi", true);
+ name = ChangeExtension(buffer->getLatexName(), ".dvi");
path = OnlyPath(name);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
// the return code of the command. This means that all
// the code I added in PrintApplyCB is currently
// useless...
-#ifdef WITH_WARNINGS
-#warning What should we do here?
-#endif
+ // CHECK What should we do here?
ShowMessage(buffer, _("Executing command:"), cmd);
result = one.startscript(Systemcalls::System, cmd);
} else {
return false;
}
// Generate postscript file
- string psname = ChangeExtension (buffer->fileName(),
- ".ps_tmp", true);
+ string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps_tmp"));
string paper;
// Start postscript viewer
ProhibitInput(current_view);
- string ps = ChangeExtension (buffer->fileName(),
- ".ps_tmp", true);
+ string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps_tmp"));
// push directorypath, if necessary
string path = OnlyPath(buffer->fileName());
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
}
// Send fax
- string ps = ChangeExtension (buffer->fileName(), ".ps_tmp", true);
+ string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps_tmp"));
string path = OnlyPath (buffer->fileName());
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
buffer->makeLaTeXFile(s, string(), true);
ShowMessage(buffer, _("Nice LaTeX file saved as"),
MakeDisplayPath(s));
- buffer->markDviDirty();
}
}
}
// Get LinuxDoc-Filename
- string s = ChangeExtension(buffer->fileName(),
- ".sgml", false);
+ string s = ChangeExtension(buffer->fileName(), ".sgml");
if (!AskOverwrite(buffer, s))
return;
ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
MakeDisplayPath(s),"'...");
- buffer->makeLinuxDocFile(s, 65);
+ buffer->makeLinuxDocFile(s, true);
buffer->redraw();
ShowMessage(buffer, _("LinuxDoc SGML file save as"),
MakeDisplayPath(s));
}
// Get DocBook-Filename
- string s = ChangeExtension(buffer->fileName(),
- ".sgml", false);
+ string s = ChangeExtension(buffer->fileName(), ".sgml");
if (!AskOverwrite(buffer, s))
return;
ShowMessage(buffer, _("Building DocBook SGML file `"),
MakeDisplayPath(s), "'...");
- buffer->makeDocBookFile(s, 65);
+ buffer->makeDocBookFile(s, true);
buffer->redraw();
ShowMessage(buffer, _("DocBook SGML file save as"),
MakeDisplayPath(s));
//if (!bv->text) return;
/* get LaTeX-Filename */
- string s = ChangeExtension (buffer->fileName(),
- ".txt", false);
+ string s = ChangeExtension (buffer->fileName(), ".txt");
if (!AskOverwrite(buffer, s))
}
-void MenuPrint(Buffer * buffer)
-{
- // Who cares?
- //if (!bv->text)
- // return;
-
- string input_file = ChangeExtension(buffer->fileName(),
- lyxrc.print_file_extension,
- true);
- fl_set_input(fd_form_print->input_file, input_file.c_str());
-
- if (fd_form_print->form_print->visible) {
- fl_raise_form(fd_form_print->form_print);
- }
- else {
- fl_show_form(fd_form_print->form_print,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("Print"));
- }
-}
-
-
void MenuMakeHTML(Buffer * buffer)
{
// First, create LaTeX file
// the tex file name has to be correct for
// latex, but the html file name can be
// anything.
- string result = ChangeExtension(file, ".html", false);
+ string result = ChangeExtension(file, ".html");
string infile = buffer->getLatexName(false);
string tmp = lyxrc.html_command;
tmp = subst(tmp, "$$FName", infile);
// And now, run the converter
string file = buffer->fileName();
- string result = ChangeExtension(file, ".html", false);
- string infile = ChangeExtension(file, ".sgml", false);
+ string result = ChangeExtension(file, ".html");
+ string infile = ChangeExtension(file, ".sgml");
string tmp = lyxrc.linuxdoc_to_html_command;
tmp = subst(tmp, "$$FName", infile);
tmp = subst(tmp, "$$OutName", result);
// And now, run the converter
string file = buffer->fileName();
- string result = ChangeExtension(file, ".html", false);
- string infile = ChangeExtension(file, ".sgml", false);
+ string result = ChangeExtension(file, ".html");
+ string infile = ChangeExtension(file, ".sgml");
string tmp = lyxrc.docbook_to_html_command;
tmp = subst(tmp, "$$FName", infile);
tmp = subst(tmp, "$$OutName", result);
// postscript
else if (extyp == "postscript") {
// Start Print-dialog. Not as good as dvi... Bernhard.
- MenuPrint(buffer);
+ //should start lyxview->getDialogs()->showPrint();
+ // to get same as before
+ // MenuPrint(buffer);
// Since the MenuPrint is a pop-up, we can't use
// the same trick as above. (Asger)
// MISSING: Move of ps-file :-(
// clear the selection
bv->beforeChange();
if (!asParagraph)
- bv->text->InsertStringA(tmpstr);
+ bv->text->InsertStringA(bv, tmpstr);
else
- bv->text->InsertStringB(tmpstr);
- bv->update(1);
+ bv->text->InsertStringB(bv, tmpstr);
+ bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
}
-void MenuPasteSelection(char at)
-{
- if (!current_view->available())
- return;
-
- ascii_type = at;
-
- Atom data_prop = XInternAtom(fl_display,
- "LyX_Primary",
- false);
- if (data_prop == None)
- return;
- XConvertSelection(fl_display,
- XA_PRIMARY, XA_STRING, data_prop,
- current_view->owner()->getForm()->window, 0);
- XFlush(fl_display);
-}
-
-
-
-
// candidate for move to LyXView
// This is only used in toolbar.C
void LayoutsCB(int sel, void *)
int errorcode = 0;
/* generate a path-less extension name */
- string name = ChangeExtension (filename, ".sgml", true);
+ string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
string path = OnlyPath (filename);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = bv->buffer()->tmppath;
if (!bv->available())
return 0;
- bv->buffer()->makeLinuxDocFile(name, 0);
-#ifdef WITH_WARNINGS
-#warning remove this once we have a proper geometry class
-#endif
+ bv->buffer()->makeLinuxDocFile(name, false);
+
+ // CHECK remove this once we have a proper geometry class
+
BufferParams::PAPER_SIZE ps =
static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
switch (ps) {
s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
- } else
- bv->buffer()->markDviClean();
+ }
break;
default: /* unknown output */
break;
int RunDocBook(int flag, string const & filename)
{
/* generate a path-less extension name */
- string name = ChangeExtension (filename, ".sgml", true);
+ string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
string path = OnlyPath (filename);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->buffer()->tmppath;
if (!current_view->available())
return 0;
- current_view->buffer()->makeDocBookFile(name, 0);
+ current_view->buffer()->makeDocBookFile(name, false);
// Shall this code go or should it stay? (Lgb)
// This code is a placeholder for future implementation. (Jose')
string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
- } else
- current_view->buffer()->markDviClean();
+ }
}
break;
default: /* unknown output */
Buffer * buf = current_view->buffer();
fl_set_input(fd_form_paragraph->input_labelwidth,
- current_view->text->cursor.par->GetLabelWidthString().c_str());
+ current_view->text->cursor.par()->GetLabelWidthString().c_str());
fl_set_button(fd_form_paragraph->radio_align_right, 0);
fl_set_button(fd_form_paragraph->radio_align_left, 0);
fl_set_button(fd_form_paragraph->radio_align_center, 0);
fl_set_button(fd_form_paragraph->radio_align_block, 0);
- int align = current_view->text->cursor.par->GetAlign();
+ int align = current_view->text->cursor.par()->GetAlign();
if (align == LYX_ALIGN_LAYOUT)
align = textclasslist.Style(buf->params.textclass,
- current_view->text->cursor.par->GetLayout()).align;
+ current_view->text->cursor.par()->GetLayout()).align;
switch (align) {
case LYX_ALIGN_RIGHT:
}
fl_set_button(fd_form_paragraph->check_lines_top,
- current_view->text->cursor.par->FirstPhysicalPar()->line_top);
+ current_view->text->cursor.par()->FirstPhysicalPar()->line_top);
fl_set_button(fd_form_paragraph->check_lines_bottom,
- current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
+ current_view->text->cursor.par()->FirstPhysicalPar()->line_bottom);
fl_set_button(fd_form_paragraph->check_pagebreaks_top,
- current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
+ current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
- current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
+ current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
fl_set_button(fd_form_paragraph->check_noindent,
- current_view->text->cursor.par->FirstPhysicalPar()->noindent);
+ current_view->text->cursor.par()->FirstPhysicalPar()->noindent);
fl_set_input (fd_form_paragraph->input_space_above, "");
- switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
+ switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
case VSpace::NONE:
fl_set_choice (fd_form_paragraph->choice_space_above, 1);
break;
case VSpace::LENGTH:
fl_set_choice (fd_form_paragraph->choice_space_above, 7);
fl_set_input (fd_form_paragraph->input_space_above,
- current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
+ current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str());
break;
}
fl_set_button (fd_form_paragraph->check_space_above,
- current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
+ current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.keep());
fl_set_input (fd_form_paragraph->input_space_below, "");
- switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
+ switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) {
case VSpace::NONE:
fl_set_choice (fd_form_paragraph->choice_space_below,
1);
fl_set_choice (fd_form_paragraph->choice_space_below,
7);
fl_set_input (fd_form_paragraph->input_space_below,
- current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
+ current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
break;
}
fl_set_button (fd_form_paragraph->check_space_below,
- current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
+ current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep());
fl_set_button(fd_form_paragraph->check_noindent,
- current_view->text->cursor.par->FirstPhysicalPar()->noindent);
+ current_view->text->cursor.par()->FirstPhysicalPar()->noindent);
if (current_view->buffer()->isReadonly()) {
DisableParagraphLayout();
// This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
// Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
-LyXFont UserFreeFont()
+LyXFont UserFreeFont(BufferParams const & params)
{
LyXFont font(LyXFont::ALL_IGNORE);
case 11: font.setColor(LColor::inherit); break;
}
+ int choice = combo_language2->get();
+ if (choice == 1)
+ font.setLanguage(ignore_language);
+ else if (choice == 2)
+ font.setLanguage(params.language_info);
+ else
+ font.setLanguage(&languages[combo_language2->getline()]);
+
return font;
}
-
-
/* callbacks for form form_title */
extern "C" void TimerCB(FL_OBJECT *, long)
{
labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
noindent = fl_get_button(fd_form_paragraph->check_noindent);
- current_view->text->SetParagraph(line_top,
+ current_view->text->SetParagraph(current_view,
+ line_top,
line_bottom,
pagebreak_top,
pagebreak_bottom,
align,
labelwidthstring,
noindent);
- current_view->update(1);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
}
// we set toggleall locally here, since it should be true for
// all other uses of ToggleAndShow() (JMarc)
toggleall = fl_get_button(fd_form_character->check_toggle_all);
- ToggleAndShow(current_view, UserFreeFont());
+ ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
+ current_view->setState();
toggleall = true;
}
BufferParams * params = &(current_view->buffer()->params);
Language const * old_language = params->language_info;
- Language const * new_language;
params->language = combo_language->getline();
Languages::iterator lit = languages.find(params->language);
+
+ Language const * new_language;
if (lit != languages.end())
new_language = &(*lit).second;
else
new_language = default_language;
if (current_view->available()) {
- if (old_language != new_language &&
- old_language->RightToLeft == new_language->RightToLeft &&
- ! current_view->buffer()->isMultiLingual() ) {
+ if (old_language != new_language
+ && old_language->RightToLeft() == new_language->RightToLeft()
+ && !current_view->buffer()->isMultiLingual())
current_view->buffer()->ChangeLanguage(old_language,
new_language);
- current_view->buffer()->redraw();
+ if (old_language != new_language) {
+ //current_view->buffer()->redraw();
+ redo = true;
}
}
params->language_info = new_language;
if (!current_view->available())
return;
- current_view->text->SetCursor(current_view->text->cursor.par,
- current_view->text->cursor.pos);
+ current_view->text->SetCursor(current_view,
+ current_view->text->cursor.par(),
+ current_view->text->cursor.pos());
current_view->setState();
LyXTextClassList::ClassList::size_type new_class =
current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
current_view->buffer()->markDirty();
-
+
params->options =
fl_get_input(fd_form_document->input_extra);
-
}
return;
// check for tables in tables
- if (current_view->text->cursor.par->table){
+ if (current_view->text->cursor.par()->table){
WriteAlert(_("Impossible Operation!"),
_("Cannot insert table in table."),
_("Sorry."));
current_view->hideCursor();
current_view->beforeChange();
- current_view->update(-2);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
- current_view->text->SetCursorParUndo();
+ current_view->text->SetCursorParUndo(current_view->buffer());
current_view->text->FreezeUndo();
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- if (current_view->text->cursor.par->Last()) {
- current_view->text->CursorLeft();
+ if (current_view->text->cursor.par()->Last()) {
+ current_view->text->CursorLeft(current_view);
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
current_view->text->current_font.setLatex(LyXFont::OFF);
//if (!fl_get_button(fd_form_table->check_latex)){
// insert the new wysiwy table
- current_view->text->SetLayout(0); // standard layout
- if (current_view->text->cursor.par->footnoteflag ==
+ current_view->text->SetLayout(current_view, 0); // standard layout
+ if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
current_view->text
- ->SetParagraph(0, 0,
+ ->SetParagraph(current_view, 0, 0,
0, 0,
VSpace (0.3 * current_view->buffer()->
params.spacing.getValue(),
0);
} else {
current_view->text
- ->SetParagraph(0, 0,
+ ->SetParagraph(current_view, 0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
0);
}
- current_view->text->cursor.par->table =
+ current_view->text->cursor.par()->table =
new LyXTable(xsize, ysize);
Language const * lang =
- current_view->text->cursor.par->getParLanguage();
- LyXFont font(LyXFont::ALL_INHERIT,lang);
+ current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
+ LyXFont font(LyXFont::ALL_INHERIT, lang);
for (int i = 0; i < xsize * ysize - 1; ++i) {
- current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
- current_view->text->cursor.par->SetFont(0, font);
+ current_view->text->cursor.par()
+ ->InsertChar(0, LyXParagraph::META_NEWLINE, font);
}
- current_view->text->RedoParagraph();
+ current_view->text->RedoParagraph(current_view);
current_view->text->UnFreezeUndo();
- current_view->update(1);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
current_view->owner()->getMiniBuffer()->Set(_("Table inserted"));
current_view->setState();
}
}
-/* callbacks for form form_print */
-
-extern "C" void PrintCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_print->form_print);
-}
-
-
-static
-bool stringOnlyContains (string const & LStr, char const * cset)
-{
- return LStr.find_first_not_of(cset) == string::npos;
-}
-
-
-extern "C" void PrintApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
- Buffer * buffer = current_view->buffer();
- string path = OnlyPath(buffer->fileName());
-
- string pageflag;
- if (fl_get_button(fd_form_print->radio_even_pages))
- pageflag = lyxrc.print_evenpage_flag + ' ';
- else if (fl_get_button(fd_form_print->radio_odd_pages))
- pageflag = lyxrc.print_oddpage_flag + ' ';
-
-// Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
-// User may give a page (range) list
-// User may print multiple (unsorted) copies
- string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
- pages = subst(pages, '+',',');
- pages = frontStrip(strip(pages)) ;
- while (!pages.empty()) { // a page range was given
- string piece ;
- pages = split (pages, piece, ',') ;
- piece = strip(piece) ;
- piece = frontStrip(piece) ;
- if ( !stringOnlyContains (piece, "0123456789-") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'range of pages'!"));
- return;
- }
- if (piece.find('-') == string::npos) { // not found
- pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
- } else if (suffixIs(piece, "-") ) { // missing last page
- pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
- } else if (prefixIs(piece, "-") ) { // missing first page
- pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
- } else {
- pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
- }
- }
-
- string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
- if (!copies.empty()) { // a number of copies was given
- if ( !stringOnlyContains (copies, "0123456789") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'number of copies'!"));
- return;
- }
- if (fl_get_button(fd_form_print->do_unsorted))
- pageflag += lyxrc.print_copies_flag;
- else
- pageflag += lyxrc.print_collcopies_flag;
- pageflag += " " + copies + ' ' ;
- }
-
- string reverseflag;
- if (fl_get_button(fd_form_print->radio_order_reverse))
- reverseflag = lyxrc.print_reverse_flag + ' ';
-
- string orientationflag;
- if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- orientationflag = lyxrc.print_landscape_flag + ' ';
-
- string ps_file = fl_get_input(fd_form_print->input_file);
- string printer = strip(fl_get_input(fd_form_print->input_printer));
-
- string printerflag;
- if (lyxrc.print_adapt_output // printer name should be passed to dvips
- && ! printer.empty()) // a printer name has been given
- printerflag = lyxrc.print_to_printer + printer + ' ';
-
- string extraflags;
- if (!lyxrc.print_extra_options.empty())
- extraflags = lyxrc.print_extra_options + ' ';
-
- string command = lyxrc.print_command + ' '
- + printerflag + pageflag + reverseflag
- + orientationflag + extraflags;
-
- char real_papersize = buffer->params.papersize;
- if (real_papersize == BufferParams::PAPER_DEFAULT)
- real_papersize = lyxrc.default_papersize;
-
- string paper;
- switch (real_papersize) {
- case BufferParams::PAPER_USLETTER:
- paper = "letter";
- break;
- case BufferParams::PAPER_A3PAPER:
- paper = "a3";
- break;
- case BufferParams::PAPER_A4PAPER:
- paper = "a4";
- break;
- case BufferParams::PAPER_A5PAPER:
- paper = "a5";
- break;
- case BufferParams::PAPER_B5PAPER:
- paper = "b5";
- break;
- case BufferParams::PAPER_EXECUTIVEPAPER:
- paper = "foolscap";
- break;
- case BufferParams::PAPER_LEGALPAPER:
- paper = "legal";
- break;
- default: /* If nothing else fits, keep an empty value... */
- break;
- }
-
- if (buffer->params.use_geometry
- && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
- && !lyxrc.print_paper_dimension_flag.empty()
- && !buffer->params.paperwidth.empty()
- && !buffer->params.paperheight.empty()) {
- // using a custom papersize
- command += ' ';
- command += lyxrc.print_paper_dimension_flag + ' ';
- command += buffer->params.paperwidth + ',';
- command += buffer->params.paperheight + ' ';
- } else if (!lyxrc.print_paper_flag.empty()
- && !paper.empty()
- && (real_papersize != BufferParams::PAPER_USLETTER ||
- buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
- command += " " + lyxrc.print_paper_flag + " " + paper + " ";
- }
- if (fl_get_button(fd_form_print->radio_file))
- command += lyxrc.print_to_file
- + QuoteName(MakeAbsPath(ps_file, path));
- else if (!lyxrc.print_spool_command.empty())
- command += lyxrc.print_to_file
- + QuoteName(ps_file);
-
- // push directorypath, if necessary
- if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
- path = buffer->tmppath;
- }
- Path p(path);
-
- bool result;
- if (!lyxrc.print_spool_command.empty() &&
- !fl_get_button(fd_form_print->radio_file)) {
- string command2 = lyxrc.print_spool_command + ' ';
- if (!printer.empty())
- command2 += lyxrc.print_spool_printerprefix
- + printer;
- // First run dvips and, if succesful, then spool command
- if ((result = RunScript(buffer, true, command))) {
- result = RunScript(buffer, false, command2, ps_file);
- }
- } else
- result = RunScript(buffer, false, command);
-
- if (!result)
- WriteAlert(_("Error:"),
- _("Unable to print"),
- _("Check that your parameters are correct"));
-}
-
-
-extern "C" void PrintOKCB(FL_OBJECT * ob, long data)
-{
- PrintCancelCB(ob, data);
- PrintApplyCB(ob, data);
-}
-
-
void Figure()
{
if (fd_form_figure->form_figure->visible) {
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
if (fl_get_button(fd_form_figure->radio_inline)
- || current_view->text->cursor.par->table) {
+ || current_view->text->cursor.par()->table) {
InsetFig * new_inset = new InsetFig(100, 20, buffer);
current_view->insertInset(new_inset);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
}
current_view->hideCursor();
- current_view->update(-2);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
current_view->beforeChange();
- current_view->text->SetCursorParUndo();
+ current_view->text->SetCursorParUndo(current_view->buffer());
current_view->text->FreezeUndo();
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- if (current_view->text->cursor.par->Last()) {
- current_view->text->CursorLeft();
+ if (current_view->text->cursor.par()->Last()) {
+ current_view->text->CursorLeft(current_view);
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
// The standard layout should always be numer 0;
- current_view->text->SetLayout(0);
+ current_view->text->SetLayout(current_view, 0);
- if (current_view->text->cursor.par->footnoteflag ==
+ if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
current_view->text->
- SetParagraph(0, 0,
+ SetParagraph(current_view, 0, 0,
0, 0,
VSpace (0.3 * buffer->params.spacing.getValue(),
LyXLength::CM),
LyXLength::CM),
LYX_ALIGN_CENTER, string(), 0);
} else {
- current_view->text->SetParagraph(0, 0,
+ current_view->text->SetParagraph(current_view, 0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
0);
}
- current_view->update(-1);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
Inset * new_inset = new InsetFig(100, 100, buffer);
current_view->insertInset(new_inset);
new_inset->Edit(current_view, 0, 0, 0);
- current_view->update(0);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
current_view->text->UnFreezeUndo();
current_view->setState();
lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm);
lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
fontloader.update();
-
+
+ // Of course we should only to the resize and the textcahce.clear
+ // if values really changed...but not very important right now. (Lgb)
+
// All buffers will need resize
bufferlist.resize();
-
+ // We also need to empty the textcache so that
+ // the buffer will be formatted correctly after
+ // a zoom change.
+ textcache.clear();
+
current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
}
// Table of Contents
//
-struct TocList {
- int counter[6];
- bool appendix;
- TocList * next;
-};
-
-
-static TocList * toclist = 0;
+static vector<Buffer::TocItem> toclist;
extern "C" void TocSelectCB(FL_OBJECT * ob, long)
if (!current_view->available())
return;
- TocList * tmptoclist = toclist;
- int i = fl_get_browser(ob);
- for (int a = 1; a < i && tmptoclist->next; ++a) {
- tmptoclist = tmptoclist->next;
- }
-
- if (!tmptoclist)
- return;
-
-
- LyXParagraph * par = current_view->buffer()->paragraph;
- while (par && (par->GetFirstCounter(0) != tmptoclist->counter[0] ||
- par->GetFirstCounter(1) != tmptoclist->counter[1] ||
- par->GetFirstCounter(2) != tmptoclist->counter[2] ||
- par->GetFirstCounter(3) != tmptoclist->counter[3] ||
- par->GetFirstCounter(4) != tmptoclist->counter[4] ||
- par->GetFirstCounter(5) != tmptoclist->counter[5] ||
- par->appendix != tmptoclist->appendix)) {
- par = par->LastPhysicalPar()->Next();
- }
-
- if (par) {
- current_view->beforeChange();
- current_view->text->SetCursor(par, 0);
+ TocUpdateCB(0, 0);
+ unsigned int choice = fl_get_browser(ob);
+ if (0 < choice && choice - 1 < toclist.size()) {
+ current_view->beforeChange();
+ current_view->text->SetCursor(current_view, toclist[choice-1].par, 0);
current_view->text->sel_cursor =
current_view->text->cursor;
- current_view->update(0);
- }
- else {
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
+ } else {
WriteAlert(_("Error"),
_("Couldn't find this label"),
_("in current document."));
}
-
}
}
-extern "C" void TocUpdateCB(FL_OBJECT *, long)
+extern "C"
+void TocUpdateCB(FL_OBJECT *, long)
{
- static LyXParagraph * stapar = 0;
- TocList * tmptoclist = 0;
-
- /* deleted the toclist */
- if (toclist){
- while (toclist){
- tmptoclist = toclist->next;
- delete toclist;
- toclist = tmptoclist;
- }
- }
- toclist = 0;
- tmptoclist = toclist;
-
-
- fl_clear_browser(fd_form_toc->browser_toc);
if (!current_view->available()) {
+ toclist.clear();
+ fl_clear_browser(fd_form_toc->browser_toc);
fl_add_browser_line(fd_form_toc->browser_toc,
_("*** No Document ***"));
return;
}
- fl_hide_object(fd_form_toc->browser_toc);
- /* get the table of contents */
- LyXParagraph * par = current_view->buffer()->paragraph;
- char labeltype;
- char * line = new char[200];
- int pos = 0;
- unsigned char c;
- int topline = 0;
-
- if (stapar == par)
- topline = fl_get_browser_topline(fd_form_toc->browser_toc);
- stapar = par;
-
- while (par) {
- labeltype = textclasslist.Style(current_view->buffer()->params.textclass,
- par->GetLayout()).labeltype;
-
- if (labeltype >= LABEL_COUNTER_CHAPTER
- && labeltype <= LABEL_COUNTER_CHAPTER +
- current_view->buffer()->params.tocdepth) {
- /* insert this into the table of contents */
- /* first indent a little bit */
-
- for (pos = 0;
- pos < (labeltype -
- textclasslist.TextClass(current_view->buffer()->
- params.textclass).maxcounter()) * 4 + 2;
- ++pos)
- line[pos] = ' ';
-
- // Then the labestring
- if (!par->labelstring.empty()) {
- string::size_type i = 0;
- while (pos < 199 && i < par->labelstring.length()) {
- line[pos] = par->labelstring[i];
- ++i;
- ++pos;
- }
- }
-
- line[pos] = ' ';
- ++pos;
-
- /* now the contents */
- LyXParagraph::size_type i = 0;
- while (pos < 199 && i < par->size()) {
- c = par->GetChar(i);
- if (isprint(c) || c >= 128) {
- line[pos] = c;
- ++pos;
- }
- ++i;
- }
- line[pos] = '\0';
- fl_add_browser_line(fd_form_toc->browser_toc, line);
-
- /* make a toclist entry */
- if (!tmptoclist){
- tmptoclist = new TocList;
- toclist = tmptoclist;
- } else {
- tmptoclist->next = new TocList;
- tmptoclist = tmptoclist->next;
- }
-
- tmptoclist->next = 0;
- int a = 0;
- for (a = 0; a < 6; ++a) {
- tmptoclist->counter[a] = par->GetFirstCounter(a);
- }
- tmptoclist->appendix = par->appendix;
+
+ vector<vector<Buffer::TocItem> > tmp =
+ current_view->buffer()->getTocList();
+ int type = fl_get_choice(fd_form_toc->toctype)-1;
+ //if (toclist == tmp[type])
+ // return;
+ if (toclist.size() == tmp[type].size()) {
+ // Check if all elements are the same.
+ unsigned int i = 0;
+ for (; i < toclist.size(); ++i) {
+ if (toclist[i] != tmp[type][i])
+ break;
}
- par = par->LastPhysicalPar()->Next();
-
+ if (i >= toclist.size()) return;
}
- delete[] line;
+
+ toclist = tmp[type];
+
+ static Buffer * buffer = 0;
+ int topline = 0;
+ int line = 0;
+ if (buffer == current_view->buffer()) {
+ topline = fl_get_browser_topline(fd_form_toc->browser_toc);
+ line = fl_get_browser(fd_form_toc->browser_toc);
+ } else
+ buffer = current_view->buffer();
+
+ fl_clear_browser(fd_form_toc->browser_toc);
+ fl_hide_object(fd_form_toc->browser_toc);
+
+ for (vector<Buffer::TocItem>::const_iterator it = toclist.begin();
+ it != toclist.end(); ++it)
+ fl_add_browser_line(fd_form_toc->browser_toc,
+ (string(4*(*it).depth,' ')+
+ (*it).str).c_str());
+
fl_set_browser_topline(fd_form_toc->browser_toc, topline);
+ fl_select_browser_line(fd_form_toc->browser_toc, line);
fl_show_object(fd_form_toc->browser_toc);
}
if (s.empty())
return;
- if (data == 2) {
+ if (data == 5) {
current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
+ if (!current_view->NoSavedPositions()) {
+ fl_activate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_BLACK);
+ }
return;
- }
-
- string t;
- if (data == 0)
- t += "\\ref";
- else
- t += "\\pageref";
+ } else if (data >= 6) {
+ current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFBACK);
+ if (current_view->NoSavedPositions()) {
+ fl_deactivate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE);
+ }
+ return;
+ }
- if(current_view->buffer()->isSGML())
+ static string const commands[5]
+ = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
+ "\\prettyref"};
+ string t = commands[data];
+
+ if (current_view->buffer()->isSGML())
t += "[" + u + "]" + "{" + s + "}";
else
t += "{" + s + "}";
string currentstr = btmp ? btmp : "";
fl_clear_browser(brow);
+ fl_hide_object(brow);
- string refs = current_view->buffer()->getReferenceList('\n');
- int topline = 1;
+ vector<string> refs = current_view->buffer()->getLabelList();
+ if (fl_get_button(fd_form_ref->sort))
+ sort(refs.begin(),refs.end());
+ for (vector<string>::const_iterator it = refs.begin();
+ it != refs.end(); ++it)
+ fl_add_browser_line(brow, (*it).c_str());
- fl_addto_browser_chars(brow, refs.c_str());
+ int topline = 1;
int total_lines = fl_get_browser_maxline(brow);
for (int i = 1; i <= total_lines ; ++i) {
if (fl_get_browser_line(brow, i) == currentstr) {
}
fl_set_browser_topline(brow, topline);
- if (!fl_get_browser_maxline(brow)) {
+ bool empty = refs.empty();
+ bool sgml = current_view->buffer()->isSGML();
+ bool readonly = current_view->buffer()->isReadonly();
+
+ if (current_view->NoSavedPositions()) {
+ fl_deactivate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE);
+ } else {
+ fl_activate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_BLACK);
+ }
+
+ if (empty) {
fl_add_browser_line(brow,
_("*** No labels found in document ***"));
fl_deactivate_object(brow);
+ fl_deactivate_object(fd_form_ref->gotoref);
+ fl_set_object_lcol(fd_form_ref->gotoref, FL_INACTIVE);
} else {
fl_select_browser_line(brow, topline);
fl_activate_object(brow);
+ fl_activate_object(fd_form_ref->gotoref);
+ fl_set_object_lcol(fd_form_ref->gotoref, FL_BLACK);
}
- if (current_view->buffer()->isReadonly()) {
- // would be better to de/activate insert buttons
- // but that's more work... besides this works. ARRae
- fl_hide_form(fd_form_ref->form_ref);
+
+ if (empty || readonly) {
+ fl_deactivate_object(fd_form_ref->ref);
+ fl_set_object_lcol(fd_form_ref->ref, FL_INACTIVE);
+ fl_deactivate_object(fd_form_ref->pageref);
+ fl_set_object_lcol(fd_form_ref->pageref, FL_INACTIVE);
+ } else {
+ fl_activate_object(fd_form_ref->ref);
+ fl_set_object_lcol(fd_form_ref->ref, FL_BLACK);
+ fl_activate_object(fd_form_ref->pageref);
+ fl_set_object_lcol(fd_form_ref->pageref, FL_BLACK);
}
- if (!current_view->buffer()->isSGML()) {
- fl_deactivate_object(fd_form_ref->ref_name);
- fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
+
+ if (empty || readonly || sgml) {
+ fl_deactivate_object(fd_form_ref->vref);
+ fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE);
+ fl_deactivate_object(fd_form_ref->vpageref);
+ fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE);
+ fl_deactivate_object(fd_form_ref->prettyref);
+ fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE);
+ } else {
+ fl_activate_object(fd_form_ref->vref);
+ fl_set_object_lcol(fd_form_ref->vref, FL_BLACK);
+ fl_activate_object(fd_form_ref->vpageref);
+ fl_set_object_lcol(fd_form_ref->vpageref, FL_BLACK);
+ fl_activate_object(fd_form_ref->prettyref);
+ fl_set_object_lcol(fd_form_ref->prettyref, FL_BLACK);
}
- else {
+
+ if (sgml) {
fl_activate_object(fd_form_ref->ref_name);
fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
+ } else {
+ fl_deactivate_object(fd_form_ref->ref_name);
+ fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
}
+
+ fl_show_object(brow);
}