+2000-05-20 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/BufferView.C (pasteSelection): new method
+
+ * src/BufferView_pimpl.C (pasteSelection): new method
+
+ * src/lyxfunc.C (Dispatch): use the new clipboard functions.
+
+ * src/WorkArea.C (request_clipboard_cb): new static function
+ (getClipboard): new method
+ (putClipboard): new method
+
2000-05-19 Lars Gullik Bjønnes <larsbj@lyx.org>
* LyX 1.1.5pre2 released
}
+#ifndef XFORMS_CLIPBOARD
void BufferView::workAreaSelectionNotify(Window win, XEvent * event)
{
pimpl_->workAreaSelectionNotify(win, event);
}
+#endif
void BufferView::cursorPrevious()
{
pimpl_->center();
}
+
+
+#ifdef XFORMS_CLIPBOARD
+void BufferView::pasteSelection(bool asPara)
+{
+ pimpl_->pasteSelection(asPara);
+}
+#endif
class TeXErrors;
class Buffer;
+#define XFORMS_CLIPBOARD 1
+
///
class BufferView {
public:
void enterView();
///
void leaveView();
+#ifndef XFORMS_CLIPBOARD
///
void workAreaSelectionNotify(Window win, XEvent * event);
+#endif
///
bool ChangeRefs(string const & from, string const & to);
+#ifdef XFORMS_CLIPBOARD
+ ///
+ void pasteSelection(bool asPara);
+#endif
private:
struct Pimpl;
Pimpl * pimpl_;
#include "lyxrc.h"
#include "intl.h"
#include "support/LAssert.h"
+
using std::pair;
using std::endl;
+using std::vector;
/* the selection possible is needed, that only motion events are
* used, where the bottom press event was on the drawing area too */
}
+#ifndef XFORMS_CLIPBOARD
static
string fromClipboard(Window win, XEvent * event)
{
update(1);
}
}
+#endif
void BufferView::Pimpl::update()
update(0);
redraw();
}
+
+
+#ifdef XFORMS_CLIPBOARD
+void BufferView::Pimpl::pasteSelection(bool asPara)
+{
+ if (buffer_ == 0) return;
+
+ screen->HideCursor();
+ bv_->beforeChange();
+
+ string clip(workarea->getClipboard());
+
+ if (clip.empty()) return;
+
+ if (asPara) {
+ bv_->text->InsertStringB(clip);
+ } else {
+ bv_->text->InsertStringA(clip);
+ }
+ update(1);
+}
+#endif
void workAreaButtonPress(int x, int y, unsigned int button);
///
void workAreaButtonRelease(int x, int y, unsigned int button);
+#ifndef XFORMS_CLIPBOARD
///
void workAreaSelectionNotify(Window win, XEvent * event);
+#endif
///
void doubleClick(int x, int y, unsigned int button);
///
WorkArea * workarea;
///
UpdateInset updatelist;
+#ifdef XFORMS_CLIPBOARD
+ ///
+ void pasteSelection(bool asPara);
+#endif
private:
bool using_xterm_cursor;
};
break;
case FL_OTHER:
if (!ev) break;
+#ifndef XFORMS_CLIPBOARD
if (ev->type == SelectionNotify) {
lyxerr.debug() << "Workarea event: SELECTION" << endl;
area->owner->workAreaSelectionNotify(area->work_area->form->window, ev);
} else
+#endif
lyxerr.debug() << "Workarea event: OTHER" << endl;
break;
return 1;
}
+
+
+#ifdef XFORMS_CLIPBOARD
+static string clipboard_selection;
+static bool clipboard_read = false;
+
+static
+int request_clipboard_cb(FL_OBJECT * /*ob*/, long /*type*/,
+ void const * data, long size)
+{
+ clipboard_selection.erase();
+ if (size == 0) return 0; // no selection
+
+ clipboard_selection.reserve(size);
+ for (int i = 0; i < size; ++i) {
+ clipboard_selection.push_back(static_cast<char*>(data)[i]);
+ }
+ clipboard_read = true;
+ return 0;
+}
+
+
+string WorkArea::getClipboard() const
+{
+ clipboard_read = false;
+
+ if (fl_request_clipboard(work_area, 0, request_clipboard_cb) == -1)
+ return string();
+
+ XEvent ev;
+
+ while (!clipboard_read) {
+ if (fl_check_forms() == FL_EVENT) {
+ lyxerr << "LyX: This shouldn't happen..." << endl;
+ fl_XNextEvent(&ev);
+ }
+ }
+ return clipboard_selection;
+}
+
+
+void WorkArea::putClipboard(string const & s) const
+{
+ static string hold;
+ hold = s;
+
+ fl_stuff_clipboard(work_area, 0, hold.c_str(), hold.size(), 0);
+}
+#endif
class BufferView;
+#define XFORMS_CLIPBOARD 1
+
class WorkArea {
public:
///
int /*key*/, void * xev);
/// xforms callback
static void scroll_cb(FL_OBJECT *, long);
+#ifdef XFORMS_CLIPBOARD
+ ///
+ string getClipboard() const;
+ ///
+ void putClipboard(string const &) const;
+#endif
private:
///
void createPixmap(int, int);
extern FD_LaTeXOptions * fd_latex_options;
extern FD_form_bullet * fd_form_bullet;
+#define XFORMS_CLIPBOARD 1
+
extern BufferView * current_view; // called too many times in this file...
extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
}
+#ifndef XFORMS_CLIPBOARD
void MenuPasteSelection(char at)
{
if (!current_view->available())
return;
-
ascii_type = at;
Atom data_prop = XInternAtom(fl_display,
XA_PRIMARY, XA_STRING, data_prop,
current_view->owner()->getForm()->window, 0);
XFlush(fl_display);
-}
+}
+#endif
extern void QuitLyX();
extern void MenuFax(Buffer *);
extern void MenuExport(Buffer *, string const &);
+
+#define XFORMS_CLIPBOARD 1
+
+#ifndef XFORMS_CLIPBOARD
extern void MenuPasteSelection(char at);
+#endif
+
extern LyXAction lyxaction;
// (alkis)
extern tex_accent_struct get_accent(kb_action action);
static LyXFindReplace FR_;
FR_.StartSearch(owner->view());
}
-
- break;
+ break;
case LFUN_PASTE:
owner->view()->paste();
{
bool asPara = false;
if (argument == "paragraph") asPara = true;
+#ifdef XFORMS_CLIPBOARD
+ owner->view()->pasteSelection(asPara);
+#else
MenuPasteSelection(asPara);
- break;
+#endif
}
-
+ break;
+
case LFUN_CUT:
owner->view()->cut();
break;