mirror of
https://github.com/HEYAHONG/PDCurses.git
synced 2025-05-08 13:36:23 +08:00
Move extern variables to the pdc_ namespace.
This commit is contained in:
parent
3a2b906a25
commit
6189c976a7
@ -74,7 +74,7 @@ static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
|
||||
{
|
||||
PDC_LOG(("_convert_proc() - called\n"));
|
||||
|
||||
if (*target == XA_TARGETS(XtDisplay(topLevel)))
|
||||
if (*target == XA_TARGETS(XtDisplay(pdc_toplevel)))
|
||||
{
|
||||
XSelectionRequestEvent *req = XtGetSelectionRequest(w,
|
||||
*selection, (XtRequestId)NULL);
|
||||
@ -83,7 +83,7 @@ static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
|
||||
XPointer std_targets;
|
||||
unsigned long std_length;
|
||||
|
||||
XmuConvertStandardSelection(topLevel, req->time, selection,
|
||||
XmuConvertStandardSelection(pdc_toplevel, req->time, selection,
|
||||
target, type_return, &std_targets,
|
||||
&std_length, format_return);
|
||||
|
||||
@ -92,7 +92,7 @@ static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
|
||||
|
||||
targetP = *(Atom**)value_return;
|
||||
*targetP++ = XA_STRING;
|
||||
*targetP++ = XA_UTF8_STRING(XtDisplay(topLevel));
|
||||
*targetP++ = XA_UTF8_STRING(XtDisplay(pdc_toplevel));
|
||||
|
||||
memmove((void *)targetP, (const void *)std_targets,
|
||||
sizeof(Atom) * std_length);
|
||||
@ -103,7 +103,7 @@ static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
|
||||
|
||||
return True;
|
||||
}
|
||||
else if (*target == XA_UTF8_STRING(XtDisplay(topLevel)) ||
|
||||
else if (*target == XA_UTF8_STRING(XtDisplay(pdc_toplevel)) ||
|
||||
*target == XA_STRING)
|
||||
{
|
||||
char *data = XtMalloc(tmpsel_length + 1);
|
||||
@ -123,7 +123,7 @@ static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
|
||||
return True;
|
||||
}
|
||||
else
|
||||
return XmuConvertStandardSelection(topLevel, CurrentTime,
|
||||
return XmuConvertStandardSelection(pdc_toplevel, CurrentTime,
|
||||
selection, target, type_return, (XPointer*)value_return,
|
||||
length_return, format_return);
|
||||
}
|
||||
@ -163,9 +163,9 @@ int PDC_getclipboard(char **contents, long *length)
|
||||
xc_selection = NULL;
|
||||
xc_selection_len = -1;
|
||||
|
||||
XtGetSelectionValue(topLevel, XA_PRIMARY,
|
||||
XtGetSelectionValue(pdc_toplevel, XA_PRIMARY,
|
||||
#ifdef PDC_WIDE
|
||||
XA_UTF8_STRING(XtDisplay(topLevel)),
|
||||
XA_UTF8_STRING(XtDisplay(pdc_toplevel)),
|
||||
#else
|
||||
XA_STRING,
|
||||
#endif
|
||||
@ -173,7 +173,7 @@ int PDC_getclipboard(char **contents, long *length)
|
||||
|
||||
while (-1 == xc_selection_len)
|
||||
{
|
||||
XtAppNextEvent(app_context, &event);
|
||||
XtAppNextEvent(pdc_app_context, &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ int PDC_setclipboard(const char *contents, long length)
|
||||
tmpsel_length = length;
|
||||
tmpsel[length] = 0;
|
||||
|
||||
if (XtOwnSelection(topLevel, XA_PRIMARY, CurrentTime,
|
||||
if (XtOwnSelection(pdc_toplevel, XA_PRIMARY, CurrentTime,
|
||||
_convert_proc, _lose_ownership, NULL) == False)
|
||||
{
|
||||
status = PDC_CLIP_ACCESS_ERROR;
|
||||
|
@ -45,16 +45,17 @@ chtype acs_map[128] =
|
||||
|
||||
#endif
|
||||
|
||||
bool visible_cursor = FALSE;
|
||||
bool vertical_cursor = FALSE;
|
||||
bool pdc_blinked_off;
|
||||
bool pdc_visible_cursor = FALSE;
|
||||
bool pdc_vertical_cursor = FALSE;
|
||||
|
||||
/* Convert character positions x and y to pixel positions, stored in
|
||||
xpos and ypos */
|
||||
|
||||
static void _make_xy(int x, int y, int *xpos, int *ypos)
|
||||
{
|
||||
*xpos = x * font_width;
|
||||
*ypos = xc_app_data.normalFont->ascent + (y * font_height);
|
||||
*xpos = x * pdc_fwidth;
|
||||
*ypos = pdc_app_data.normalFont->ascent + (y * pdc_fheight);
|
||||
}
|
||||
|
||||
static void _set_cursor_color(chtype *ch, short *fore, short *back)
|
||||
@ -118,15 +119,15 @@ static void _display_cursor(int old_row, int old_x, int new_row, int new_x)
|
||||
ch = curscr->_y[new_row] + new_x;
|
||||
_set_cursor_color(ch, &fore, &back);
|
||||
|
||||
if (vertical_cursor)
|
||||
if (pdc_vertical_cursor)
|
||||
{
|
||||
XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
|
||||
XSetForeground(XCURSESDISPLAY, pdc_cursor_gc, pdc_color[back]);
|
||||
|
||||
for (i = 1; i <= SP->visibility; i++)
|
||||
XDrawLine(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
|
||||
xpos + i, ypos - xc_app_data.normalFont->ascent,
|
||||
xpos + i, ypos - xc_app_data.normalFont->ascent +
|
||||
font_height - 1);
|
||||
XDrawLine(XCURSESDISPLAY, XCURSESWIN, pdc_cursor_gc,
|
||||
xpos + i, ypos - pdc_app_data.normalFont->ascent,
|
||||
xpos + i, ypos - pdc_app_data.normalFont->ascent +
|
||||
pdc_fheight - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -136,18 +137,18 @@ static void _display_cursor(int old_row, int old_x, int new_row, int new_x)
|
||||
|
||||
if (SP->visibility == 2)
|
||||
{
|
||||
yp = ypos - font_height + font_descent;
|
||||
yh = font_height;
|
||||
yp = ypos - pdc_fheight + pdc_fdescent;
|
||||
yh = pdc_fheight;
|
||||
}
|
||||
else
|
||||
{
|
||||
yp = ypos - font_height / 4 + font_descent;
|
||||
yh = font_height / 4;
|
||||
yp = ypos - pdc_fheight / 4 + pdc_fdescent;
|
||||
yh = pdc_fheight / 4;
|
||||
}
|
||||
|
||||
XSetFunction(XCURSESDISPLAY, rect_cursor_gc, GXinvert);
|
||||
XFillRectangle(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
|
||||
xpos, yp, font_width, yh);
|
||||
XSetFunction(XCURSESDISPLAY, pdc_cursor_gc, GXinvert);
|
||||
XFillRectangle(XCURSESDISPLAY, XCURSESWIN, pdc_cursor_gc,
|
||||
xpos, yp, pdc_fwidth, yh);
|
||||
}
|
||||
|
||||
PDC_LOG(("_display_cursor() - draw cursor at row %d col %d\n",
|
||||
@ -167,7 +168,7 @@ void XC_blink_text(XtPointer unused, XtIntervalId *id)
|
||||
|
||||
PDC_LOG(("XC_blink_text() - called:\n"));
|
||||
|
||||
blinked_off = !blinked_off;
|
||||
pdc_blinked_off = !pdc_blinked_off;
|
||||
|
||||
/* Redraw changed lines on the screen to match the blink state */
|
||||
|
||||
@ -190,22 +191,22 @@ void XC_blink_text(XtPointer unused, XtIntervalId *id)
|
||||
|
||||
XC_redraw_cursor();
|
||||
|
||||
if ((SP->termattrs & A_BLINK) || !blinked_off)
|
||||
XtAppAddTimeOut(app_context, xc_app_data.textBlinkRate,
|
||||
if ((SP->termattrs & A_BLINK) || !pdc_blinked_off)
|
||||
XtAppAddTimeOut(pdc_app_context, pdc_app_data.textBlinkRate,
|
||||
XC_blink_text, NULL);
|
||||
}
|
||||
|
||||
static void _toggle_cursor(void)
|
||||
{
|
||||
PDC_LOG(("_toggle_cursor - called. Vis now: "));
|
||||
PDC_LOG((visible_cursor ? "1\n" : "0\n"));
|
||||
PDC_LOG((pdc_visible_cursor ? "1\n" : "0\n"));
|
||||
|
||||
/* If the window is not active, ignore this command. The
|
||||
cursor will stay solid. */
|
||||
|
||||
if (window_entered)
|
||||
if (pdc_window_entered)
|
||||
{
|
||||
if (visible_cursor)
|
||||
if (pdc_visible_cursor)
|
||||
{
|
||||
/* Cursor currently ON, turn it off */
|
||||
|
||||
@ -213,14 +214,14 @@ static void _toggle_cursor(void)
|
||||
SP->visibility = 0;
|
||||
XC_redraw_cursor();
|
||||
SP->visibility = save_visibility;
|
||||
visible_cursor = FALSE;
|
||||
pdc_visible_cursor = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Cursor currently OFF, turn it on */
|
||||
|
||||
XC_redraw_cursor();
|
||||
visible_cursor = TRUE;
|
||||
pdc_visible_cursor = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,7 +236,7 @@ int PDC_display_cursor(int oldrow, int oldcol, int newrow, int newcol,
|
||||
_toggle_cursor();
|
||||
else
|
||||
{
|
||||
visible_cursor = TRUE;
|
||||
pdc_visible_cursor = TRUE;
|
||||
_display_cursor(oldrow, oldcol, newrow, newcol);
|
||||
}
|
||||
|
||||
@ -247,7 +248,7 @@ void XC_blink_cursor(XtPointer unused, XtIntervalId *id)
|
||||
PDC_LOG(("XC_blink_cursor() - called:\n"));
|
||||
|
||||
_toggle_cursor();
|
||||
XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
|
||||
XtAppAddTimeOut(pdc_app_context, pdc_app_data.cursorBlinkRate,
|
||||
XC_blink_cursor, NULL);
|
||||
}
|
||||
|
||||
@ -295,33 +296,33 @@ static int _new_packet(chtype attr, int len, int col, int row,
|
||||
/* Determine which GC to use - normal, italic or bold */
|
||||
|
||||
if ((attr & A_ITALIC) && (sysattrs & A_ITALIC))
|
||||
gc = italic_gc;
|
||||
gc = pdc_italic_gc;
|
||||
else if ((attr & A_BOLD) && (sysattrs & A_BOLD))
|
||||
gc = bold_gc;
|
||||
gc = pdc_bold_gc;
|
||||
else
|
||||
gc = normal_gc;
|
||||
gc = pdc_normal_gc;
|
||||
|
||||
_make_xy(col, row, &xpos, &ypos);
|
||||
|
||||
bounds.x = xpos;
|
||||
bounds.y = ypos - font_ascent;
|
||||
bounds.width = font_width * len;
|
||||
bounds.height = font_height;
|
||||
bounds.y = ypos - pdc_fascent;
|
||||
bounds.width = pdc_fwidth * len;
|
||||
bounds.height = pdc_fheight;
|
||||
|
||||
XSetClipRectangles(XCURSESDISPLAY, gc, 0, 0, &bounds, 1, Unsorted);
|
||||
|
||||
if (blinked_off && (sysattrs & A_BLINK) && (attr & A_BLINK))
|
||||
if (pdc_blinked_off && (sysattrs & A_BLINK) && (attr & A_BLINK))
|
||||
{
|
||||
XSetForeground(XCURSESDISPLAY, gc, colors[rev ? fore : back]);
|
||||
XSetForeground(XCURSESDISPLAY, gc, pdc_color[rev ? fore : back]);
|
||||
XFillRectangle(XCURSESDISPLAY, XCURSESWIN, gc, xpos, bounds.y,
|
||||
bounds.width, font_height);
|
||||
bounds.width, pdc_fheight);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Draw it */
|
||||
|
||||
XSetForeground(XCURSESDISPLAY, gc, colors[rev ? back : fore]);
|
||||
XSetBackground(XCURSESDISPLAY, gc, colors[rev ? fore : back]);
|
||||
XSetForeground(XCURSESDISPLAY, gc, pdc_color[rev ? back : fore]);
|
||||
XSetBackground(XCURSESDISPLAY, gc, pdc_color[rev ? fore : back]);
|
||||
|
||||
#ifdef PDC_WIDE
|
||||
XDrawImageString16(
|
||||
@ -337,26 +338,26 @@ static int _new_packet(chtype attr, int len, int col, int row,
|
||||
int k;
|
||||
|
||||
if (SP->line_color != -1)
|
||||
XSetForeground(XCURSESDISPLAY, gc, colors[SP->line_color]);
|
||||
XSetForeground(XCURSESDISPLAY, gc, pdc_color[SP->line_color]);
|
||||
|
||||
if (attr & A_UNDERLINE)
|
||||
XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
|
||||
xpos, ypos + 1, xpos + font_width * len, ypos + 1);
|
||||
xpos, ypos + 1, xpos + pdc_fwidth * len, ypos + 1);
|
||||
|
||||
if (attr & A_LEFT)
|
||||
for (k = 0; k < len; k++)
|
||||
{
|
||||
int x = xpos + font_width * k;
|
||||
int x = xpos + pdc_fwidth * k;
|
||||
XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
|
||||
x, ypos - font_ascent, x, ypos + font_descent);
|
||||
x, ypos - pdc_fascent, x, ypos + pdc_fdescent);
|
||||
}
|
||||
|
||||
if (attr & A_RIGHT)
|
||||
for (k = 0; k < len; k++)
|
||||
{
|
||||
int x = xpos + font_width * (k + 1) - 1;
|
||||
int x = xpos + pdc_fwidth * (k + 1) - 1;
|
||||
XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
|
||||
x, ypos - font_ascent, x, ypos + font_descent);
|
||||
x, ypos - pdc_fascent, x, ypos + pdc_fdescent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
x11/pdckbd.c
43
x11/pdckbd.c
@ -161,7 +161,7 @@ static struct
|
||||
static KeySym keysym = 0;
|
||||
static XIM Xim = NULL;
|
||||
|
||||
XIC Xic = NULL;
|
||||
XIC pdc_xic = NULL;
|
||||
|
||||
#ifdef MOUSE_DEBUG
|
||||
# define MOUSE_LOG(x) printf x
|
||||
@ -228,7 +228,7 @@ static unsigned long _process_key_event(XEvent *event)
|
||||
|
||||
buffer[0] = '\0';
|
||||
|
||||
count = XwcLookupString(Xic, &(event->xkey), buffer, buflen,
|
||||
count = XwcLookupString(pdc_xic, &(event->xkey), buffer, buflen,
|
||||
&keysym, &status);
|
||||
|
||||
/* translate keysym into curses key code */
|
||||
@ -352,8 +352,8 @@ static unsigned long _process_mouse_event(XEvent *event)
|
||||
|
||||
SP->mouse_status.changes = 0;
|
||||
|
||||
SP->mouse_status.x = event->xbutton.x / font_width;
|
||||
SP->mouse_status.y = event->xbutton.y / font_height;
|
||||
SP->mouse_status.x = event->xbutton.x / pdc_fwidth;
|
||||
SP->mouse_status.y = event->xbutton.y / pdc_fheight;
|
||||
|
||||
switch(event->type)
|
||||
{
|
||||
@ -396,16 +396,16 @@ static unsigned long _process_mouse_event(XEvent *event)
|
||||
SP->mouse_status.button[button_no - 1] = BUTTON_PRESSED;
|
||||
|
||||
napms(SP->mouse_wait);
|
||||
while (XtAppPending(app_context))
|
||||
while (XtAppPending(pdc_app_context))
|
||||
{
|
||||
XEvent rel;
|
||||
XtAppNextEvent(app_context, &rel);
|
||||
XtAppNextEvent(pdc_app_context, &rel);
|
||||
|
||||
if (rel.type == ButtonRelease && rel.xbutton.button == button_no)
|
||||
SP->mouse_status.button[button_no - 1] = BUTTON_CLICKED;
|
||||
else
|
||||
XSendEvent(XtDisplay(topLevel),
|
||||
RootWindowOfScreen(XtScreen(topLevel)),
|
||||
XSendEvent(XtDisplay(pdc_toplevel),
|
||||
RootWindowOfScreen(XtScreen(pdc_toplevel)),
|
||||
True, 0, &rel);
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ static unsigned long _process_mouse_event(XEvent *event)
|
||||
case MotionNotify:
|
||||
MOUSE_LOG(("\nMotionNotify: y: %d x: %d Width: %d "
|
||||
"Height: %d\n", event->xbutton.y, event->xbutton.x,
|
||||
font_width, font_height));
|
||||
pdc_fwidth, pdc_fheight));
|
||||
|
||||
button_no = last_button_no;
|
||||
|
||||
@ -465,11 +465,11 @@ static unsigned long _process_mouse_event(XEvent *event)
|
||||
|
||||
bool PDC_check_key(void)
|
||||
{
|
||||
XtInputMask s = XtAppPending(app_context);
|
||||
XtInputMask s = XtAppPending(pdc_app_context);
|
||||
|
||||
PDC_LOG(("PDC_check_key() - returning %s\n", s ? "TRUE" : "FALSE"));
|
||||
|
||||
return xc_resize_now || !!s;
|
||||
return pdc_resize_now || !!s;
|
||||
}
|
||||
|
||||
/* return the next available key or mouse event */
|
||||
@ -480,14 +480,14 @@ int PDC_get_key(void)
|
||||
unsigned long newkey = 0;
|
||||
int key = 0;
|
||||
|
||||
if (xc_resize_now)
|
||||
if (pdc_resize_now)
|
||||
{
|
||||
xc_resize_now = FALSE;
|
||||
pdc_resize_now = FALSE;
|
||||
SP->key_code = TRUE;
|
||||
return KEY_RESIZE;
|
||||
}
|
||||
|
||||
XtAppNextEvent(app_context, &event);
|
||||
XtAppNextEvent(pdc_app_context, &event);
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
@ -557,24 +557,25 @@ int XC_kb_setup(void)
|
||||
|
||||
if (Xim)
|
||||
{
|
||||
Xic = XCreateIC(Xim, XNInputStyle,
|
||||
XIMPreeditNothing | XIMStatusNothing,
|
||||
XNClientWindow, XCURSESWIN, NULL);
|
||||
pdc_xic = XCreateIC(Xim, XNInputStyle,
|
||||
XIMPreeditNothing | XIMStatusNothing,
|
||||
XNClientWindow, XCURSESWIN, NULL);
|
||||
}
|
||||
|
||||
if (Xic)
|
||||
if (pdc_xic)
|
||||
{
|
||||
long im_event_mask;
|
||||
|
||||
XGetICValues(Xic, XNFilterEvents, &im_event_mask, NULL);
|
||||
XGetICValues(pdc_xic, XNFilterEvents, &im_event_mask, NULL);
|
||||
|
||||
/* Add in the mouse events */
|
||||
|
||||
im_event_mask |= ButtonPressMask | ButtonReleaseMask |
|
||||
ButtonMotionMask;
|
||||
|
||||
XtAddEventHandler(drawing, im_event_mask, False, _dummy_handler, NULL);
|
||||
XSetICFocus(Xic);
|
||||
XtAddEventHandler(pdc_drawing, im_event_mask, False,
|
||||
_dummy_handler, NULL);
|
||||
XSetICFocus(pdc_xic);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
228
x11/pdcscrn.c
228
x11/pdcscrn.c
@ -142,23 +142,20 @@ static XrmOptionDescRec options[] =
|
||||
#undef CCOLOR
|
||||
#undef COPT
|
||||
|
||||
Pixel colors[PDC_MAXCOL];
|
||||
Pixel pdc_color[PDC_MAXCOL];
|
||||
|
||||
XCursesAppData xc_app_data;
|
||||
XtAppContext app_context;
|
||||
Widget topLevel, drawing;
|
||||
XCursesAppData pdc_app_data;
|
||||
XtAppContext pdc_app_context;
|
||||
Widget pdc_toplevel, pdc_drawing;
|
||||
|
||||
GC normal_gc, rect_cursor_gc, italic_gc, bold_gc;
|
||||
int font_height, font_width, font_ascent, font_descent;
|
||||
int window_width, window_height;
|
||||
bool blinked_off;
|
||||
|
||||
int resize_window_width = 0, resize_window_height = 0;
|
||||
bool window_entered = TRUE;
|
||||
bool xc_resize_now = FALSE;
|
||||
GC pdc_normal_gc, pdc_cursor_gc, pdc_italic_gc, pdc_bold_gc;
|
||||
int pdc_fheight, pdc_fwidth, pdc_fascent, pdc_fdescent;
|
||||
int pdc_wwidth, pdc_wheight;
|
||||
bool pdc_window_entered = TRUE, pdc_resize_now = FALSE;
|
||||
|
||||
static Atom wm_atom[2];
|
||||
static String class_name = "XCurses";
|
||||
static int resize_window_width = 0, resize_window_height = 0;
|
||||
static int received_map_notify = 0;
|
||||
static bool exposed = FALSE;
|
||||
|
||||
@ -166,8 +163,7 @@ static bool exposed = FALSE;
|
||||
|
||||
static struct {short f, b;} atrtab[PDC_COLOR_PAIRS];
|
||||
|
||||
static Pixmap icon_pixmap;
|
||||
static Pixmap icon_pixmap_mask;
|
||||
static Pixmap icon_pixmap, icon_pixmap_mask;
|
||||
|
||||
/* close the physical screen */
|
||||
|
||||
@ -189,11 +185,11 @@ void PDC_scr_free(void)
|
||||
if (icon_pixmap_mask)
|
||||
XFreePixmap(XCURSESDISPLAY, icon_pixmap_mask);
|
||||
|
||||
XFreeGC(XCURSESDISPLAY, normal_gc);
|
||||
XFreeGC(XCURSESDISPLAY, italic_gc);
|
||||
XFreeGC(XCURSESDISPLAY, bold_gc);
|
||||
XFreeGC(XCURSESDISPLAY, rect_cursor_gc);
|
||||
XDestroyIC(Xic);
|
||||
XFreeGC(XCURSESDISPLAY, pdc_normal_gc);
|
||||
XFreeGC(XCURSESDISPLAY, pdc_italic_gc);
|
||||
XFreeGC(XCURSESDISPLAY, pdc_bold_gc);
|
||||
XFreeGC(XCURSESDISPLAY, pdc_cursor_gc);
|
||||
XDestroyIC(pdc_xic);
|
||||
}
|
||||
|
||||
void XCursesExit(void)
|
||||
@ -205,23 +201,23 @@ static void _initialize_colors(void)
|
||||
{
|
||||
int i, r, g, b;
|
||||
|
||||
colors[COLOR_BLACK] = xc_app_data.colorBlack;
|
||||
colors[COLOR_RED] = xc_app_data.colorRed;
|
||||
colors[COLOR_GREEN] = xc_app_data.colorGreen;
|
||||
colors[COLOR_YELLOW] = xc_app_data.colorYellow;
|
||||
colors[COLOR_BLUE] = xc_app_data.colorBlue;
|
||||
colors[COLOR_MAGENTA] = xc_app_data.colorMagenta;
|
||||
colors[COLOR_CYAN] = xc_app_data.colorCyan;
|
||||
colors[COLOR_WHITE] = xc_app_data.colorWhite;
|
||||
pdc_color[COLOR_BLACK] = pdc_app_data.colorBlack;
|
||||
pdc_color[COLOR_RED] = pdc_app_data.colorRed;
|
||||
pdc_color[COLOR_GREEN] = pdc_app_data.colorGreen;
|
||||
pdc_color[COLOR_YELLOW] = pdc_app_data.colorYellow;
|
||||
pdc_color[COLOR_BLUE] = pdc_app_data.colorBlue;
|
||||
pdc_color[COLOR_MAGENTA] = pdc_app_data.colorMagenta;
|
||||
pdc_color[COLOR_CYAN] = pdc_app_data.colorCyan;
|
||||
pdc_color[COLOR_WHITE] = pdc_app_data.colorWhite;
|
||||
|
||||
colors[COLOR_BLACK + 8] = xc_app_data.colorBoldBlack;
|
||||
colors[COLOR_RED + 8] = xc_app_data.colorBoldRed;
|
||||
colors[COLOR_GREEN + 8] = xc_app_data.colorBoldGreen;
|
||||
colors[COLOR_YELLOW + 8] = xc_app_data.colorBoldYellow;
|
||||
colors[COLOR_BLUE + 8] = xc_app_data.colorBoldBlue;
|
||||
colors[COLOR_MAGENTA + 8] = xc_app_data.colorBoldMagenta;
|
||||
colors[COLOR_CYAN + 8] = xc_app_data.colorBoldCyan;
|
||||
colors[COLOR_WHITE + 8] = xc_app_data.colorBoldWhite;
|
||||
pdc_color[COLOR_BLACK + 8] = pdc_app_data.colorBoldBlack;
|
||||
pdc_color[COLOR_RED + 8] = pdc_app_data.colorBoldRed;
|
||||
pdc_color[COLOR_GREEN + 8] = pdc_app_data.colorBoldGreen;
|
||||
pdc_color[COLOR_YELLOW + 8] = pdc_app_data.colorBoldYellow;
|
||||
pdc_color[COLOR_BLUE + 8] = pdc_app_data.colorBoldBlue;
|
||||
pdc_color[COLOR_MAGENTA + 8] = pdc_app_data.colorBoldMagenta;
|
||||
pdc_color[COLOR_CYAN + 8] = pdc_app_data.colorBoldCyan;
|
||||
pdc_color[COLOR_WHITE + 8] = pdc_app_data.colorBoldWhite;
|
||||
|
||||
#define RGB(R, G, B) ( ((unsigned long)(R) << 16) | \
|
||||
((unsigned long)(G) << 8) | \
|
||||
@ -233,11 +229,11 @@ static void _initialize_colors(void)
|
||||
for (i = 16, r = 0; r < 6; r++)
|
||||
for (g = 0; g < 6; g++)
|
||||
for (b = 0; b < 6; b++)
|
||||
colors[i++] = RGB(r ? r * 40 + 55 : 0,
|
||||
g ? g * 40 + 55 : 0,
|
||||
b ? b * 40 + 55 : 0);
|
||||
pdc_color[i++] = RGB(r ? r * 40 + 55 : 0,
|
||||
g ? g * 40 + 55 : 0,
|
||||
b ? b * 40 + 55 : 0);
|
||||
for (i = 0; i < 24; i++)
|
||||
colors[i + 232] = RGB(i * 10 + 8, i * 10 + 8, i * 10 + 8);
|
||||
pdc_color[i + 232] = RGB(i * 10 + 8, i * 10 + 8, i * 10 + 8);
|
||||
|
||||
#undef RGB
|
||||
}
|
||||
@ -248,30 +244,30 @@ static void _get_icon(void)
|
||||
|
||||
PDC_LOG(("_get_icon() - called\n"));
|
||||
|
||||
if (xc_app_data.pixmap && xc_app_data.pixmap[0]) /* supplied pixmap */
|
||||
if (pdc_app_data.pixmap && pdc_app_data.pixmap[0]) /* supplied pixmap */
|
||||
{
|
||||
XpmReadFileToPixmap(XtDisplay(topLevel),
|
||||
RootWindowOfScreen(XtScreen(topLevel)),
|
||||
(char *)xc_app_data.pixmap,
|
||||
XpmReadFileToPixmap(XtDisplay(pdc_toplevel),
|
||||
RootWindowOfScreen(XtScreen(pdc_toplevel)),
|
||||
(char *)pdc_app_data.pixmap,
|
||||
&icon_pixmap, &icon_pixmap_mask, NULL);
|
||||
}
|
||||
else if (xc_app_data.bitmap && xc_app_data.bitmap[0]) /* supplied bitmap */
|
||||
else if (pdc_app_data.bitmap && pdc_app_data.bitmap[0]) /* bitmap */
|
||||
{
|
||||
unsigned file_bitmap_width = 0, file_bitmap_height = 0;
|
||||
int x_hot = 0, y_hot = 0;
|
||||
|
||||
rc = XReadBitmapFile(XtDisplay(topLevel),
|
||||
RootWindowOfScreen(XtScreen(topLevel)),
|
||||
(char *)xc_app_data.bitmap,
|
||||
rc = XReadBitmapFile(XtDisplay(pdc_toplevel),
|
||||
RootWindowOfScreen(XtScreen(pdc_toplevel)),
|
||||
(char *)pdc_app_data.bitmap,
|
||||
&file_bitmap_width, &file_bitmap_height,
|
||||
&icon_pixmap, &x_hot, &y_hot);
|
||||
|
||||
if (BitmapOpenFailed == rc)
|
||||
fprintf(stderr, "bitmap file %s: not found\n",
|
||||
xc_app_data.bitmap);
|
||||
pdc_app_data.bitmap);
|
||||
else if (BitmapFileInvalid == rc)
|
||||
fprintf(stderr, "bitmap file %s: contents invalid\n",
|
||||
xc_app_data.bitmap);
|
||||
pdc_app_data.bitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -280,8 +276,8 @@ static void _get_icon(void)
|
||||
|
||||
icon_size = XAllocIconSize();
|
||||
|
||||
rc = XGetIconSizes(XtDisplay(topLevel),
|
||||
RootWindowOfScreen(XtScreen(topLevel)),
|
||||
rc = XGetIconSizes(XtDisplay(pdc_toplevel),
|
||||
RootWindowOfScreen(XtScreen(pdc_toplevel)),
|
||||
&icon_size, &size_count);
|
||||
|
||||
/* if the WM can advise on icon sizes... */
|
||||
@ -312,8 +308,8 @@ static void _get_icon(void)
|
||||
|
||||
XFree(icon_size);
|
||||
|
||||
XpmCreatePixmapFromData(XtDisplay(topLevel),
|
||||
RootWindowOfScreen(XtScreen(topLevel)),
|
||||
XpmCreatePixmapFromData(XtDisplay(pdc_toplevel),
|
||||
RootWindowOfScreen(XtScreen(pdc_toplevel)),
|
||||
(max_width >= 64 && max_height >= 64) ? icon64 : icon32,
|
||||
&icon_pixmap, &icon_pixmap_mask, NULL);
|
||||
}
|
||||
@ -382,13 +378,13 @@ static void _handle_enter_leave(Widget w, XtPointer client_data,
|
||||
case EnterNotify:
|
||||
PDC_LOG(("EnterNotify received\n"));
|
||||
|
||||
window_entered = TRUE;
|
||||
pdc_window_entered = TRUE;
|
||||
break;
|
||||
|
||||
case LeaveNotify:
|
||||
PDC_LOG(("LeaveNotify received\n"));
|
||||
|
||||
window_entered = FALSE;
|
||||
pdc_window_entered = FALSE;
|
||||
|
||||
/* Display the cursor so it stays on while the window is
|
||||
not current */
|
||||
@ -418,7 +414,7 @@ static void _handle_structure_notify(Widget w, XtPointer client_data,
|
||||
resize_window_height = event->xconfigure.height;
|
||||
|
||||
SP->resized = TRUE;
|
||||
xc_resize_now = TRUE;
|
||||
pdc_resize_now = TRUE;
|
||||
break;
|
||||
|
||||
case MapNotify:
|
||||
@ -446,8 +442,8 @@ static void _get_gc(GC *gc, XFontStruct *font_info, int fore, int back)
|
||||
|
||||
XSetFont(XCURSESDISPLAY, *gc, font_info->fid);
|
||||
|
||||
XSetForeground(XCURSESDISPLAY, *gc, colors[fore]);
|
||||
XSetBackground(XCURSESDISPLAY, *gc, colors[back]);
|
||||
XSetForeground(XCURSESDISPLAY, *gc, pdc_color[fore]);
|
||||
XSetBackground(XCURSESDISPLAY, *gc, pdc_color[back]);
|
||||
}
|
||||
|
||||
static void _pointer_setup(void)
|
||||
@ -455,22 +451,22 @@ static void _pointer_setup(void)
|
||||
XColor pointerforecolor, pointerbackcolor;
|
||||
XrmValue rmfrom, rmto;
|
||||
|
||||
XDefineCursor(XCURSESDISPLAY, XCURSESWIN, xc_app_data.pointer);
|
||||
XDefineCursor(XCURSESDISPLAY, XCURSESWIN, pdc_app_data.pointer);
|
||||
rmfrom.size = sizeof(Pixel);
|
||||
rmto.size = sizeof(XColor);
|
||||
|
||||
rmto.addr = (XPointer)&pointerforecolor;
|
||||
rmfrom.addr = (XPointer)&(xc_app_data.pointerForeColor);
|
||||
XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
|
||||
rmfrom.addr = (XPointer)&(pdc_app_data.pointerForeColor);
|
||||
XtConvertAndStore(pdc_drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
|
||||
|
||||
rmfrom.size = sizeof(Pixel);
|
||||
rmto.size = sizeof(XColor);
|
||||
|
||||
rmfrom.addr = (XPointer)&(xc_app_data.pointerBackColor);
|
||||
rmfrom.addr = (XPointer)&(pdc_app_data.pointerBackColor);
|
||||
rmto.addr = (XPointer)&pointerbackcolor;
|
||||
XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
|
||||
XtConvertAndStore(pdc_drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
|
||||
|
||||
XRecolorCursor(XCURSESDISPLAY, xc_app_data.pointer,
|
||||
XRecolorCursor(XCURSESDISPLAY, pdc_app_data.pointer,
|
||||
&pointerforecolor, &pointerbackcolor);
|
||||
}
|
||||
|
||||
@ -508,48 +504,48 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
/* Initialise the top level widget */
|
||||
|
||||
topLevel = XtVaAppInitialize(&app_context, class_name, options,
|
||||
pdc_toplevel = XtVaAppInitialize(&pdc_app_context, class_name, options,
|
||||
XtNumber(options), &argc, argv, NULL, NULL);
|
||||
|
||||
XtVaGetApplicationResources(topLevel, &xc_app_data, app_resources,
|
||||
XtVaGetApplicationResources(pdc_toplevel, &pdc_app_data, app_resources,
|
||||
XtNumber(app_resources), NULL);
|
||||
|
||||
/* Check application resource values here */
|
||||
|
||||
font_width = xc_app_data.normalFont->max_bounds.rbearing -
|
||||
xc_app_data.normalFont->min_bounds.lbearing;
|
||||
pdc_fwidth = pdc_app_data.normalFont->max_bounds.rbearing -
|
||||
pdc_app_data.normalFont->min_bounds.lbearing;
|
||||
|
||||
font_ascent = xc_app_data.normalFont->max_bounds.ascent;
|
||||
font_descent = xc_app_data.normalFont->max_bounds.descent;
|
||||
font_height = font_ascent + font_descent;
|
||||
pdc_fascent = pdc_app_data.normalFont->max_bounds.ascent;
|
||||
pdc_fdescent = pdc_app_data.normalFont->max_bounds.descent;
|
||||
pdc_fheight = pdc_fascent + pdc_fdescent;
|
||||
|
||||
/* Check that the italic font and normal fonts are the same size */
|
||||
|
||||
italic_font_valid = font_width ==
|
||||
xc_app_data.italicFont->max_bounds.rbearing -
|
||||
xc_app_data.italicFont->min_bounds.lbearing;
|
||||
italic_font_valid = pdc_fwidth ==
|
||||
pdc_app_data.italicFont->max_bounds.rbearing -
|
||||
pdc_app_data.italicFont->min_bounds.lbearing;
|
||||
|
||||
bold_font_valid = font_width ==
|
||||
xc_app_data.boldFont->max_bounds.rbearing -
|
||||
xc_app_data.boldFont->min_bounds.lbearing;
|
||||
bold_font_valid = pdc_fwidth ==
|
||||
pdc_app_data.boldFont->max_bounds.rbearing -
|
||||
pdc_app_data.boldFont->min_bounds.lbearing;
|
||||
|
||||
/* Calculate size of display window */
|
||||
|
||||
COLS = xc_app_data.cols;
|
||||
LINES = xc_app_data.lines;
|
||||
COLS = pdc_app_data.cols;
|
||||
LINES = pdc_app_data.lines;
|
||||
|
||||
window_width = font_width * COLS;
|
||||
window_height = font_height * LINES;
|
||||
pdc_wwidth = pdc_fwidth * COLS;
|
||||
pdc_wheight = pdc_fheight * LINES;
|
||||
|
||||
minwidth = font_width * 2;
|
||||
minheight = font_height * 2;
|
||||
minwidth = pdc_fwidth * 2;
|
||||
minheight = pdc_fheight * 2;
|
||||
|
||||
/* Set up the icon for the application; the default is an internal
|
||||
one for PDCurses. Then set various application level resources. */
|
||||
|
||||
_get_icon();
|
||||
|
||||
XtVaSetValues(topLevel, XtNminWidth, minwidth, XtNminHeight,
|
||||
XtVaSetValues(pdc_toplevel, XtNminWidth, minwidth, XtNminHeight,
|
||||
minheight, XtNbaseWidth, 0, XtNbaseHeight, 0,
|
||||
XtNbackground, 0, XtNiconPixmap, icon_pixmap,
|
||||
XtNiconMask, icon_pixmap_mask, NULL);
|
||||
@ -558,24 +554,24 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
if (!XC_scrollbar_init(argv[0]))
|
||||
{
|
||||
drawing = topLevel;
|
||||
pdc_drawing = pdc_toplevel;
|
||||
|
||||
XtVaSetValues(topLevel, XtNwidth, window_width, XtNheight,
|
||||
window_height, XtNwidthInc, font_width, XtNheightInc,
|
||||
font_height, NULL);
|
||||
XtVaSetValues(pdc_toplevel, XtNwidth, pdc_wwidth, XtNheight,
|
||||
pdc_wheight, XtNwidthInc, pdc_fwidth, XtNheightInc,
|
||||
pdc_fheight, NULL);
|
||||
}
|
||||
|
||||
/* Determine text cursor alignment from resources */
|
||||
|
||||
if (!strcmp(xc_app_data.textCursor, "vertical"))
|
||||
vertical_cursor = TRUE;
|
||||
if (!strcmp(pdc_app_data.textCursor, "vertical"))
|
||||
pdc_vertical_cursor = TRUE;
|
||||
|
||||
SP = calloc(1, sizeof(SCREEN));
|
||||
|
||||
SP->lines = LINES;
|
||||
SP->cols = COLS;
|
||||
|
||||
SP->mouse_wait = xc_app_data.clickPeriod;
|
||||
SP->mouse_wait = pdc_app_data.clickPeriod;
|
||||
SP->audible = TRUE;
|
||||
|
||||
SP->termattrs = A_COLOR | A_ITALIC | A_UNDERLINE | A_LEFT | A_RIGHT |
|
||||
@ -583,44 +579,46 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
/* Add Event handlers to the drawing widget */
|
||||
|
||||
XtAddEventHandler(drawing, ExposureMask, False, _handle_expose, NULL);
|
||||
XtAddEventHandler(drawing, StructureNotifyMask, False,
|
||||
XtAddEventHandler(pdc_drawing, ExposureMask, False, _handle_expose, NULL);
|
||||
XtAddEventHandler(pdc_drawing, StructureNotifyMask, False,
|
||||
_handle_structure_notify, NULL);
|
||||
XtAddEventHandler(drawing, EnterWindowMask | LeaveWindowMask, False,
|
||||
XtAddEventHandler(pdc_drawing, EnterWindowMask | LeaveWindowMask, False,
|
||||
_handle_enter_leave, NULL);
|
||||
XtAddEventHandler(topLevel, 0, True, _handle_nonmaskable, NULL);
|
||||
XtAddEventHandler(pdc_toplevel, 0, True, _handle_nonmaskable, NULL);
|
||||
|
||||
/* If there is a cursorBlink resource, start the Timeout event */
|
||||
|
||||
if (xc_app_data.cursorBlinkRate)
|
||||
XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
|
||||
if (pdc_app_data.cursorBlinkRate)
|
||||
XtAppAddTimeOut(pdc_app_context, pdc_app_data.cursorBlinkRate,
|
||||
XC_blink_cursor, NULL);
|
||||
|
||||
XtRealizeWidget(topLevel);
|
||||
XtRealizeWidget(pdc_toplevel);
|
||||
|
||||
/* Handle trapping of the WM_DELETE_WINDOW property */
|
||||
|
||||
wm_atom[0] = XInternAtom(XtDisplay(topLevel), "WM_DELETE_WINDOW", False);
|
||||
wm_atom[0] = XInternAtom(XtDisplay(pdc_toplevel), "WM_DELETE_WINDOW",
|
||||
False);
|
||||
|
||||
XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), wm_atom, 1);
|
||||
XSetWMProtocols(XtDisplay(pdc_toplevel), XtWindow(pdc_toplevel),
|
||||
wm_atom, 1);
|
||||
|
||||
/* Create the Graphics Context for drawing. This MUST be done AFTER
|
||||
the associated widget has been realized. */
|
||||
|
||||
PDC_LOG(("before _get_gc\n"));
|
||||
|
||||
_get_gc(&normal_gc, xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
|
||||
_get_gc(&pdc_normal_gc, pdc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
|
||||
|
||||
_get_gc(&italic_gc, italic_font_valid ? xc_app_data.italicFont :
|
||||
xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
|
||||
_get_gc(&pdc_italic_gc, italic_font_valid ? pdc_app_data.italicFont :
|
||||
pdc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
|
||||
|
||||
_get_gc(&bold_gc, bold_font_valid ? xc_app_data.boldFont :
|
||||
xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
|
||||
_get_gc(&pdc_bold_gc, bold_font_valid ? pdc_app_data.boldFont :
|
||||
pdc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
|
||||
|
||||
_get_gc(&rect_cursor_gc, xc_app_data.normalFont,
|
||||
_get_gc(&pdc_cursor_gc, pdc_app_data.normalFont,
|
||||
COLOR_WHITE, COLOR_BLACK);
|
||||
|
||||
XSetLineAttributes(XCURSESDISPLAY, rect_cursor_gc, 2,
|
||||
XSetLineAttributes(XCURSESDISPLAY, pdc_cursor_gc, 2,
|
||||
LineSolid, CapButt, JoinMiter);
|
||||
|
||||
/* Set the pointer for the application */
|
||||
@ -634,7 +632,7 @@ int PDC_scr_open(int argc, char **argv)
|
||||
{
|
||||
XEvent event;
|
||||
|
||||
XtAppNextEvent(app_context, &event);
|
||||
XtAppNextEvent(pdc_app_context, &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
|
||||
@ -667,15 +665,15 @@ int PDC_resize_screen(int nlines, int ncols)
|
||||
if (nlines || ncols || !SP->resized)
|
||||
return ERR;
|
||||
|
||||
SP->lines = resize_window_height / font_height;
|
||||
SP->lines = resize_window_height / pdc_fheight;
|
||||
|
||||
LINES = SP->lines - SP->linesrippedoff - SP->slklines;
|
||||
|
||||
SP->cols = COLS = resize_window_width / font_width;
|
||||
SP->cols = COLS = resize_window_width / pdc_fwidth;
|
||||
|
||||
window_width = resize_window_width;
|
||||
window_height = resize_window_height;
|
||||
visible_cursor = TRUE;
|
||||
pdc_wwidth = resize_window_width;
|
||||
pdc_wheight = resize_window_height;
|
||||
pdc_visible_cursor = TRUE;
|
||||
|
||||
SP->resized = FALSE;
|
||||
|
||||
@ -725,7 +723,7 @@ int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
Colormap cmap = DefaultColormap(XCURSESDISPLAY,
|
||||
DefaultScreen(XCURSESDISPLAY));
|
||||
|
||||
tmp.pixel = colors[color];
|
||||
tmp.pixel = pdc_color[color];
|
||||
XQueryColor(XCURSESDISPLAY, cmap, &tmp);
|
||||
|
||||
*red = ((double)(tmp.red) * 1000 / 65535) + 0.5;
|
||||
@ -747,7 +745,7 @@ int PDC_init_color(short color, short red, short green, short blue)
|
||||
DefaultScreen(XCURSESDISPLAY));
|
||||
|
||||
if (XAllocColor(XCURSESDISPLAY, cmap, &tmp))
|
||||
colors[color] = tmp.pixel;
|
||||
pdc_color[color] = tmp.pixel;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ void PDC_set_title(const char *title)
|
||||
{
|
||||
PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
|
||||
|
||||
XtVaSetValues(topLevel, XtNtitle, title, NULL);
|
||||
XtVaSetValues(pdc_toplevel, XtNtitle, title, NULL);
|
||||
}
|
||||
|
||||
int PDC_set_blink(bool blinkon)
|
||||
@ -74,8 +74,8 @@ int PDC_set_blink(bool blinkon)
|
||||
if (!(SP->termattrs & A_BLINK))
|
||||
{
|
||||
SP->termattrs |= A_BLINK;
|
||||
blinked_off = FALSE;
|
||||
XtAppAddTimeOut(app_context, xc_app_data.textBlinkRate,
|
||||
pdc_blinked_off = FALSE;
|
||||
XtAppAddTimeOut(pdc_app_context, pdc_app_data.textBlinkRate,
|
||||
XC_blink_text, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,14 @@ void PDC_beep(void)
|
||||
{
|
||||
PDC_LOG(("PDC_beep() - called\n"));
|
||||
|
||||
XBell(XtDisplay(topLevel), 50);
|
||||
XBell(XtDisplay(pdc_toplevel), 50);
|
||||
}
|
||||
|
||||
void PDC_napms(int ms)
|
||||
{
|
||||
PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
|
||||
|
||||
XSync(XtDisplay(topLevel), False);
|
||||
XSync(XtDisplay(pdc_toplevel), False);
|
||||
|
||||
#if defined(HAVE_USLEEP)
|
||||
|
||||
|
29
x11/pdcx11.h
29
x11/pdcx11.h
@ -20,8 +20,8 @@
|
||||
|
||||
#include <Xatom.h>
|
||||
|
||||
#define XCURSESDISPLAY (XtDisplay(drawing))
|
||||
#define XCURSESWIN (XtWindow(drawing))
|
||||
#define XCURSESDISPLAY (XtDisplay(pdc_drawing))
|
||||
#define XCURSESWIN (XtWindow(pdc_drawing))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -59,24 +59,19 @@ typedef struct
|
||||
int textBlinkRate;
|
||||
} XCursesAppData;
|
||||
|
||||
extern Pixel colors[PDC_MAXCOL];
|
||||
extern Pixel pdc_color[PDC_MAXCOL];
|
||||
extern XIC pdc_xic;
|
||||
|
||||
extern XCursesAppData xc_app_data;
|
||||
extern XtAppContext app_context;
|
||||
extern Widget topLevel, drawing;
|
||||
extern XCursesAppData pdc_app_data;
|
||||
extern XtAppContext pdc_app_context;
|
||||
extern Widget pdc_toplevel, pdc_drawing;
|
||||
|
||||
extern GC normal_gc, rect_cursor_gc, italic_gc, bold_gc;
|
||||
extern int font_height, font_width, font_ascent, font_descent;
|
||||
extern int window_width, window_height;
|
||||
extern bool blinked_off;
|
||||
extern GC pdc_normal_gc, pdc_cursor_gc, pdc_italic_gc, pdc_bold_gc;
|
||||
extern int pdc_fheight, pdc_fwidth, pdc_fascent, pdc_fdescent;
|
||||
extern int pdc_wwidth, pdc_wheight;
|
||||
|
||||
extern int resize_window_width, resize_window_height;
|
||||
extern bool window_entered;
|
||||
extern bool xc_resize_now;
|
||||
|
||||
extern XIC Xic;
|
||||
extern bool vertical_cursor;
|
||||
extern bool visible_cursor;
|
||||
extern bool pdc_blinked_off, pdc_window_entered, pdc_resize_now;
|
||||
extern bool pdc_vertical_cursor, pdc_visible_cursor;
|
||||
|
||||
int PDC_display_cursor(int, int, int, int, int);
|
||||
|
||||
|
49
x11/sb.c
49
x11/sb.c
@ -62,9 +62,9 @@ static void _scroll_up_down(Widget w, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
int pixels = (long) call_data;
|
||||
int total_y = SP->sb_total_y * font_height;
|
||||
int viewport_y = SP->sb_viewport_y * font_height;
|
||||
int cur_y = SP->sb_cur_y * font_height;
|
||||
int total_y = SP->sb_total_y * pdc_fheight;
|
||||
int viewport_y = SP->sb_viewport_y * pdc_fheight;
|
||||
int cur_y = SP->sb_cur_y * pdc_fheight;
|
||||
|
||||
/* When pixels is negative, right button pressed, move data down,
|
||||
thumb moves up. Otherwise, left button pressed, pixels positive,
|
||||
@ -80,7 +80,7 @@ static void _scroll_up_down(Widget w, XtPointer client_data,
|
||||
if (cur_y > (total_y - viewport_y))
|
||||
cur_y = total_y - viewport_y;
|
||||
|
||||
SP->sb_cur_y = cur_y / font_height;
|
||||
SP->sb_cur_y = cur_y / pdc_fheight;
|
||||
|
||||
XawScrollbarSetThumb(w, (double)((double)cur_y / (double)total_y),
|
||||
(double)((double)viewport_y / (double)total_y));
|
||||
@ -90,9 +90,9 @@ static void _scroll_left_right(Widget w, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
int pixels = (long) call_data;
|
||||
int total_x = SP->sb_total_x * font_width;
|
||||
int viewport_x = SP->sb_viewport_x * font_width;
|
||||
int cur_x = SP->sb_cur_x * font_width;
|
||||
int total_x = SP->sb_total_x * pdc_fwidth;
|
||||
int viewport_x = SP->sb_viewport_x * pdc_fwidth;
|
||||
int cur_x = SP->sb_cur_x * pdc_fwidth;
|
||||
|
||||
cur_x += pixels;
|
||||
|
||||
@ -104,7 +104,7 @@ static void _scroll_left_right(Widget w, XtPointer client_data,
|
||||
if (cur_x > (total_x - viewport_x))
|
||||
cur_x = total_x - viewport_x;
|
||||
|
||||
SP->sb_cur_x = cur_x / font_width;
|
||||
SP->sb_cur_x = cur_x / pdc_fwidth;
|
||||
|
||||
XawScrollbarSetThumb(w, (double)((double)cur_x / (double)total_x),
|
||||
(double)((double)viewport_x / (double)total_x));
|
||||
@ -153,35 +153,36 @@ static void _thumb_left_right(Widget w, XtPointer client_data,
|
||||
|
||||
bool XC_scrollbar_init(const char *program_name)
|
||||
{
|
||||
if (xc_app_data.scrollbarWidth && sb_started)
|
||||
if (pdc_app_data.scrollbarWidth && sb_started)
|
||||
{
|
||||
scrollBox = XtVaCreateManagedWidget(program_name,
|
||||
scrollBoxWidgetClass, topLevel, XtNwidth,
|
||||
window_width + xc_app_data.scrollbarWidth,
|
||||
XtNheight, window_height + xc_app_data.scrollbarWidth,
|
||||
XtNwidthInc, font_width, XtNheightInc, font_height, NULL);
|
||||
scrollBoxWidgetClass, pdc_toplevel, XtNwidth,
|
||||
pdc_wwidth + pdc_app_data.scrollbarWidth,
|
||||
XtNheight, pdc_wheight + pdc_app_data.scrollbarWidth,
|
||||
XtNwidthInc, pdc_fwidth, XtNheightInc, pdc_fheight, NULL);
|
||||
|
||||
drawing = XtVaCreateManagedWidget(program_name,
|
||||
pdc_drawing = XtVaCreateManagedWidget(program_name,
|
||||
boxWidgetClass, scrollBox, XtNwidth,
|
||||
window_width, XtNheight, window_height, XtNwidthInc,
|
||||
font_width, XtNheightInc, font_height, NULL);
|
||||
pdc_wwidth, XtNheight, pdc_wheight, XtNwidthInc,
|
||||
pdc_fwidth, XtNheightInc, pdc_fheight, NULL);
|
||||
|
||||
scrollVert = XtVaCreateManagedWidget("scrollVert",
|
||||
scrollbarWidgetClass, scrollBox, XtNorientation,
|
||||
XtorientVertical, XtNheight, window_height, XtNwidth,
|
||||
xc_app_data.scrollbarWidth, NULL);
|
||||
XtorientVertical, XtNheight, pdc_wheight, XtNwidth,
|
||||
pdc_app_data.scrollbarWidth, NULL);
|
||||
|
||||
XtAddCallback(scrollVert, XtNscrollProc, _scroll_up_down, drawing);
|
||||
XtAddCallback(scrollVert, XtNjumpProc, _thumb_up_down, drawing);
|
||||
XtAddCallback(scrollVert, XtNscrollProc, _scroll_up_down, pdc_drawing);
|
||||
XtAddCallback(scrollVert, XtNjumpProc, _thumb_up_down, pdc_drawing);
|
||||
|
||||
scrollHoriz = XtVaCreateManagedWidget("scrollHoriz",
|
||||
scrollbarWidgetClass, scrollBox, XtNorientation,
|
||||
XtorientHorizontal, XtNwidth, window_width, XtNheight,
|
||||
xc_app_data.scrollbarWidth, NULL);
|
||||
XtorientHorizontal, XtNwidth, pdc_wwidth, XtNheight,
|
||||
pdc_app_data.scrollbarWidth, NULL);
|
||||
|
||||
XtAddCallback(scrollHoriz, XtNscrollProc, _scroll_left_right,
|
||||
drawing);
|
||||
XtAddCallback(scrollHoriz, XtNjumpProc, _thumb_left_right, drawing);
|
||||
pdc_drawing);
|
||||
XtAddCallback(scrollHoriz, XtNjumpProc, _thumb_left_right,
|
||||
pdc_drawing);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user