The bottom of dw/selection.cc goes: /** \todo Actual Selection is platform dependant. */ printf ("Selected text:\n"); printf ("--------------------------------------------------\n"); printf (strbuf.getChars ()); printf ("\n--------------------------------------------------\n"); Now, suppose we violate the principles of dw, sticking #include <fltk/events.h> in the top of the file, and put const char *buf = strbuf.getChars(); fltk::copy(buf, strlen(buf), false); in place of the above printf()s. Works. So if anyone knows the structure of dw well enough to know how to go about making a proper little platform-independent interface, there's nothing difficult here in principle...
To start with a simple one ... On Sun, Nov 18, place wrote:
The bottom of dw/selection.cc goes:
/** \todo Actual Selection is platform dependant. */
printf ("Selected text:\n"); printf ("--------------------------------------------------\n"); printf (strbuf.getChars ()); printf ("\n--------------------------------------------------\n");
Now, suppose we violate the principles of dw, sticking #include <fltk/events.h> in the top of the file, and put const char *buf = strbuf.getChars(); fltk::copy(buf, strlen(buf), false); in place of the above printf()s. Works.
So if anyone knows the structure of dw well enough to know how to go about making a proper little platform-independent interface, there's nothing difficult here in principle..
Well, a clean solution is rather simple: this is exactly, what dw::core::Platform is for. A patch is attached below (also in CVS). Sebastian ---------- Index: dw/fltkplatform.cc =================================================================== RCS file: /sfhome/cvs/dillo/dw2/dw/fltkplatform.cc,v retrieving revision 1.2 diff -u -r1.2 fltkplatform.cc --- dw/fltkplatform.cc 17 Nov 2007 16:15:13 -0000 1.2 +++ dw/fltkplatform.cc 18 Nov 2007 17:16:51 -0000 @@ -24,6 +24,7 @@ #include <fltk/draw.h> #include <fltk/run.h> +#include <fltk/events.h> #include <stdio.h> namespace dw { @@ -379,6 +380,10 @@ return new FltkColor(color, core::style::Color::TYPE_SHADED); } +void FltkPlatform::copySelection(const char *text) +{ + fltk::copy(text, strlen(text), false); +} core::Imgbuf *FltkPlatform::createImgbuf (core::Imgbuf::Type type, int width, int height) Index: dw/fltkplatform.hh =================================================================== RCS file: /sfhome/cvs/dillo/dw2/dw/fltkplatform.hh,v retrieving revision 1.2 diff -u -r1.2 fltkplatform.hh --- dw/fltkplatform.hh 17 Nov 2007 16:15:13 -0000 1.2 +++ dw/fltkplatform.hh 18 Nov 2007 17:16:52 -0000 @@ -157,6 +157,8 @@ core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height); + void copySelection(const char *text); + core::ui::ResourceFactory *getResourceFactory (); void attachResource (ui::FltkResource *resource); Index: dw/layout.cc =================================================================== RCS file: /sfhome/cvs/dillo/dw2/dw/layout.cc,v retrieving revision 1.4 diff -u -r1.4 layout.cc --- dw/layout.cc 13 Nov 2007 13:57:32 -0000 1.4 +++ dw/layout.cc 18 Nov 2007 17:16:52 -0000 @@ -101,6 +101,8 @@ DBG_OBJ_ASSOC (&selection, this); platform->setLayout (this); + + selectionState.setLayout(this); } Layout::~Layout () Index: dw/layout.hh =================================================================== RCS file: /sfhome/cvs/dillo/dw2/dw/layout.hh,v retrieving revision 1.2 diff -u -r1.2 layout.hh --- dw/layout.hh 19 Oct 2007 22:10:13 -0000 1.2 +++ dw/layout.hh 18 Nov 2007 17:16:52 -0000 @@ -223,6 +223,11 @@ return platform->createImgbuf (type, width, height); } + inline void copySelection(const char *text) + { + platform->copySelection(text); + } + inline ui::ResourceFactory *getResourceFactory () { return platform->getResourceFactory (); Index: dw/platform.hh =================================================================== RCS file: /sfhome/cvs/dillo/dw2/dw/platform.hh,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 platform.hh --- dw/platform.hh 6 Oct 2007 22:03:01 -0000 1.1.1.1 +++ dw/platform.hh 18 Nov 2007 17:16:52 -0000 @@ -188,6 +188,11 @@ virtual Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height) = 0; /** + * \brief Copy selected text (0-terminated). + */ + virtual void copySelection(const char *text) = 0; + + /** * ... */ virtual ui::ResourceFactory *getResourceFactory () = 0; Index: dw/selection.cc =================================================================== RCS file: /sfhome/cvs/dillo/dw2/dw/selection.cc,v retrieving revision 1.3 diff -u -r1.3 selection.cc --- dw/selection.cc 1 Nov 2007 15:00:04 -0000 1.3 +++ dw/selection.cc 18 Nov 2007 17:16:52 -0000 @@ -44,6 +44,8 @@ SelectionState::SelectionState () { + layout = NULL; + selectionState = NONE; from = NULL; to = NULL; @@ -493,12 +495,7 @@ delete i; } - /** \todo Actual Selection is platform dependant. */ - - printf ("Selected text:\n"); - printf ("--------------------------------------------------\n"); - printf (strbuf.getChars ()); - printf ("\n--------------------------------------------------\n"); + layout->copySelection(strbuf.getChars()); } } Index: dw/selection.hh =================================================================== RCS file: /sfhome/cvs/dillo/dw2/dw/selection.hh,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 selection.hh --- dw/selection.hh 6 Oct 2007 22:03:01 -0000 1.1.1.1 +++ dw/selection.hh 18 Nov 2007 17:16:52 -0000 @@ -209,6 +209,8 @@ DoubleClickEmitter doubleClickEmitter; + Layout *layout; + // selection enum { NONE, @@ -248,6 +250,7 @@ SelectionState (); ~SelectionState (); + inline void setLayout (Layout *layout) { this->layout = layout; } void reset (); inline void connectDoubleClick (DoubleClickReceiver *receiver) { doubleClickEmitter.connectDoubleClick (receiver); }
Sebastian wrote:
Well, a clean solution is rather simple: this is exactly, what dw::core::Platform is for. A patch is attached below (also in CVS).
Oh, the solution was right under my nose all along and I didn't notice it... I should stop fixing things myself and just make requests on the list :)
participants (2)
-
place@gobigwest.com
-
sgeerken@dillo.org