int PopDown P((DialogClass n));
void MarkMenu P((char *item, int dlgNr));
int AppendText P((Option *opt, char *s));
+void HighlightText P((Option *opt, int from, int to, Boolean highlight));
void SetColor P((char *colorName, Option *box));
//void ColorChanged P((Widget w, XtPointer data, XEvent *event, Boolean *b));
void SetInsertPos P((Option *opt, int pos));
case 3: // press button 3
pressed = 1;
if(LoadMultiPV(x, y, text, index, &start, &end, currentPV)) {
-#ifdef TODO_GTK
- XawTextSetSelection( w, start, end );
-#endif
highTextStart[currentPV] = start; highTextEnd[currentPV] = end;
+ HighlightText(&engoutOptions[currentPV ? 12 : 5], start, end, TRUE);
}
break;
case -3: // release button 3
pressed = 0;
+ if(highTextStart[currentPV] != highTextEnd[currentPV])
+ HighlightText(&engoutOptions[currentPV ? 12 : 5], highTextStart[currentPV], highTextEnd[currentPV], FALSE);
highTextStart[currentPV] = highTextEnd[currentPV] = 0;
UnLoadPV();
break;
return AppendText(&historyOptions[0], text); // for now ignore bold & color stuff, as Xaw cannot handle that
}
+void
+HighlightMove (int from, int to, Boolean highlight)
+{
+ HighlightText (&historyOptions[0], from, to, highlight);
+}
+
char *historyText;
int
// ------------- low-level front-end actions called by MoveHistory back-end -----------------
-void
-HighlightMove (int from, int to, Boolean highlight)
-{
- if(highlight)
- XawTextSetSelection( historyOptions[0].handle, from, to ); // for lack of a better method, use selection for highighting
-}
-
// the bold argument says 0 = normal, 1 = bold typeface
// the colorNr argument says 0 = font-default, 1 = gray
void
void
HighlightText (Option *opt, int start, int end, Boolean on)
{
+ if(on)
+ XawTextSetSelection( opt->handle, start, end ); // for lack of a better method, use selection for highighting
+ else
+ XawTextSetSelection( opt->handle, 0, 0 );
}
void
if(where < highTextStart[which]) { // [HGM] multiPVdisplay: move highlighting
int len = strlen(text);
highTextStart[which] += len; highTextEnd[which] += len;
-#ifdef TODO_GTK
- XawTextSetSelection( edit, highTextStart[which], highTextEnd[which] );
-#endif
}
}
// ------------- low-level front-end actions called by MoveHistory back-end -----------------
void
-HighlightMove (int from, int to, Boolean highlight)
-{
- static int init = 0;
- static GtkTextIter start, end;
-
- if(!init) {
- init = 1;
- gtk_text_buffer_create_tag(historyOptions[0].handle, "highlight", "background", "yellow", NULL);
- gtk_text_buffer_create_tag(historyOptions[0].handle, "normal", "background", "white", NULL);
- }
- gtk_text_buffer_get_iter_at_offset(historyOptions[0].handle, &start, from);
- gtk_text_buffer_get_iter_at_offset(historyOptions[0].handle, &end, to);
- gtk_text_buffer_apply_tag_by_name(historyOptions[0].handle, highlight ? "highlight" : "normal", &start, &end);
-}
-
-void
ScrollToCurrent (int caretPos)
{
static GtkTextIter iter;
}
}
+void
+HighlightText (Option *opt, int from, int to, Boolean highlight)
+{
+# define INIT 0x8000
+ static GtkTextIter start, end;
+
+ if(!(opt->min & INIT)) {
+ opt->min |= INIT; // each memo its own init flag!
+ gtk_text_buffer_create_tag(opt->handle, "highlight", "background", "yellow", NULL);
+ gtk_text_buffer_create_tag(opt->handle, "normal", "background", "white", NULL);
+ }
+ gtk_text_buffer_get_iter_at_offset(opt->handle, &start, from);
+ gtk_text_buffer_get_iter_at_offset(opt->handle, &end, to);
+ gtk_text_buffer_apply_tag_by_name(opt->handle, highlight ? "highlight" : "normal", &start, &end);
+}
+
static gboolean
MemoEvent(GtkWidget *widget, GdkEvent *event, gpointer gdata)
{ // handle mouse clicks on text widgets that need it