regex patch for gnom from Marko

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1023 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-09-15 17:01:24 +00:00
parent b2b9fd9c89
commit 854eb6f9e9
8 changed files with 85 additions and 2303 deletions

View File

@ -1,3 +1,10 @@
2000-09-15 Marko Vendelin <markov@ioc.ee>
* src/frontends/gnome/FormCitation.C
* src/frontends/gnome/FormCitation.h
* src/frontends/gnome/diainsertcitation_interface.c
* src/frontends/gnome/dialogs/diainsertcitation.glade: adds
regexp support to FormCitation [Gnome].
2000-09-15 John Levon <moz@compsoc.man.ac.uk>
* acconfig.h

View File

@ -119,7 +119,6 @@ src/mathed/formulamacro.C
src/mathed/math_forms.C
src/mathed/math_panel.C
src/MenuBackend.C
src/menus.C
src/minibuffer.C
src/PaperLayout.C
src/paragraph.C

View File

@ -25,6 +25,7 @@
#include "buffer.h"
#include "lyxfunc.h"
#include "support/filetools.h"
#include "support/LRegex.h"
extern "C" {
#include "diainsertcitation_interface.h"
@ -63,6 +64,9 @@ using SigC::bind;
#define CONF_COLUMN "column"
#define CONF_COLUMN_DEFAULT "=50"
#define CONF_REGEXP "regexp"
#define CONF_REGEXP_DEFAULT "=0"
FormCitation::FormCitation(LyXView * lv, Dialogs * d)
: lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL)
@ -209,6 +213,8 @@ void FormCitation::show()
button_down_ = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_down") ) );
button_search_ = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_search") ) );
button_regexp_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "button_regexp") ) );
paned_info_ = Gtk::wrap( GTK_PANED( lookup_widget(pd, "vpaned_info") ) );
paned_key_ = Gtk::wrap( GTK_PANED( lookup_widget(pd, "hpaned_key") ) );
box_keys_ = Gtk::wrap( GTK_BOX( lookup_widget(pd, "vbox_keys") ) );
@ -291,6 +297,10 @@ void FormCitation::show()
w = path + "/" + CONF_COLUMN + "_" + tostr(i) + CONF_COLUMN_DEFAULT;
clist_bib_->column(i).set_width( gnome_config_get_int(w.c_str()) );
}
// restoring regexp setting
w = path + "/" + CONF_REGEXP + CONF_REGEXP_DEFAULT;
button_regexp_->set_active( (gnome_config_get_int(w.c_str()) > 0) );
// ready to go...
if (!dialog_->is_visible()) dialog_->show_all();
@ -499,6 +509,9 @@ void FormCitation::free()
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());
gnome_config_sync();
// cleaning up
@ -546,8 +559,45 @@ void FormCitation::sortBibList(gint col)
clist_bib_->sort();
}
// looking for entries which contain all the words specified in search_text entry
void FormCitation::search()
{
if (button_regexp_->get_active()) searchReg();
else searchSimple();
}
// looking for entries which match regexp
void FormCitation::searchReg()
{
string tmp, rexptxt( search_text_->get_entry()->get_text() );
rexptxt = frontStrip( strip( rexptxt ) );
LRegex reg(rexptxt);
// populating clist_bib_
clist_bib_->rows().clear();
clist_bib_->freeze();
int i, sz;
bool additem;
for ( i = 0, sz = bibkeys.size(); i < sz; ++i )
{
string data = bibkeys[i] + bibkeysInfo[i];
if (rexptxt.empty()) additem = true;
else additem = (reg.exec(data).size() > 0);
if ( additem ) addItemToBibList(i);
}
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() );

View File

@ -28,6 +28,7 @@
#include <gtk--/button.h>
#include <gtk--/paned.h>
#include <gtk--/box.h>
#include <gtk--/checkbutton.h>
/** This class provides an Gnome implementation of the FormCitation Dialog.
*/
@ -74,6 +75,8 @@ private:
void moveCitationDown();
/// searches for entries
void search();
void searchReg();
void searchSimple();
/// add item to the list
void addItemToBibList(int i);
@ -113,7 +116,8 @@ private:
Gtk::Button * button_up_;
Gtk::Button * button_down_;
Gtk::Button * button_search_;
Gtk::CheckButton * button_regexp_;
Gtk::CList * clist_selected_;
Gtk::CList * clist_bib_;

View File

@ -42,6 +42,7 @@ create_DiaInsertCitation (void)
GtkWidget *search_text;
GtkWidget *combo_entry1;
GtkWidget *button_search;
GtkWidget *button_regexp;
GtkWidget *vbox5;
GtkWidget *alignment2;
GtkWidget *label16;
@ -236,6 +237,13 @@ create_DiaInsertCitation (void)
gtk_box_pack_start (GTK_BOX (hbox3), button_search, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (button_search), 2);
button_regexp = gtk_check_button_new_with_label (_("Use Regular Expression"));
gtk_widget_ref (button_regexp);
gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_regexp", button_regexp,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (button_regexp);
gtk_box_pack_start (GTK_BOX (hbox3), button_regexp, FALSE, FALSE, 0);
vbox5 = gtk_vbox_new (FALSE, 1);
gtk_widget_ref (vbox5);
gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "vbox5", vbox5,

View File

@ -375,6 +375,20 @@
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>button_regexp</name>
<can_focus>True</can_focus>
<label>Use Regular Expression</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>

File diff suppressed because it is too large Load Diff

View File

@ -1,108 +0,0 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef MENUS_H
#define MENUS_H
#ifdef __GNUG__
#pragma interface
#endif
#include FORMS_H_LOCATION
#include "lyx.h"
#include "LString.h"
class BufferView;
class LyXView;
///
class Menus {
public:
///
Menus(LyXView *view, int air);
///
void showMenus();
///
void hideMenus();
///
void openByName(string const &menuName);
///
static void ShowFileMenu(FL_OBJECT *ob, long);
///
static void ShowFileMenu2(FL_OBJECT *ob, long);
///
static void ShowEditMenu(FL_OBJECT *ob, long data);
///
static void ShowTocMenu(FL_OBJECT *ob, long data);
///
static void ShowRefsMenu(FL_OBJECT *ob, long data);
///
static void ShowLayoutMenu(FL_OBJECT *ob, long data);
///
static void ShowInsertMenu(FL_OBJECT *ob, long data);
///
static void ShowMathMenu(FL_OBJECT *ob, long);
///
static void ShowOptionsMenu(FL_OBJECT *ob, long men);
///
static void ShowBufferMenu(FL_OBJECT *ob, long);
///
static void ShowHelpMenu(FL_OBJECT *ob, long);
private:
///
void create_menus(int air);
///
void showCopyright();
///
void showLicense();
///
void MenuDocu(string const & docname);
///
void handleBufferMenu(int choice);
///
BufferView *currentView();
///
LyXView *_view;
///
FL_OBJECT *menu_grp1;
///
FL_OBJECT *menu_grp2;
///
FL_OBJECT *menu_file;
///
FL_OBJECT *menu_file2;
///
FL_OBJECT *menu_edit;
///
FL_OBJECT *menu_toc;
///
FL_OBJECT *menu_refs;
///
FL_OBJECT *menu_layout;
///
FL_OBJECT *menu_insert;
///
FL_OBJECT *menu_math;
///
FL_OBJECT *menu_options;
///
FL_OBJECT *menu_options2;
///
FL_OBJECT *menu_buffer;
///
FL_OBJECT *menu_help;
///
FL_OBJECT *menu_help2;
};
#endif