+2000-09-18 Juergen Vigna <jug@sad.it>
+
+ * src/insets/insettext.C (LocalDispatch): fixed Backspace/Delete
+ problems with selection. Inserted new LFUN_PASTESELECTION.
+ (InsetButtonPress): inserted handling of middle mouse-button paste.
+
+ * src/spellchecker.C: changed word to word.c_str().
+
+2000-09-16 Kayvan A. Sylvan <kayvan@sylvan.com>
+
+ * src/Makefile.am: Add sources to lyx_SOURCES so they will be
+ included in the ``make dist'' tarball.
+
+2000-09-15 Juergen Vigna <jug@sad.it>
+
+ * src/CutAndPaste.C (cutSelection): small fix return the right
+ end position after cut inside one paragraph only.
+
+ * src/insets/insettext.C (resizeLyXText): only reset the cursor if
+ we are locked as otherwise we don't have a valid cursor position!
+
+ * src/insets/figinset.C (draw): small bugfix but why is this needed???
+
+2000-09-19 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/frontends/kde/FormRef.C: added using directive.
+ * src/frontends/kde/FormToc.C: ditto
+
+ * src/frontends/kde/formtocdialog.h: changed endl to std::endl.
+
+ * src/frontends/kde/FormRef.h: removed trailing comma from enums.
+
+
+2000-09-19 Marko Vendelin <markov@ioc.ee>
+
+ * src/frontends/gnome/Menubar_pimpl.C
+ * src/frontends/gnome/Menubar_pimpl.h: Gnome menus show now
+ Toc, ViewFormats, UpdateFormats, and ExportFormats.
+
+ * src/frontends/gnome/mainapp.C
+ * src/frontends/gnome/mainapp.h: support for menu update used
+ by Toc menu.
+
+ * src/frontends/gnome/mainapp.C
+ * src/frontends/gnome/mainapp.h: support for "action" area in the
+ main window. This area is used by small simple dialogs, such as
+ FormUrl.
+
+ * src/frontends/gnome/FormIndex.C
+ * src/frontends/gnome/FormIndex.h
+ * src/frontends/gnome/FormUrl.C
+ * src/frontends/gnome/FormUrl.h: rewrite to use main window action
+ area
+
+ * src/frontends/gnome/FormCitation.C
+ * src/frontends/gnome/FormCitation.h: rewrite to use main window
+ action area. Only "Insert new citation" is implemented.
+
+
+
2000-09-19 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/buffer.C (Dispatch): fix call to Dispatch
src/frontends/gnome/FormCitation.C
src/frontends/gnome/FormPrint.C
src/frontends/gnome/FormToc.C
+src/frontends/kde/dlg/FormIndex.C
+src/frontends/kde/dlg/formindexdialog.C
src/frontends/kde/FormCitation.C
src/frontends/kde/formcitationdialog.C
src/frontends/kde/FormCopyright.C
#endif
buf->InsertFromMinibuffer(buf->Last());
}
+ end = start-1;
} else {
// more than one paragraph
(*endpar)->BreakParagraphConservative(current_view->buffer()->params,
spellchecker.C \
spellchecker.h \
stl_string_fwd.h \
+ table.h \
+ table.C \
tabular.C \
tabular.h \
tex-accent.C \
#include "support/filetools.h"
#include "support/LRegex.h"
-extern "C" {
-#include "diainsertcitation_interface.h"
-#include "support.h"
-}
-
#include <gtk--/scrolledwindow.h>
#include <gnome--/pixmap.h>
+#include <gtk--/label.h>
+#include <gtk--/box.h>
+#include <gtk--/buttonbox.h>
+#include <gnome--/entry.h>
+#include <gnome--/stock.h>
+#include <gtk--/separator.h>
+#include <libgnome/gnome-config.h>
+
+// temporary solution for LyXView
+#include "mainapp.h"
+extern GLyxAppWin * mainAppWin;
using std::vector;
using std::pair;
using SigC::bind;
#endif
-// gnome configuration file keys
-#define LOCAL_CONFIGURE_PREFIX "FormCitation"
-#define CONF_DIALOG_WIDTH "width"
-#define CONF_DIALOG_WIDTH_DEFAULT "=550"
+// configuration keys
+static string const LOCAL_CONFIGURE_PREFIX("FormCitation");
+
+static string const CONF_DIALOG_WIDTH("width");
+static string const CONF_DIALOG_WIDTH_DEFAULT("=550");
-#define CONF_DIALOG_HEIGTH "heigth"
-#define CONF_DIALOG_HEIGTH_DEFAULT "=550"
+static string const CONF_DIALOG_HEIGTH("heigth");
+static string const CONF_DIALOG_HEIGTH_DEFAULT("=550");
-#define CONF_PANE_INFO "paneinfo"
-#define CONF_PANE_INFO_DEFAULT "=300"
+static string const CONF_PANE_INFO("paneinfo");
+static string const CONF_PANE_INFO_DEFAULT("=300");
-#define CONF_PANE_KEY "panekey"
-#define CONF_PANE_KEY_DEFAULT "=225"
+static string const CONF_PANE_KEY("panekey");
+static string const CONF_PANE_KEY_DEFAULT("=225");
-#define CONF_COLUMN "column"
-#define CONF_COLUMN_DEFAULT "=50"
+static string const CONF_COLUMN("column");
+static string const CONF_COLUMN_DEFAULT("=50");
-#define CONF_REGEXP "regexp"
-#define CONF_REGEXP_DEFAULT "=0"
+static string const CONF_REGEXP("regexp");
+static string const CONF_REGEXP_DEFAULT("=0");
+static string const CONF_SEARCH("FormCitation_search");
+static string const CONF_TEXTAFTER("FormCitation_textafter");
FormCitation::FormCitation(LyXView * lv, Dialogs * d)
: lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL)
inset_ = inset;
ih_ = inset_->hide.connect(slot(this, &FormCitation::hide));
+
+ u_ = d_->updateBufferDependent.connect(slot(this, &FormCitation::update));
+ h_ = d_->hideBufferDependent.connect(slot(this, &FormCitation::hide));
params = inset->params();
- show();
+ //showStageEdit();
}
{
if( dialog_!=NULL ) return;
+ u_ = d_->updateBufferDependent.connect(slot(this, &FormCitation::update));
+ h_ = d_->hideBufferDependent.connect(slot(this, &FormCitation::hide));
+
params.setFromString( arg );
- show();
+ showStageSearch();
}
+
static
void parseBibTeX(string data,
string const & findkey,
}
}
-void FormCitation::show()
+void FormCitation::showStageSearch()
+{
+ if (!dialog_)
+ {
+ using namespace Gtk::Box_Helpers;
+
+ Gtk::Box * mbox = manage( new Gtk::HBox() );
+ Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() );
+ Gtk::Separator * sep = manage( new Gtk::VSeparator() );
+
+ search_text_ = manage( new Gnome::Entry() );
+
+ button_regexp_ = manage( new Gtk::CheckButton(N_("Use Regular Expression")) );
+
+ b_ok = manage( new Gtk::Button(N_("Search")) );
+ b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) );
+
+ // set up spacing
+ mbox->set_spacing(4);
+ bbox->set_spacing(4);
+
+ search_text_->set_history_id(CONF_SEARCH);
+ search_text_->set_max_saved(10);
+ search_text_->load_history();
+ search_text_->set_use_arrows_always(true);
+
+ // packing
+ bbox->children().push_back(Element(*b_ok, false, false));
+ bbox->children().push_back(Element(*b_cancel, false, false));
+
+ mbox->children().push_back(Element(*search_text_, true, true));
+ mbox->children().push_back(Element(*button_regexp_, false, false));
+ mbox->children().push_back(Element(*sep, false, false));
+ mbox->children().push_back(Element(*bbox, false, false));
+
+ // packing dialog to main window
+ dialog_ = mbox;
+ mainAppWin->add_action(*dialog_, N_(" Insert Citation: Enter keyword(s) or regular expression "));
+
+ // setting focus
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET(search_text_->get_entry()->gtkobj()), GTK_CAN_DEFAULT);
+ gtk_widget_grab_focus (GTK_WIDGET(search_text_->get_entry()->gtkobj()));
+ gtk_widget_grab_default (GTK_WIDGET(search_text_->get_entry()->gtkobj()));
+
+ // restoring regexp setting
+ string path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX;
+ string w;
+ w = path + "/" + CONF_REGEXP + CONF_REGEXP_DEFAULT;
+ button_regexp_->set_active( (gnome_config_get_int(w.c_str()) > 0) );
+
+ // connecting signals
+ b_ok->clicked.connect(slot(this, &FormCitation::moveFromSearchToSelect));
+ search_text_->get_entry()->activate.connect(slot(this, &FormCitation::moveFromSearchToSelect));
+
+ b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action));
+
+ dialog_->destroy.connect(slot(this, &FormCitation::free));
+ }
+}
+
+void FormCitation::moveFromSearchToSelect()
+{
+ search_string_ = search_text_->get_entry()->get_text();
+ use_regexp_ = button_regexp_->get_active();
+
+ // saving configuration
+ search_text_->save_history();
+
+ string path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX;
+ string w;
+ w = path + "/" + CONF_REGEXP;
+ gnome_config_set_int(w.c_str(), button_regexp_->get_active());
+ gnome_config_sync();
+
+ // moves to stage "select"
+ dialog_ = NULL;
+ mainAppWin->remove_action();
+ showStageSelect();
+}
+
+void FormCitation::showStageSelect()
+{
+ if (!dialog_)
+ {
+ using namespace Gtk::Box_Helpers;
+
+ Gtk::Box * mbox = manage( new Gtk::VBox() );
+ Gtk::Box * tbox = manage( new Gtk::HBox() );
+ Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() );
+ Gtk::Separator * sep = manage( new Gtk::HSeparator() );
+ Gtk::ScrolledWindow * sw = manage( new Gtk::ScrolledWindow() );
+
+ info_ = manage( new Gnome::Less() );
+ paned_info_ = manage( new Gtk::HPaned() );
+ text_after_ = manage( new Gnome::Entry() );
+
+ b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) );
+ b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) );
+
+ // setup text_after_
+ text_after_->set_history_id(CONF_TEXTAFTER);
+ text_after_->set_max_saved(10);
+ text_after_->load_history();
+ text_after_->set_use_arrows_always(true);
+
+ sw->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ // constructing CList
+ vector<string> colnames;
+ colnames.push_back("INVISIBLE");
+ colnames.push_back(N_("Key"));
+ colnames.push_back(N_("Author(s)"));
+ colnames.push_back(N_("Title"));
+ colnames.push_back(N_("Year"));
+ colnames.push_back(N_("Journal"));
+ clist_bib_ = manage( new Gtk::CList(colnames) );
+ clist_bib_->column(0).set_visiblity(false);
+
+ bbox->set_layout(GTK_BUTTONBOX_END);
+
+ // set up spacing
+ mbox->set_spacing(4);
+ bbox->set_spacing(4);
+ tbox->set_spacing(4);
+
+ // packing widgets
+ sw->add(*clist_bib_);
+ paned_info_->add1(*sw);
+ paned_info_->add2(*info_);
+
+ bbox->children().push_back(Element(*b_ok, false, false));
+ bbox->children().push_back(Element(*b_cancel, false, false));
+
+ tbox->children().push_back(Element(*manage(new Gtk::Label(N_("Text after"))), false, false));
+ tbox->children().push_back(Element(*text_after_, true, true));
+ tbox->children().push_back(Element(*manage(new Gtk::VSeparator()), false, false));
+ tbox->children().push_back(Element(*bbox, false, false));
+
+ mbox->children().push_back(Element(*paned_info_,true,true));
+ mbox->children().push_back(Element(*sep, false, false));
+ mbox->children().push_back(Element(*tbox, false, false));
+
+ // packing dialog to main window
+ dialog_ = mbox;
+ mainAppWin->add_action(*dialog_, N_(" Insert Citation: Select citation "), true);
+
+ // setting focus
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_ok->gtkobj()), GTK_CAN_DEFAULT);
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_cancel->gtkobj()), GTK_CAN_DEFAULT);
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET(clist_bib_->gtkobj()), GTK_CAN_DEFAULT);
+ gtk_widget_grab_focus (GTK_WIDGET(clist_bib_->gtkobj()));
+ gtk_widget_grab_default (GTK_WIDGET(b_ok->gtkobj()));
+
+ // setting sizes of the widgets
+ string path;
+ string w, h;
+ path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX;
+
+ w = path + "/" + CONF_PANE_INFO + CONF_PANE_INFO_DEFAULT;
+ paned_info_->set_position( gnome_config_get_int(w.c_str()) );
+
+ int i, sz;
+ for (i = 0, sz = clist_bib_->columns().size(); i < sz; ++i)
+ {
+ w = path + "/" + CONF_COLUMN + "_" + tostr(i) + CONF_COLUMN_DEFAULT;
+ clist_bib_->column(i).set_width( gnome_config_get_int(w.c_str()) );
+ }
+
+ // connecting signals
+ b_ok->clicked.connect(slot(this, &FormCitation::applySelect));
+ b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action));
+
+ dialog_->destroy.connect(slot(this, &FormCitation::free));
+
+ clist_bib_->click_column.connect(slot(this, &FormCitation::sortBibList));
+ clist_bib_->select_row.connect(bind(slot(this, &FormCitation::selection_toggled),
+ true, false));
+ clist_bib_->unselect_row.connect(bind(slot(this, &FormCitation::selection_toggled),
+ false, false));
+ // retrieving data
+ vector<pair<string,string> > blist = lv_->buffer()->getBibkeyList();
+
+ for ( i = 0, sz = blist.size(); i < sz; ++i )
+ {
+ bibkeys.push_back(blist[i].first);
+ bibkeysInfo.push_back(blist[i].second);
+ }
+
+ blist.clear();
+
+ // updating list
+ search();
+ }
+}
+
+/*void FormCitation::show()
{
if (!dialog_)
{
dialog_win.raise();
}
}
+*/
void FormCitation::addItemToBibList(int i)
{
void FormCitation::update()
{
+ return;
+
bibkeys.clear();
bibkeysInfo.clear();
{
info_->show_string("");
}
- updateButtons();
}
void FormCitation::removeCitation()
void FormCitation::hide()
{
- if (dialog_!=NULL) dialog_->destroy();
+ if (dialog_!=NULL) mainAppWin->remove_action();
}
void FormCitation::free()
if (dialog_!=NULL)
{
// storing configuration
- string path;
- string w, h;
- path = PACKAGE "/" LOCAL_CONFIGURE_PREFIX;
- w = path + "/" + CONF_DIALOG_WIDTH;
- h = path + "/" + CONF_DIALOG_HEIGTH;
+// string path;
+// string w, h;
+// path = PACKAGE "/" LOCAL_CONFIGURE_PREFIX;
+// w = path + "/" + CONF_DIALOG_WIDTH;
+// h = path + "/" + CONF_DIALOG_HEIGTH;
- gnome_config_set_int(w.c_str(), dialog_->width());
- gnome_config_set_int(h.c_str(), dialog_->height());
+// gnome_config_set_int(w.c_str(), dialog_->width());
+// gnome_config_set_int(h.c_str(), dialog_->height());
- w = path + "/" + CONF_PANE_INFO;
- gnome_config_set_int(w.c_str(), paned_key_->height());
+// w = path + "/" + CONF_PANE_INFO;
+// gnome_config_set_int(w.c_str(), paned_key_->height());
- w = path + "/" + CONF_PANE_KEY;
- gnome_config_set_int(w.c_str(), box_keys_->width());
+// w = path + "/" + CONF_PANE_KEY;
+// gnome_config_set_int(w.c_str(), box_keys_->width());
- int i, sz;
- for (i = 0, sz = clist_bib_->columns().size(); i < sz; ++i)
- {
- w = path + "/" + CONF_COLUMN + "_" + tostr(i);
- gnome_config_set_int(w.c_str(), clist_bib_->get_column_width(i));
- }
+// int i, sz;
+// for (i = 0, sz = clist_bib_->columns().size(); i < sz; ++i)
+// {
+// w = path + "/" + CONF_COLUMN + "_" + tostr(i);
+// gnome_config_set_int(w.c_str(), clist_bib_->get_column_width(i));
+// }
- w = path + "/" + CONF_REGEXP;
- gnome_config_set_int(w.c_str(), button_regexp_->get_active());
+// w = path + "/" + CONF_REGEXP;
+// gnome_config_set_int(w.c_str(), button_regexp_->get_active());
- gnome_config_sync();
+// gnome_config_sync();
// cleaning up
dialog_ = NULL;
}
}
+void FormCitation::applySelect()
+{
+ if( lv_->buffer()->isReadonly() ) return;
+
+ string contents;
+ int i, sz;
+
+ contents = frontStrip( strip(params.getContents()) );
+ if (!contents.empty()) contents += ", ";
+
+ sz = clist_bib_->selection().size();
+ for (i=0; i < sz; ++i)
+ {
+ if (i > 0) contents += ", ";
+ contents += clist_bib_->selection().operator[](i).operator[](1).get_text();
+ }
+
+ params.setContents( contents );
+ params.setOptions( text_after_->get_entry()->get_text() );
+
+ if( inset_ != 0 )
+ {
+ // Only update if contents have changed
+ if( params != inset_->params() )
+ {
+ inset_->setParams( params );
+ lv_->view()->updateInset( inset_, true );
+ }
+ }
+ else
+ {
+ lv_->getLyXFunc()->Dispatch( LFUN_CITATION_INSERT,
+ params.getAsString().c_str() );
+ }
+
+ // save config
+ text_after_->save_history();
+
+ string path;
+ string w, h;
+ path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX;
+
+ w = path + "/" + CONF_PANE_INFO;
+ gnome_config_set_int(w.c_str(), paned_info_->width() - info_->width());
+
+ for (i = 0, sz = clist_bib_->columns().size(); i < sz; ++i)
+ {
+ w = path + "/" + CONF_COLUMN + "_" + tostr(i);
+ gnome_config_set_int(w.c_str(), clist_bib_->get_column_width(i));
+ }
+
+ gnome_config_sync();
+
+ // close dialog
+ hide();
+}
+
void FormCitation::apply()
{
if( lv_->buffer()->isReadonly() ) return;
void FormCitation::search()
{
- if (button_regexp_->get_active()) searchReg();
+ if (use_regexp_) searchReg();
else searchSimple();
}
// looking for entries which match regexp
void FormCitation::searchReg()
{
- string tmp, rexptxt( search_text_->get_entry()->get_text() );
+ string tmp, rexptxt( search_string_ );
rexptxt = frontStrip( strip( rexptxt ) );
LRegex reg(rexptxt);
clist_bib_->sort();
clist_bib_->thaw();
- // clist_bib_: done
- updateButtons();
}
// looking for entries which contain all the words specified in search_text entry
void FormCitation::searchSimple()
{
vector<string> searchwords;
- string tmp, stext( search_text_->get_entry()->get_text() );
+ string tmp, stext( search_string_ );
stext = frontStrip( strip( stext ) );
stext = frontStrip( split(stext, tmp, ' ') );
while( !tmp.empty() )
clist_bib_->sort();
clist_bib_->thaw();
- // clist_bib_: done
- updateButtons();
}
#include "support/utility.hpp"
#include "insets/insetcommand.h"
-#include <gtk--/widget.h>
+#include <gtk--/container.h>
#include <gtk--/clist.h>
#include <gnome--/entry.h>
#include <gnome--/less.h>
virtual void update();
/// Apply from dialog (modify or create inset)
virtual void apply();
+ /// Apply from dialog (modify or create inset)
+ virtual void applySelect();
/// Explicitly free the dialog.
void free();
- /// Create the dialog if necessary, update it and display it.
- void show();
/// Hide the dialog.
void hide();
-
+ /// Create the dialog if necessary, update it and display it. Not used in this dialog
+ void show() { }
+ /// Ask user for regexp or keyword(s)
+ void showStageSearch();
+ /// Ask user to select the citation in the list
+ void showStageSelect();
+ /// moves from Search to Select "stage"
+ void moveFromSearchToSelect();
+
/// sort biblist
void sortBibList(gint);
/// update state of the buttons
Connection ih_;
/// Real GUI implementation.
- Gtk::Widget * dialog_;
+ Gtk::Container * dialog_;
Gtk::Button * b_ok;
Gtk::Button * b_cancel;
+ Gnome::Entry * search_text_;
+ string search_string_;
+ bool use_regexp_;
+
Gnome::Less * info_;
Gnome::Entry * text_after_;
- Gnome::Entry * search_text_;
-
Gtk::Button * button_select_;
Gtk::Button * button_unselect_;
Gtk::Button * button_up_;
Gtk::Button * button_down_;
- Gtk::Button * button_search_;
Gtk::CheckButton * button_regexp_;
Gtk::CList * clist_selected_;
#include "buffer.h"
#include "lyxfunc.h"
-extern "C" {
-#include "diainsertindex_interface.h"
-#include "support.h"
-}
-
-#include <gtk--/base.h>
-
#include "gettext.h"
#include "Dialogs.h"
#include "FormIndex.h"
#include "form_index.h"
#include "lyxfunc.h"
+#include <gtk--/label.h>
+#include <gtk--/box.h>
+#include <gtk--/buttonbox.h>
+#include <gnome--/entry.h>
+#include <gnome--/stock.h>
+#include <gtk--/separator.h>
+
+// temporary solution for LyXView
+#include "mainapp.h"
+extern GLyxAppWin * mainAppWin;
+
+// configuration keys
+static string const CONF_ENTRY("FormIndex_entry");
+
FormIndex::FormIndex(LyXView * lv, Dialogs * d)
: lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL)
{
{
if (!dialog_)
{
- GtkWidget * pd = create_DiaInsertIndex();
+ using namespace Gtk::Box_Helpers;
+
+ Gtk::Label * label = manage( new Gtk::Label(N_("Keyword")) );
+ Gtk::Box * mbox = manage( new Gtk::HBox() );
+ Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() );
+ Gtk::Separator * sep = manage( new Gtk::VSeparator() );
- dialog_ = Gtk::wrap(pd);
- keyword_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "keyword") ) );
+ keyword_ = manage( new Gnome::Entry() );
+
+ b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) );
+ b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) );
+
+ // set up spacing
+ mbox->set_spacing(2);
+ bbox->set_spacing(4);
+
+ keyword_->set_history_id(CONF_ENTRY);
+ keyword_->set_max_saved(10);
+ keyword_->load_history();
+ keyword_->set_use_arrows_always(true);
- b_ok = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_ok") ) );
- b_cancel = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_cancel") ) );
+ // packing
+ bbox->children().push_back(Element(*b_ok, false, false));
+ bbox->children().push_back(Element(*b_cancel, false, false));
+
+ mbox->children().push_back(Element(*label, false, false));
+ mbox->children().push_back(Element(*keyword_, true, true));
+ mbox->children().push_back(Element(*sep, false, false));
+ mbox->children().push_back(Element(*bbox, false, false));
+
+ // packing dialog to main window
+ dialog_ = mbox;
+ mainAppWin->add_action(*dialog_, N_(" Index "));
+ // setting focus
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET(keyword_->get_entry()->gtkobj()), GTK_CAN_DEFAULT);
+ gtk_widget_grab_focus (GTK_WIDGET(keyword_->get_entry()->gtkobj()));
+ gtk_widget_grab_default (GTK_WIDGET(keyword_->get_entry()->gtkobj()));
+
+ // connecting signals
b_ok->clicked.connect(slot(this, &FormIndex::apply));
- b_ok->clicked.connect(dialog_->destroy.slot());
- b_cancel->clicked.connect(dialog_->destroy.slot());
+ keyword_->get_entry()->activate.connect(slot(this, &FormIndex::apply));
+
+ b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action));
+
dialog_->destroy.connect(slot(this, &FormIndex::free));
u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::update));
h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide));
- if (!dialog_->is_visible()) dialog_->show_all();
-
update(); // make sure its up-to-date
}
- else
- {
- Gdk_Window dialog_win(dialog_->get_window());
- dialog_win.raise();
- }
}
void FormIndex::update()
void FormIndex::hide()
{
- if (dialog_!=NULL) dialog_->destroy();
+ if (dialog_!=NULL) mainAppWin->remove_action();
}
void FormIndex::free()
lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT,
params.getAsString().c_str() );
}
+
+ // save history
+ keyword_->save_history();
+
+ // hide the dialog
+ hide();
}
+
#include "support/utility.hpp"
#include "insets/insetcommand.h"
-#include <gtk--/widget.h>
+#include <gtk--/container.h>
#include <gnome--/entry.h>
#include <gtk--/label.h>
Connection ih_;
/// Real GUI implementation.
- Gtk::Widget * dialog_;
+ Gtk::Container * dialog_;
Gnome::Entry * keyword_;
Gtk::Button * b_ok;
Gtk::Button * b_cancel;
#include "buffer.h"
#include "lyxfunc.h"
-extern "C" {
-#include "diainserturl_interface.h"
-#include "support.h"
-}
-
+#include <gtk--/label.h>
+#include <gtk--/table.h>
+#include <gtk--/box.h>
+#include <gtk--/buttonbox.h>
#include <gtk--/base.h>
+#include <gtk--/separator.h>
+
+// temporary solution for LyXView
+#include "mainapp.h"
+extern GLyxAppWin * mainAppWin;
+
+// configuration keys
+static string const CONF_ENTRY_URL("FormUrl_url");
+static string const CONF_ENTRY_NAME("FormUrl_name");
FormUrl::FormUrl(LyXView * lv, Dialogs * d)
: lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL)
{
if (!dialog_)
{
- GtkWidget * pd = create_DiaInsertUrl();
+ using namespace Gtk::Box_Helpers;
+
+ Gtk::Label * label;
+ Gtk::Table * table = manage( new Gtk::Table(2, 2, FALSE) );
+ Gtk::Box * mbox = manage( new Gtk::HBox() );
+ Gtk::ButtonBox * bbox = manage( new Gtk::VButtonBox() );
+ Gtk::Separator * sep = manage( new Gtk::VSeparator() );
- dialog_ = Gtk::wrap(pd);
- url_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "url") ) );
- name_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "name") ) );
- html_type_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "html_type") ) );
+ url_ = manage( new Gnome::Entry() );
+ name_ = manage( new Gnome::Entry() );
+ html_type_ = manage( new Gtk::CheckButton(N_("HTML type")) );
+
+ b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) );
+ b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) );
+
+ // set up spacing
+ table->set_row_spacings(2);
+ table->set_col_spacings(2);
+ mbox->set_spacing(2);
+ bbox->set_spacing(4);
+
+ // configure entries
+ url_->set_history_id(CONF_ENTRY_URL);
+ url_->set_max_saved(10);
+ url_->load_history();
+ url_->set_use_arrows_always(true);
+
+ name_->set_history_id(CONF_ENTRY_NAME);
+ name_->set_max_saved(10);
+ name_->load_history();
+ name_->set_use_arrows_always(true);
+
+ // pack widgets
+ bbox->children().push_back(Element(*b_ok, false, false));
+ bbox->children().push_back(Element(*b_cancel, false, false));
+
+ label = manage( new Gtk::Label(N_("URL")) );
+ table->attach( *label, 0, 1, 0, 1, 0, 0 );
+ label = manage( new Gtk::Label(N_("Name")) );
+ table->attach( *label, 0, 1, 1, 2, 0, 0 );
+ table->attach( *url_, 1, 2, 0, 1 );
+ table->attach( *name_, 1, 2, 1, 2 );
+
+ mbox->children().push_back(Element(*table));
+ mbox->children().push_back(Element(*html_type_, false, false));
+ mbox->children().push_back(Element(*sep, false, false));
+ mbox->children().push_back(Element(*bbox, false, false));
- b_ok = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_ok") ) );
- b_cancel = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_cancel") ) );
+ // packing dialog to main window
+ dialog_ = mbox;
+ mainAppWin->add_action(*dialog_, N_(" URL "));
+ // setting focus
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET(url_->get_entry()->gtkobj()), GTK_CAN_DEFAULT);
+ gtk_widget_grab_focus (GTK_WIDGET(url_->get_entry()->gtkobj()));
+ gtk_widget_grab_default (GTK_WIDGET(url_->get_entry()->gtkobj()));
+
+ // connecting signals
b_ok->clicked.connect(slot(this, &FormUrl::apply));
- b_ok->clicked.connect(dialog_->destroy.slot());
- b_cancel->clicked.connect(dialog_->destroy.slot());
+ name_->get_entry()->activate.connect(slot(this, &FormUrl::apply));
+
+ b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action));
+
dialog_->destroy.connect(slot(this, &FormUrl::free));
u_ = d_->updateBufferDependent.connect(slot(this, &FormUrl::update));
h_ = d_->hideBufferDependent.connect(slot(this, &FormUrl::hide));
- if (!dialog_->is_visible()) dialog_->show_all();
-
update(); // make sure its up-to-date
}
- else
- {
- Gdk_Window dialog_win(dialog_->get_window());
- dialog_win.raise();
- }
}
void FormUrl::update()
void FormUrl::hide()
{
- if (dialog_!=NULL) dialog_->destroy();
+ if (dialog_!=NULL) mainAppWin->remove_action();
}
void FormUrl::free()
lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
params.getAsString().c_str() );
}
+
+ // save history
+ url_->save_history();
+ name_->save_history();
+
+ // hide the dialog
+ hide();
}
#include "support/utility.hpp"
#include "insets/insetcommand.h"
-#include <gtk--/widget.h>
+#include <gtk--/container.h>
#include <gtk--/checkbutton.h>
#include <gnome--/entry.h>
#include <gtk--/button.h>
Connection ih_;
/// Real GUI implementation.
- Gtk::Widget * dialog_;
+ Gtk::Container * dialog_;
Gtk::CheckButton * html_type_;
#include "LyXView.h"
#include "MenuBackend.h"
#include "Menubar_pimpl.h"
+#include "lyxtext.h"
+#include "exporter.h"
#include "mainapp.h"
+#include <gtk--/menu.h>
+
using SigC::slot;
using SigC::bind;
Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb)
: owner_(view), menubackend_(&mb), ignore_action_(false)
{
- // Should we do something here?
+
}
Menubar::Pimpl::~Pimpl()
{
- // Should we do something here?
+ if (utoc_.connected()) utoc_.disconnect();
}
void Menubar::Pimpl::set(string const & menu_name)
// if (current_menu_name_ != menu_name) // disabled until Lastfiles and Documents are added dynamically to menu
{
current_menu_name_ = menu_name;
+
+ // clean up the lists
+ toc_.clear();
+ if (utoc_.connected()) utoc_.disconnect();
+
// compose new menu
vector<Gnome::UI::Info> menus;
- composeUIInfo(current_menu_name_, menus);
+ composeUIInfo(current_menu_name_, menus, "");
// set menu
Menu_ = menus;
// update state of the items
update();
+ updateAllLists();
+ }
+}
+
+void Menubar::Pimpl::updateAllLists()
+{
+ // update lists
+ if (toc_.size() > 0)
+ {
+ vector<Buffer::TocItem> toclist = (owner_->view()->buffer()->getTocList())[Buffer::TOC_TOC];
+ updateList(&toclist, &toc_);
+ }
+}
+
+void Menubar::Pimpl::updateList(vector<Buffer::TocItem> * toclist, vector<ListsHolder> * pgui)
+{
+ vector<ListsHolder> & gui = *pgui;
+ int szGui = gui.size();
+ int i;
+ for (i=0; i < szGui; ++i)
+ {
+ int oldsz = gui[i].lst.size();
+ vector<Gnome::UI::Info> menu;
+ string label;
+
+ menu.push_back(Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_REFRESH),
+ N_("Refresh"), slot(this, &Menubar::Pimpl::updateAllLists)));
+
+ vector<Buffer::TocItem>::const_iterator end = toclist->end();
+ for (vector<Buffer::TocItem>::const_iterator it = toclist->begin();
+ it != end; ++it)
+
+ {
+ label = string(4*(*it).depth,' ')+(*it).str;
+
+ menu.push_back(Gnome::UI::Item(label,
+ bind<Buffer::TocItem>(slot(this, &Menubar::Pimpl::callbackToc), (*it)),
+ label));
+ }
+
+ gui[i].lst = menu;
+ mainAppWin->update_menu(gui[i].path, oldsz, gui[i].lst);
}
}
action_ = action;
}
-void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus)
+void Menubar::Pimpl::callbackToc(Buffer::TocItem tg)
{
+ if (!owner_->view()->available()) return;
+
+ owner_->view()->beforeChange();
+ owner_->view()->text->SetCursor( owner_->view(), tg.par, 0 );
+ owner_->view()->text->sel_cursor = owner_->view()->text->cursor;
+ owner_->view()->update(BufferView::SELECT|BufferView::FITCUR);
+}
+
+void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus, string rootpath)
+{
+ string path = rootpath;
+
if (!menubackend_->hasMenu(menu_name))
{
cout << "ERROR:composeUIInfo: Unknown menu `" << menu_name
case MenuItem::Command: {
string label = item.label();
+
+ path = rootpath + label;
+
if (label.find(item.shortcut()) != string::npos)
label.insert(label.find(item.shortcut()), "_");
case MenuItem::Submenu: {
vector<Gnome::UI::Info> submenu;
string label = item.label();
+
+ path = rootpath + label;
+
if (label.find(item.shortcut()) != string::npos)
label.insert(label.find(item.shortcut()), "_");
- composeUIInfo(item.submenu(), submenu);
+ composeUIInfo(item.submenu(), submenu, path + "/");
Menus.push_back(Gnome::UI::Menu(label,submenu,label));
break;
}
case MenuItem::Separator: {
+
+ path = rootpath + "<Separator>";
+
Menus.push_back(Gnome::UI::Separator());
break;
}
cit != lastfiles->end() && ii < 10; ++cit, ++ii)
{
int action = lyxaction.getPseudoAction(LFUN_FILE_OPEN, (*cit));
- string label = "_" + tostr(ii) + ". " + MakeDisplayPath((*cit),30);
+ string label = tostr(ii) + ". " + MakeDisplayPath((*cit),30);
+ path = rootpath + label;
+ label = "_" + label;
+
Menus.push_back(Gnome::UI::Item(label,
bind<int>(slot(this, &Menubar::Pimpl::callback), action),
label));
int action = lyxaction.getPseudoAction(LFUN_SWITCHBUFFER, *cit);
string label = MakeDisplayPath(*cit, 30);
+ path = rootpath + label;
+
Menus.push_back(Gnome::UI::Item(label,
bind<int>(slot(this, &Menubar::Pimpl::callback), action),
label));
}
break;
}
+
+ case MenuItem::Toc: {
+ ListsHolder t;
+ t.path = path;
+ toc_.push_back(t);
+ break;
+ }
+
+ case MenuItem::ViewFormats: {
+ add_formats(Menus, LFUN_PREVIEW, true);
+ break;
+ }
+
+ case MenuItem::UpdateFormats: {
+ add_formats(Menus, LFUN_UPDATE, true);
+ break;
+ }
+
+ case MenuItem::ExportFormats: {
+ add_formats(Menus, LFUN_EXPORT, false);
+ break;
+ }
}
}
}
+void Menubar::Pimpl::add_formats(vector<Gnome::UI::Info> & Menus, kb_action action, bool viewable)
+{
+ vector<pair<string,string> > names =
+ viewable
+ ? Exporter::GetViewableFormats(owner_->buffer())
+ : Exporter::GetExportableFormats(owner_->buffer());
+
+ for (vector<pair<string,string> >::const_iterator cit = names.begin();
+ cit != names.end() ; ++cit) {
+ int action2 = lyxaction.getPseudoAction(action, (*cit).first);
+ string label = (*cit).second;
+
+ Menus.push_back(Gnome::UI::Item(label,
+ bind<int>(slot(this, &Menubar::Pimpl::callback), action2),
+ label));
+ }
+}
+
void Menubar::Pimpl::connectWidgetToAction(GnomeUIInfo * guinfo)
{
for (; guinfo->type != GnomeUIInfoType(GNOME_APP_UI_ENDOFINFO); ++guinfo)
{
- if ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_ITEM) ||
- guinfo->type == GnomeUIInfoType(GNOME_APP_UI_TOGGLEITEM) )
+ if ( ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_ITEM) ||
+ guinfo->type == GnomeUIInfoType(GNOME_APP_UI_TOGGLEITEM) ) &&
+ guinfo->moreinfo != NULL )
{
(*((void(*)(void *, void *))(guinfo->moreinfo)))(NULL, guinfo->user_data);
wid_act_.push_back( GtkWidgetToAction( guinfo->widget, action_ ) );
#include "LString.h"
#include <gnome--/app.h>
#include "frontends/Menubar.h"
+#include "commandtags.h"
+#include "buffer.h"
class LyXView;
class MenuBackend;
class MenuItem;
class StrPool;
+#ifdef SIGC_CXX_NAMESPACES
+using SigC::Connection;
+#endif
+
#include "debug.h"
/*
void openByName(string const &);
/// update the state of menuitems
void update();
+ /// update TOC, LOF, ... on user' request
+ void updateAllLists();
protected:
/// callback function
void callback(int action);
+ /// callback function used by lists
+ void callbackToc(Buffer::TocItem tg);
/// compose Gnome::UI::Array object describing the menu
- void composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus);
+ void composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus, string path);
/// populate wid_act_ vector with all widgets and corresponding actions
void connectWidgetToAction(GnomeUIInfo * guinfo);
+
+ /// lists (toc, lof, lot, loa)
+ struct ListsHolder {
+ string path;
+ Gnome::UI::Array lst;
+
+ ListsHolder () { }
+ ListsHolder (const ListsHolder & a) { path = a.path; lst = a.lst; }
+ };
+ /// populate lists
+ void updateList(vector<Buffer::TocItem> *, vector<ListsHolder> *);
+ /// Add to "Menus" the list of exportable/viewable formats
+ void add_formats(vector<Gnome::UI::Info> & Menus, kb_action action, bool viewable);
private:
///
bool ignore_action_;
int action_;
vector<GtkWidgetToAction> wid_act_;
+
+ /// toc
+ Connection utoc_;
+ vector<ListsHolder> toc_;
};
#endif
* ====================================================== */
#include <config.h>
+
#include <gnome--/main.h>
#include <gtk--/accelgroup.h>
+#include <gnome--/pixmap.h>
+#include <gtk--/separator.h>
+#include <gtk--/frame.h>
+#include <gtk--/label.h>
+
#include <vector>
#include <algorithm>
GLyxAppWin::GLyxAppWin() :
Gnome::App(PACKAGE,"LyX Gnomified"),
- status_(false, true, GNOME_PREFERENCES_NEVER)
+ status_(false, true, GNOME_PREFERENCES_NEVER),
+ action_mode(false)
{
init();
show_all();
set_default_size(250, 350);
set_wmclass(PACKAGE, "GnomeLyX");
- frame_.set_shadow_type(GTK_SHADOW_IN);
-
- set_contents(frame_);
-
set_statusbar(status_);
// initial (dummy) menu
menu.gtkobj());
menusize_ = menu.size();
+
+ // packing widgets
+
+ // temporary main widget
+ Gtk::HBox * h = manage( new Gtk::HBox() );
+ Gnome::Pixmap * p;
+ p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(NULL, GNOME_STOCK_PIXMAP_ABOUT) ) );
+
+ h->children().push_back( Gtk::Box_Helpers::Element( *p ) );
+ h->children().push_back( *(manage(new Gtk::Label("Waiting for LyXView port"))) );
+
+ view_ = h;
+ // temporary main widget: done
+
+ // packing main widget and separator
+ Gtk::Separator * sep = manage( new Gtk::HSeparator() );
+
+ box_.children().push_back( Gtk::Box_Helpers::Element(*view_) );
+ box_.children().push_back( Gtk::Box_Helpers::Element(*sep, false) );
+
+ box_.show_all();
+
+ set_contents(box_);
+
+ key_press_event.connect(slot(this, &GLyxAppWin::key_pressed));
}
menusize_ = menu.size();
}
+void GLyxAppWin::update_menu(string path, int noelms, Gnome::UI::Array &menu)
+{
+ // remove "noelms" items and install new items from "menu"
+ gnome_app_remove_menus(this->gtkobj(),path.c_str(),noelms);
+ gnome_app_insert_menus(this->gtkobj(),path.c_str(),menu.gtkobj());
+ gnome_app_install_menu_hints(this->gtkobj(),menu.gtkobj());
+}
+
+// clean up first, then add new action widget and finally, disable main view
+void GLyxAppWin::add_action(Gtk::Container &action, string title, bool expand)
+{
+ remove_action();
+
+ Gtk::Frame * frame = manage( new Gtk::Frame(title) );
+ frame->set_border_width(2);
+ action.set_border_width(2);
+ frame->add(action);
+
+ box_.children().push_back( Gtk::Box_Helpers::Element( *frame, expand ) );
+ box_.show_all();
+
+ view_->set_sensitive(false);
+ action_mode = true;
+}
+
+void GLyxAppWin::remove_action()
+{
+ while ( box_.children().size() > 2 )
+ {
+ box_.children().pop_back();
+ }
+
+ view_->set_sensitive(true);
+ action_mode = false;
+}
+
+gint GLyxAppWin::key_pressed(GdkEventKey * e)
+{
+ if (action_mode &&
+ e->keyval == GDK_Escape)
+ {
+ remove_action();
+ return TRUE;
+ }
+ return FALSE;
+}
/// set menu of the window
void set_menu(Gnome::UI::Array &);
+ /// update menu
+ void update_menu(string path,
+ int noelms,
+ Gnome::UI::Array &);
+ /// add action area
+ void add_action(Gtk::Container &, string title, bool expand=false);
+ /// remove action area
+ void remove_action();
+ /// clears action area if Escape is pressed
+ gint key_pressed(GdkEventKey * e);
protected:
/// init window widgets
protected:
// widgets
Gnome::AppBar status_;
- Gtk::Frame frame_;
+ Gtk::VBox box_;
+ Gtk::Widget *view_;
+ bool action_mode;
+
// menu size
int menusize_;
};
#include "formrefdialog.h"
#include "debug.h"
+using std::endl;
+
FormRef::FormRef(LyXView *v, Dialogs *d)
: dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0),
sort(0), gotowhere(GOTOREF), type(REF), refs(0)
private:
enum Type {
- REF, PAGEREF, VREF, VPAGEREF, PRETTYREF,
+ REF, PAGEREF, VREF, VPAGEREF, PRETTYREF
};
enum GotoType {
- GOTOREF, GOTOBACK,
+ GOTOREF, GOTOBACK
};
/// Create the dialog if necessary, update it and display it.
using std::vector;
using std::pair;
using std::stack;
-
+using std::endl;
+
FormToc::FormToc(LyXView *v, Dialogs *d)
: dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0),
toclist(0), type(Buffer::TOC_TOC), depth(1)
form_->set_type(Buffer::TOC_LOA);
break;
default:
- lyxerr[Debug::GUI] << "Unknown TOC combo selection." << endl;
+ lyxerr[Debug::GUI] << "Unknown TOC combo selection." << std::endl;
break;
}
}
params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle);
#ifdef USE_CLASS_COMBO
- unsigned int new_class = combo_doc_class->get();
+ unsigned int new_class = combo_doc_class->get() - 1;
#else
unsigned int new_class = fl_get_choice(class_->choice_doc_class) - 1;
#endif
_("Errors loading new document class."),
_("Reverting to original document class."));
#ifdef USE_CLASS_COMBO
- combo_doc_class->select(params.textclass);
+ combo_doc_class->select(params.textclass + 1);
#else
fl_set_choice(class_->choice_doc_class,
params.textclass + 1);
string tct;
#ifdef USE_CLASS_COMBO
- tc = combo_doc_class->get();
+ tc = combo_doc_class->get() - 1;
tct = combo_doc_class->getline();
#else
tc = fl_get_choice(ob) - 1;
_("Unable to switch to new document class."),
_("Reverting to original document class."));
#ifdef USE_CLASS_COMBO
- combo_doc_class->select(lv_->buffer()->params.textclass);
+ combo_doc_class->select(lv_->buffer()->params.textclass + 1);
#else
fl_set_choice(class_->choice_doc_class,
lv_->buffer()->params.textclass + 1);
} else {
char * msg = 0;
string lfname = fname;
- if (GetExtension(fname).empty())
+ if (!fname.empty() && GetExtension(fname).empty())
lfname += ".eps";
// draw frame
pain.rectangle(int(x), baseline - hgh - 1, wid + 1, hgh + 1);
const int ADD_TO_HEIGHT = 2;
const int ADD_TO_TABULAR_WIDTH = 2;
+///
+static LyXTabular * paste_tabular = 0;
+bool InsetTabular::hasPasteBuffer() const
+{
+ return (paste_tabular != 0);
+}
using std::ostream;
using std::ifstream;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
dialogs_ = 0;
- paste_tabular = 0;
need_update = INIT;
}
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
dialogs_ = 0;
- paste_tabular = 0;
need_update = INIT;
}
}
the_locking_inset = 0;
if (inset_hit && bv->the_locking_inset) {
- ActivateCellInset(bv, x, y, button);
- the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
+ if (ActivateCellInset(bv, x, y, button))
+ the_locking_inset->InsetButtonPress(bv, x-inset_x,
+ y-inset_y, button);
return;
}
ShowInsetCursor(bv);
if (!the_locking_inset)
return false;
UpdateLocal(bv, CELL, false);
- return true;
+ return (the_locking_inset != 0);
}
{
if (!hasSelection())
return false;
- for(int i=sel_cell_start; i < sel_cell_end; ++i) {
- tabular->GetCellInset(i)->clear();
+
+ int sel_col_start, sel_col_end;
+ int sel_row_start, sel_row_end;
+
+ sel_col_start = tabular->column_of_cell(sel_cell_start);
+ sel_col_end = tabular->column_of_cell(sel_cell_end);
+ if (sel_col_start > sel_col_end) {
+ sel_col_start = sel_col_end;
+ sel_col_end = tabular->right_column_of_cell(sel_cell_start);
+ } else {
+ sel_col_end = tabular->right_column_of_cell(sel_cell_end);
+ }
+ sel_row_start = tabular->row_of_cell(sel_cell_start);
+ sel_row_end = tabular->row_of_cell(sel_cell_end);
+ if (sel_row_start > sel_row_end) {
+ int tmp;
+ tmp = sel_row_start;
+ sel_row_start = sel_row_end;
+ sel_row_end = tmp;
+ }
+ if (sel_cell_start > sel_cell_end) {
+ int tmp = sel_cell_start;
+ sel_cell_start = sel_cell_end;
+ sel_cell_end = tmp;
+ }
+ int i, j;
+ for(i=sel_row_start; i <= sel_row_end; ++i) {
+ for(j=sel_col_start; j <= sel_col_end; ++j) {
+ tabular->GetCellInset(tabular->GetCellNumber(i, j))->clear();
+ }
}
return true;
}
///
int GetMaxWidthOfCell(Painter &, int cell) const;
///
- bool hasPasteBuffer() const { return (paste_tabular != 0); }
+ bool hasPasteBuffer() const;
///
bool copySelection();
///
mutable UpdateCodes need_update;
///
mutable Dialogs * dialogs_;
- ///
- LyXTabular * paste_tabular;
};
#endif
#include "intl.h"
#include "trans_mgr.h"
#include "lyxscreen.h"
+#include "WorkArea.h"
using std::ostream;
using std::ifstream;
}
}
if (!inset) {
+ bool paste_internally = false;
+ if ((button == 2) && TEXT(bv)->selection) {
+ LocalDispatch(bv, LFUN_COPY, "");
+ paste_internally = true;
+ }
TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
y+TEXT(bv)->first+insetAscent);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
bv->owner()->setLayout(cpar(bv)->GetLayout());
old_par = cpar(bv);
+ // Insert primary selection with middle mouse
+ // if there is a local selection in the current buffer,
+ // insert this
+ if (button == 2) {
+ if (paste_internally)
+ LocalDispatch(bv, LFUN_PASTE, "");
+ else
+ LocalDispatch(bv, LFUN_PASTESELECTION, "paragraph");
+ }
}
ShowInsetCursor(bv);
}
bv->text->cursor.par()->next
#endif
);
- TEXT(bv)->Backspace(bv);
+ if (TEXT(bv)->selection)
+ TEXT(bv)->CutSelection(bv);
+ else
+ TEXT(bv)->Backspace(bv);
UpdateLocal(bv, CURSOR_PAR, true);
break;
case LFUN_DELETE:
bv->text->cursor.par()->next
#endif
);
- TEXT(bv)->Delete(bv);
+ if (TEXT(bv)->selection)
+ TEXT(bv)->CutSelection(bv);
+ else
+ TEXT(bv)->Delete(bv);
UpdateLocal(bv, CURSOR_PAR, true);
break;
case LFUN_CUT:
TEXT(bv)->CopySelection(bv);
UpdateLocal(bv, CURSOR_PAR, false);
break;
+ case LFUN_PASTESELECTION:
+ {
+ string clip(bv->workarea()->getClipboard());
+
+ if (clip.empty())
+ break;
+ if (arg == "paragraph") {
+ TEXT(bv)->InsertStringB(bv, clip);
+ } else {
+ TEXT(bv)->InsertStringA(bv, clip);
+ }
+ UpdateLocal(bv, CURSOR_PAR, true);
+ break;
+ }
case LFUN_PASTE:
if (!autoBreakRows) {
CutAndPaste cap;
// ProhibitInput(bv);
- lpar = TEXT(bv)->cursor.par();
- pos = TEXT(bv)->cursor.pos();
- selstartpar = TEXT(bv)->sel_start_cursor.par();
- selstartpos = TEXT(bv)->sel_start_cursor.pos();
- selendpar = TEXT(bv)->sel_end_cursor.par();
- selendpos = TEXT(bv)->sel_end_cursor.pos();
- selection = TEXT(bv)->selection;
- mark_set = TEXT(bv)->mark_set;
+ if (locked) {
+ lpar = TEXT(bv)->cursor.par();
+ pos = TEXT(bv)->cursor.pos();
+ selstartpar = TEXT(bv)->sel_start_cursor.par();
+ selstartpos = TEXT(bv)->sel_start_cursor.pos();
+ selendpar = TEXT(bv)->sel_end_cursor.par();
+ selendpos = TEXT(bv)->sel_end_cursor.pos();
+ selection = TEXT(bv)->selection;
+ mark_set = TEXT(bv)->mark_set;
+ }
deleteLyXText(bv, (the_locking_inset == 0));
if (lpar) {
PspellCanHaveError * spell_error_object;
static
-void init_spell_checker(BufferParams const &, string const & lang)
+void init_spell_checker(BufferParams const &, string const & /* lang */)
{
PspellConfig * config = new_pspell_config();
spell_error_object = new_pspell_manager(config);
if (word_ok) {
result->flag = ISP_OK;
} else {
-
PspellWordList const * sugs =
pspell_manager_suggest(sc, word.c_str());
Assert(sugs != 0);
return column_info[column_of_cell(cell)].alignment;
}
-string LyXTable::GetPWidth(int cell)
+string const LyXTable::GetPWidth(int cell)
{
int fvcell = FirstVirtualCell(cell);
return column_info[column_of_cell(fvcell)].p_width;
}
-string LyXTable::GetAlignSpecial(int cell, int what)
+string const LyXTable::GetAlignSpecial(int cell, int what)
{
if (what == SET_SPECIAL_MULTI)
return cellinfo_of_cell(cell)->align_special;