Re: "Real" text in xdosemu

Bart Oldeman
2004-10-14T09:41:45Z

On Wed, 29 Sep 2004, Jan Willem Stumpel wrote:

> It is strange .. copying and pasting to and from xdosemu (text
> programs only, of course) *does* works fine in 1.3. And it works
> irrespective of the font used, and whether the text window is
> resizable or not!

I had problems myself with KDE 3.2.3: after you selected by dragging the
mouse it would be cleared as soon as I released the mouse button. That's
fixed now and committed to the CVS. The fix for 1.2.2 is below in case
anyone is interested.

> Why selections are highlighted in some programs and not in others,
> I have no idea. Even within the same program there are
> differences. For instance in Turbo C, selections are highlighted
> in the main edit screen, but not in the help screens. But
> selections can be taken from both of them.

True, I'll have a look at that later.

Bart

--- src/env/video/X.c 4 Jul 2004 05:39:55 -0000 1.4.2.10
+++ src/env/video/X.c 14 Oct 2004 09:34:04 -0000
@@ -453,9 +453,16 @@
static int sel_start_row = -1, sel_end_row = -1, sel_start_col, sel_end_col;
static unsigned short *sel_start = NULL, *sel_end = NULL;
static u_char *sel_text = NULL;
-static Atom compound_text_atom = None;
-static Atom utf8_text_atom = None;
-static Atom text_atom = None;
+enum {
+ TARGETS_ATOM,
+ TIMESTAMP_ATOM,
+ COMPOUND_TARGET,
+ UTF8_TARGET,
+ TEXT_TARGET,
+ STRING_TARGET,
+ NUM_TARGETS
+};
+static Atom targets[NUM_TARGETS];
static Boolean doing_selection = FALSE, visible_selection = FALSE;
#endif

@@ -844,9 +851,12 @@
}
#if CONFIG_X_SELECTION
/* Get atom for COMPOUND_TEXT/UTF8/TEXT type. */
- compound_text_atom = XInternAtom(display, "COMPOUND_TEXT", False);
- utf8_text_atom = XInternAtom(display, "UTF8_STRING", False);
- text_atom = XInternAtom(display, "TEXT", False);
+ targets[TARGETS_ATOM] = XInternAtom(display, "TARGETS", False);
+ targets[TIMESTAMP_ATOM] = XInternAtom(display, "TIMESTAMP", False);
+ targets[COMPOUND_TARGET] = XInternAtom(display, "COMPOUND_TEXT", False);
+ targets[UTF8_TARGET] = XInternAtom(display, "UTF8_STRING", False);
+ targets[TEXT_TARGET] = XInternAtom(display, "TEXT", False);
+ targets[STRING_TARGET] = XA_STRING;
#endif
/* Delete-Window-Message black magic copied from xloadimage. */
proto_atom = XInternAtom(display, "WM_PROTOCOLS", False);
@@ -4094,8 +4104,20 @@
(unsigned long) requestor);
e.xselection.property = None;
}
- else if ((target == XA_STRING) || (target == compound_text_atom) ||
- (target == utf8_text_atom) || (target == text_atom)) {
+ else if (target == targets[TARGETS_ATOM]) {
+ X_printf("X: selection: TARGETS\n");
+ XChangeProperty(display, requestor, property, XA_ATOM, 32,
+ PropModeReplace, (char *)targets, NUM_TARGETS);
+ }
+ else if (target == targets[TIMESTAMP_ATOM]) {
+ X_printf("X: timestamp atom\n");
+ XChangeProperty(display, requestor, property, XA_INTEGER, 32,
+ PropModeReplace, (char *)&e.xselection.time, 1);
+ }
+ else if (target == targets[STRING_TARGET] ||
+ target == targets[COMPOUND_TARGET] ||
+ target == targets[UTF8_TARGET] ||
+ target == targets[TEXT_TARGET]) {
X_printf("X: selection: %s\n",sel_text);
e.xselection.target = target;
XChangeProperty(display, requestor, property, target, 8, PropModeReplace,
@@ -4107,8 +4129,9 @@
else
{
e.xselection.property = None;
- X_printf("X: Window 0x%lx requested unknown selection format %ld\n",
- (unsigned long) requestor, (unsigned long) target);
+ X_printf("X: Window 0x%lx requested unknown selection format %ld %s\n",
+ (unsigned long) requestor, (unsigned long) target,
+ XGetAtomName(display, target));
}
XSendEvent(display, requestor, False, 0, &e);
}