Ejemplo n.º 1
1
void amiga_init (char *dir)
{
  if ((DefaultPubScreen = LockPubScreen (0)) == 0)
    exit (1);
  screen_ratio (DefaultPubScreen);

  char prog_name[256];
  static char font_name[MAXFONTPATH];
  char *font_desc, *name_ptr;
  static WORD pens[] =
  {-1};
  static struct TextAttr font =
  {NULL, 0, FS_NORMAL, 0};
  int window = 0;

  if (Icon == NULL)
  {
    if (GetProgramName (prog_name, 256))
      Icon = GetDiskObject (prog_name);
  }

  if (Icon)
  {
    if (FindToolType (Icon->do_ToolTypes, "WINDOW"))
      window = 1;
    if (font_desc = FindToolType (Icon->do_ToolTypes, "FONT"))
    {
      strcpy (font_name, font_desc);
      if (name_ptr = strrchr (font_name, '/'))
      {
	font.ta_Name = font_name;
	font.ta_YSize = atoi (name_ptr + 1);
	strcpy (name_ptr, ".font");
      }
    }
    if (font.ta_Name)
      Font = OpenDiskFont (&font);
  }
  if (Font == NULL)
  {
    font.ta_Name = "topaz.font";
    font.ta_YSize = 8;
    Font = OpenFont (&font);
  }

  if (window == 0)
  {
    if ((Screen = OpenScreenTags (0,
				  SA_Pens, pens,
				  SA_DisplayID, GetVPModeID (&DefaultPubScreen->ViewPort),
				  SA_Overscan, OSCAN_TEXT,
				  SA_Depth, 2,
				  SA_Type, CUSTOMSCREEN | AUTOSCROLL,
				  SA_Font, &font,
				  SA_Title, TitleBar, TAG_DONE)) == 0)
      exit (1);
  }

  if ((Window = OpenWindowTags (0,
				WA_Left, 0,
				WA_Top, Screen ? 2 : DefaultPubScreen->BarHeight + 1,
				WA_Width, Screen ? Screen->Width : ScreenWidth,
				WA_Height, Screen ? Screen->Height - 2 : ScreenHeight - DefaultPubScreen->BarHeight - 1,
				WA_SmartRefresh, 1,
				WA_NewLookMenus, 1,
				WA_AutoAdjust, 1,
				WA_Borderless, Screen ? 1 : 0,
				WA_Backdrop, Screen ? 1 : 0,
				WA_Activate, 1,
				WA_CloseGadget, Screen ? 0 : 1,
				WA_DragBar, Screen ? 0 : 1,
				WA_DepthGadget, Screen ? 0 : 1,
				WA_SizeGadget, Screen ? 0 : 1,
				WA_SizeBBottom, Screen ? 0 : 1,
				WA_Title, TitleBar,
				WA_ScreenTitle, TitleBar,
				WA_IDCMP, IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_MENUPICK | IDCMP_CLOSEWINDOW | IDCMP_CHANGEWINDOW,
				Screen ? WA_CustomScreen : WA_PubScreen, Screen ? Screen : DefaultPubScreen,
				TAG_DONE)) == 0)
    exit (1);

  ThisProcess = (struct Process *)FindTask(0);
  OldWindowPtr = ThisProcess->pr_WindowPtr;
  ThisProcess->pr_WindowPtr = Window;

  if ((Visual = GetVisualInfo (Window->WScreen, TAG_DONE)) == 0)
    exit (1);
  if ((Menus = CreateMenus (NewMenus, GTMN_NewLookMenus, TRUE, TAG_DONE)) == 0)
    exit (1);
  LayoutMenus (Menus, Visual, GTMN_NewLookMenus, TRUE, TAG_DONE);
  SetMenuStrip (Window, Menus);

  if ((GameReq = alloc_freq (dir)) == 0)
    exit (1);
  if ((SaveReq = alloc_freq (dir)) == 0)
    exit (1);
  if ((ScriptReq = alloc_freq (dir)) == 0)
    exit (1);

  RastPort = Window->RPort;
  SetDrMd (RastPort, JAM2);
  SetAPen (RastPort, 1);
  SetBPen (RastPort, 0);
  SetFont (RastPort, Font);
  DisplayHeight = ((Window->Height - Window->BorderTop - Window->BorderBottom) / RastPort->TxHeight) - 1;
  PreviousHeight = DisplayHeight;

  reset_cursor ();
}
Ejemplo n.º 2
0
void os_printchar (char c)
{
  if (Window == 0)
  {
    if (c == '\r')
      c = '\n';
    fputc (c, stdout);
    return;
  }

  if (c == '\r')
  {
    os_flush ();
    ClipBlit (RastPort,
	      Window->BorderLeft,
	      Window->BorderTop + RastPort->TxHeight,
	      RastPort,
	      Window->BorderLeft,
	      Window->BorderTop,
	      Window->Width - Window->BorderLeft - Window->BorderRight,
	      DisplayHeight * RastPort->TxHeight, 0xC0);
    rect (Window->BorderLeft,
	  Window->BorderTop + DisplayHeight * RastPort->TxHeight,
	  Window->Width - Window->BorderRight - 1,
	  Window->BorderTop + (DisplayHeight + 1) * RastPort->TxHeight - 1, 0);
    reset_cursor ();

    if (scriptfile == NULL)
    {
      if (++MoreCount >= DisplayHeight)
      {
	MoreCount = 0;
	text ("[More]", 6);
	cursor (0);
	get_key (0, -1, 1);
	cursor (0);
	rect (Window->BorderLeft,
	      Window->BorderTop + DisplayHeight * RastPort->TxHeight,
	      Window->Width - Window->BorderRight - 1,
	      Window->BorderTop + (DisplayHeight + 1) * RastPort->TxHeight - 1, 0);
        reset_cursor ();
      }
    }

    return;
  }

  if (isprint(c) == 0)
    return;
  if (TextBufferPtr >= TEXTBUFFER_SIZE)
    os_flush ();
  *(TextBuffer + (TextBufferPtr++)) = c;
}
Ejemplo n.º 3
0
void CLog::activate_prev_file()
{
  set_clock_cursor();
  if ( !clognav->prev_file())
    wow->DisplayError( "File error", "No previous file found");
  reset_cursor();
}
Ejemplo n.º 4
0
void CLog::activate_next_file()
{
  set_clock_cursor();
  if ( !clognav->next_file())
    wow->DisplayError( "File error", "No next file found");
  reset_cursor();
}
Ejemplo n.º 5
0
void erase_window (zword win)
{
    zword y = wp[win].y_pos;
    zword x = wp[win].x_pos;

    if (h_version == V6 && win != cwin && !amiga_screen_model ())
        os_set_colour (lo (wp[win].colour), hi (wp[win].colour));

    if (hi (wp[win].colour) != TRANSPARENT_COLOUR) {

        os_erase_area (y,
                       x,
                       y + wp[win].y_size - 1,
                       x + wp[win].x_size - 1,
                       win);

    }

    if (h_version == V6 && win != cwin && !amiga_screen_model ())
        os_set_colour (lo (cwp->colour), hi (cwp->colour));

    reset_cursor (win);

    wp[win].line_count = 0;

}/* erase_window */
Ejemplo n.º 6
0
/* Refresh the screen without changing the position of lines.  Use this
 * if we've moved and changed text. */
void edit_refresh(void)
{
	filestruct *foo;
	int nlines;

	/* Figure out what maxrows should really be */
	compute_maxrows();

	if (openfile->current->lineno < openfile->edittop->lineno || openfile->current->lineno >= openfile->edittop->lineno + maxrows) {

		DEBUG_LOG("edit_refresh(): line = " << openfile->current->lineno << ", edittop " << openfile->edittop->lineno << " + maxrows " << maxrows);

		/* Make sure the current line is on the screen. */
		edit_update(ISSET(SMOOTH_SCROLL) ? NONE : CENTER);
	}

	foo = openfile->edittop;

	DEBUG_LOG("edit_refresh(): edittop->lineno = " << openfile->edittop->lineno);

	for (nlines = 0; nlines < editwinrows && foo != NULL; nlines++) {
		nlines += update_line(foo, (foo == openfile->current) ? openfile->current_x : 0);
		foo = foo->next;
	}

	for (; nlines < editwinrows; nlines++) {
		blank_line(edit, nlines, 0, COLS);
	}

	reset_cursor();
	wnoutrefresh(edit);
}
Ejemplo n.º 7
0
/*
 * Init
 */
static int
console_init(void)
{
	struct bootinfo *bootinfo;

	machine_bootinfo(&bootinfo);
	cols = bootinfo->video.text_x;
	rows = bootinfo->video.text_y;

	esc_index = 0;
	attrib = 0x0F;

	vram = phys_to_virt((void *)VID_RAM);
	reset_cursor();
#if defined(DEBUG) && defined(CONFIG_DIAG_SCREEN)
	debug_attach(console_puts);
#endif
	tty_init(&console_tty);	/* init data */
	console_tty.t_oproc = console_start;
	console_tty.t_winsize.ws_row = (u_short)rows;
	console_tty.t_winsize.ws_col = (u_short)cols;

	console_dev = tty_attach("console", &console_tty);
	tty_dev = tty_attach("tty", &console_tty);
	ASSERT(tty_dev);

	return 0;
}
Ejemplo n.º 8
0
void WPkg::activate_createpkg()
{
  WItemPkg **itemlist;
  int item_count;
  int sts;

  message( ' ', "");

  sts = wpkgnav->get_select( &itemlist, &item_count);
  if ( EVEN(sts)) {
    message( 'E', "Select a node");
    return;
  }

  for ( int i = 0; i < item_count; i++) {
    if ( typeid( *itemlist[i]) != typeid( WItemPkgNode)) {
      message( 'E', "All selected items are not nodes");
      free( itemlist);
      return;
    }
  }
    
  set_clock_cursor();
  for ( int i = 0; i < item_count; i++) {
    try {
      wb_pkg *pkg = new wb_pkg( ((WItemPkgNode *)itemlist[i])->nodename, false);
      delete pkg;
    }
    catch ( wb_error &e) {
      message(' ', (char *)e.what().c_str());
      reset_cursor();
      free( itemlist);
      return;
    }
    wpkgnav->refresh_node( itemlist[i]);

    char msg[80];
    sprintf( msg, "Package created for node %s", ((WItemPkgNode *)itemlist[i])->nodename);
    message('I', msg);
    flush();
  }
  reset_cursor();
  free( itemlist);
}
Ejemplo n.º 9
0
void split_window (zword height)
{
    zword stat_height = 0;

    flush_buffer ();

    /* Calculate height of status line and upper window */

    if (h_version != V6)
        height *= hi (wp[1].font_size);

    if (h_version <= V3)
        stat_height = hi (wp[7].font_size);

    /* Cursor of upper window mustn't be swallowed by the lower window */

    wp[1].y_cursor += wp[1].y_pos - 1 - stat_height;

    wp[1].y_pos = 1 + stat_height;
    wp[1].y_size = height;

    if ((short) wp[1].y_cursor > (short) wp[1].y_size)
        reset_cursor (1);

    /* Cursor of lower window mustn't be swallowed by the upper window */

    wp[0].y_cursor += wp[0].y_pos - 1 - stat_height - height;

    wp[0].y_pos = 1 + stat_height + height;
    wp[0].y_size = h_screen_height - stat_height - height;

    if ((short) wp[0].y_cursor < 1)
        reset_cursor (0);

    /* Erase the upper window in V3 only */

    if (h_version == V3 && height != 0)
        erase_window (1);

    os_window_height (0, wp[0].y_size);
    os_window_height (1, wp[1].y_size);

}/* split_window */
Ejemplo n.º 10
0
bool_t create_cursor(cursor_t *cursor) {
  bool_t ok = TRUE;
  if( cursor ) {
    cursor->top = 0;
    ok &= create_mem(&cursor->stack, &cursor->stacklen, 
		     sizeof(coff_t), CURSOR_MINSTACK);
    if( ok ) { reset_cursor(cursor); }
    return ok;
  }
  return FALSE;
}
Ejemplo n.º 11
0
bool_t reset_lessui(lessui_t *ui) {
  if( ui ) {
    reset_cursorrep(&ui->cr);
    reset_cursormanager(&ui->cmg);
    reset_cursor(&ui->cursor);
    ui->dirty = TRUE;
    ui->display.flags = 0;
    return TRUE;
  }
  return FALSE;
}
Ejemplo n.º 12
0
bool_t pop_cursor(cursor_t *cursor) {
  if( cursor ) {
    if( cursor->top > 0 ) {
      cursor->top--;
      if( cursor->top == 0 ) {
	reset_cursor(cursor);
      }
      return TRUE;
    } 
  }
  return FALSE;
}
Ejemplo n.º 13
0
static void
relocate_ellipsepoint(F_ellipse *ellipse, int x, int y, int point_num)
{
    double	    dx, dy;

    set_temp_cursor(wait_cursor);
    if (point_num == 0) {	/* starting point is selected  */
	fix_x = ellipse->end.x;
	fix_y = ellipse->end.y;
	/* don't allow coincident start/end points */
	if (ellipse->end.x == x && ellipse->end.y == y)
	    return;
	ellipse->start.x = x;
	ellipse->start.y = y;
    } else {
	fix_x = ellipse->start.x;
	fix_y = ellipse->start.y;
	/* don't allow coincident start/end points */
	if (ellipse->start.x == x && ellipse->start.y == y)
	    return;
	ellipse->end.x = x;
	ellipse->end.y = y;
    }
    cur_angle = ellipse->angle;
    switch (ellipse->type) {
      case T_ELLIPSE_BY_RAD:
	ellipse->radiuses.x = abs(x - fix_x);
	ellipse->radiuses.y = abs(y - fix_y);
	break;
      case T_CIRCLE_BY_RAD:
	dx = fix_x - x;
	dy = fix_y - y;
	ellipse->radiuses.x = round(sqrt(dx * dx + dy * dy));
	ellipse->radiuses.y = ellipse->radiuses.x;
	break;
      case T_ELLIPSE_BY_DIA:
	ellipse->center.x = (fix_x + x) / 2;
	ellipse->center.y = (fix_y + y) / 2;
	ellipse->radiuses.x = abs(ellipse->center.x - fix_x);
	ellipse->radiuses.y = abs(ellipse->center.y - fix_y);
	break;
      case T_CIRCLE_BY_DIA:
	dx = ellipse->center.x = round((fix_x + x) / 2);
	dy = ellipse->center.y = round((fix_y + y) / 2);
	dx -= x;
	dy -= y;
	ellipse->radiuses.x = round(sqrt(dx * dx + dy * dy));
	ellipse->radiuses.y = ellipse->radiuses.x;
	break;
    }
    reset_cursor();
}
Ejemplo n.º 14
0
/* Display a message on the statusbar, and set disable_cursorpos to
 * true, so that the message won't be immediately overwritten if
 * constant cursor position display is on. */
void statusbar(const char *msg, ...)
{
	va_list ap;
	char *bar, *foo;
	size_t start_x;
	bool old_whitespace;

	va_start(ap, msg);

	/* Curses mode is turned off.  If we use wmove() now, it will muck
	 * up the terminal settings.  So we just use vfprintf(). */
	if (isendwin()) {
		vfprintf(stderr, msg, ap);
		va_end(ap);
		return;
	}

	blank_statusbar();

	old_whitespace = ISSET(WHITESPACE_DISPLAY);
	UNSET(WHITESPACE_DISPLAY);
	bar = charalloc(mb_cur_max() * (COLS - 3));
	vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap);
	va_end(ap);
	foo = display_string(bar, 0, COLS - 4, false);
	free(bar);
	if (old_whitespace) {
		SET(WHITESPACE_DISPLAY);
	}
	start_x = (COLS - strlenpt(foo) - 4) / 2;

	wmove(bottomwin, 0, start_x);
	set_color(bottomwin, interface_colors[STATUS_BAR]);
	waddstr(bottomwin, "[ ");
	waddstr(bottomwin, foo);
	free(foo);
	waddstr(bottomwin, " ]");
	clear_color(bottomwin, interface_colors[STATUS_BAR]);
	wnoutrefresh(bottomwin);
	reset_cursor();
	wnoutrefresh(edit);
	/* Leave the cursor at its position in the edit window, not in
	 * the statusbar. */

	disable_cursorpos = true;

	/* If we're doing quick statusbar blanking, and constant cursor
	 * position display is off, blank the statusbar after only one
	 * keystroke.  Otherwise, blank it after twenty-six keystrokes, as
	 * Pico does. */
	statusblank = ISSET(QUICK_BLANK) && !ISSET(CONST_UPDATE) ? 1 : 26;
}
Ejemplo n.º 15
0
/* Check if the number of keystrokes needed to blank the statusbar has
 * been pressed.  If so, blank the statusbar, unless constant cursor
 * position display is on. */
void check_statusblank(void)
{
	if (statusblank > 0) {
		statusblank--;

		if (statusblank == 0 && !ISSET(CONST_UPDATE)) {
			blank_statusbar();
			wnoutrefresh(bottomwin);
			reset_cursor();
			wnoutrefresh(edit);
		}
	}
}
Ejemplo n.º 16
0
void z_window_size (void)
{
    zword win = winarg0 ();

    flush_buffer ();

    wp[win].y_size = zargs[1];
    wp[win].x_size = zargs[2];

    /* Keep the cursor within the window */

    if (wp[win].y_cursor > zargs[1] || wp[win].x_cursor > zargs[2])
        reset_cursor (win);

}/* z_window_size */
Ejemplo n.º 17
0
void popup_browse_panel(Widget w)
{
    char *fval, *pval;

    set_temp_cursor(wait_cursor);
    XtSetSensitive(w, False);
    browse_parent = w;
    browse_up = True;
    file_viewed[0] = '\0';

    if (!browse_popup) {
	get_directory(local_dir);
    } else {
	strcpy(local_dir, cur_browse_dir);
    }

    /* move to the file directory  - if not the current dir
        and set up the file/directory values
    */
    pval = (char*) panel_get_value( pic_name_panel );
    fval = strrchr(pval, '/');
    if ( !fval ) {	/* no path in name so just use name */
      strcpy(browse_filename, pval);
    } else {		/* set us up in the same path as the file */
      strcpy(local_dir, pval);
      strcpy(browse_filename, fval+1);
      local_dir[strlen(pval) - strlen(fval)] = '\0';
      (void) change_directory(local_dir);
    }

    if (!browse_popup) {
	create_browse_panel(w);
    }

    FirstArg(XtNstring, local_dir);
    SetValues(browse_dir);
    FirstArg(XtNstring, browse_filename);
    SetValues(browse_selfile);	

    XtPopup(browse_popup, XtGrabNonexclusive);
    Rescan(0, 0, 0, 0);

    (void) XSetWMProtocols(tool_d, XtWindow(browse_popup), &wm_delete_window, 1);
    /* if the file message window is up add it to the grab */
    file_msg_add_grab();
    set_cmap(XtWindow(browse_popup));  /* ensure most recent cmap is installed */
    reset_cursor();
}
Ejemplo n.º 18
0
static void erase_screen (zword win)
{
    int i;

    os_erase_area (1, 1, h_screen_height, h_screen_width);

    if ((short) win == -1) {
        split_window (0);
        set_window (0);
        reset_cursor (0);
    }

    for (i = 0; i < 8; i++)
        wp[i].line_count = 0;

}/* erase_screen */
Ejemplo n.º 19
0
static void erase_screen (zword win)
{
    int i;

    if (hi (cwp->colour) != TRANSPARENT_COLOUR)
        os_erase_area (1, 1, h_screen_height, h_screen_width, -2);

    if ((short) win == -1) {
        split_window (0);
        set_window (0);
        reset_cursor (0);
    }

    for (i = 0; i < 8; i++)
        wp[i].line_count = 0;

}/* erase_screen */
Ejemplo n.º 20
0
void
splinepoint_deleting(F_spline *spline, F_point *previous_point, F_point *selected_point)
{
    F_point	   *next_point;
    F_sfactor      *s_prev_point, *selected_sfactor;

    next_point = selected_point->next;
    set_temp_cursor(wait_cursor);
    clean_up();
    set_last_prevpoint(previous_point);
    /* delete it and redraw underlying objects */
    list_delete_spline(&objects.splines, spline);
    draw_spline(spline, ERASE);
    redisplay_spline(spline);
    if (previous_point == NULL) {
	    spline->points = next_point;
	if (open_spline(spline)) {
	    selected_sfactor = spline->sfactors->next;
	    spline->sfactors->next = selected_sfactor->next;
	} else {
	    selected_sfactor = spline->sfactors;
	    spline->sfactors = spline->sfactors->next;
	}
    } else {
	previous_point->next = next_point;

	if ((next_point == NULL) && (open_spline(spline)))
	  previous_point = prev_point(spline->points, previous_point);

	s_prev_point = search_sfactor(spline,previous_point);
	selected_sfactor = s_prev_point->next;
	s_prev_point->next = s_prev_point->next->next;
    }

    /* put it back in the list and draw the new spline */
    list_add_spline(&objects.splines, spline);
    /* redraw it and anything on top of it */
    redisplay_spline(spline);
    set_action_object(F_DELETE_POINT, O_SPLINE);
    set_latestspline(spline);
    set_last_selectedpoint(selected_point);
    set_last_selectedsfactor(selected_sfactor);
    set_last_nextpoint(next_point);
    set_modifiedflag();
    reset_cursor();
}
Ejemplo n.º 21
0
void send_gss_error(struct rekey_session *sess, gss_OID mech, int errmaj, int errmin) 
{
  mb_t msgbuf;
  msgbuf=buf_alloc(8);
  if (!msgbuf)
    return;
  buf_setlength(msgbuf, 8);
  do_gss_error(mech, errmaj, errmin, send_gss_error_cb, msgbuf);
  reset_cursor(msgbuf);
  if (buf_putint(msgbuf, ERR_AUTHN) ||
      buf_putint(msgbuf, msgbuf->length - 8)) {
    prtmsg("internal error in send_gss_error, cannot pack message");
    buf_free(msgbuf);
    return;
  }
  sess_send(sess, RESP_ERR, msgbuf);
  buf_free(msgbuf);
}
Ejemplo n.º 22
0
static void
init_flipcompound(F_compound *old_c, int px, int py)
{
    F_compound	   *new_c;

    set_temp_cursor(wait_cursor);
    new_c = copy_compound(old_c);
    flip_compound(new_c, px, py, flip_axis);
    if (copy) {
	add_compound(new_c);
    } else {
	toggle_compoundmarker(old_c);
	draw_compoundelements(old_c, ERASE);
	change_compound(old_c, new_c);
    }
    /* redisplay objects under this object before it was rotated */
    redisplay_compound(old_c);
    /* and this object and any other objects on top */
    redisplay_compound(new_c);
    reset_cursor();
}
Ejemplo n.º 23
0
static void
init_fliparc(F_arc *old_a, int px, int py)
{
    F_arc	   *new_a;

    set_temp_cursor(wait_cursor);
    new_a = copy_arc(old_a);
    flip_arc(new_a, px, py, flip_axis);
    if (copy) {
	add_arc(new_a);
    } else {
	toggle_arcmarker(old_a);
	draw_arc(old_a, ERASE);
	change_arc(old_a, new_a);
    }
    /* redisplay objects under this object before it was rotated */
    redisplay_arc(old_a);
    /* and this arc and any other objects on top */
    redisplay_arc(new_a);
    reset_cursor();
}
Ejemplo n.º 24
0
void erase_window (zword win)
{
    zword y = wp[win].y_pos;
    zword x = wp[win].x_pos;

    if (h_version == V6 && win != cwin && h_interpreter_number != INTERP_AMIGA)
        os_set_colour (lo (wp[win].colour), hi (wp[win].colour));

    os_erase_area (y,
                   x,
                   y + wp[win].y_size - 1,
                   x + wp[win].x_size - 1);

    if (h_version == V6 && win != cwin && h_interpreter_number != INTERP_AMIGA)
        os_set_colour (lo (cwp->colour), hi (cwp->colour));

    reset_cursor (win);

    wp[win].line_count = 0;

}/* erase_window */
Ejemplo n.º 25
0
void
popup_print_panel(Widget w)
{
    char	    buf[30];

    /* turn off Compose key LED */
    setCompLED(0);

    set_temp_cursor(wait_cursor);
    if (print_popup) {
	/* the print popup already exists, but the magnification may have been
	   changed in the export popup */
	sprintf(buf,"%.1f",appres.magnification);
	FirstArg(XtNstring, buf);
	SetValues(print_mag_text);
	/* also the figure size (magnification * bounding_box) */
	print_update_figure_size();
	/* now set the color and name in the background button */
	set_but_col(print_background_panel, export_background_color);
	/* and the background color menu */
	XtDestroyWidget(background_menu);
	background_menu = make_color_popup_menu(print_background_panel,
	    				"Background Color", background_select, 
					NO_TRANSP, INCL_BACKG);
    } else {
	create_print_panel(w);
    }
    XtPopup(print_popup, XtGrabNone);
    /* now that the popup is realized, put in the name of the first printer */
    if (printer_names[0] != NULL) {
	FirstArg(XtNlabel, printer_names[0]);
	SetValues(printer_menu_button);
    }
    /* insure that the most recent colormap is installed */
    set_cmap(XtWindow(print_popup));
    (void) XSetWMProtocols(tool_d, XtWindow(print_popup), &wm_delete_window, 1);
    reset_cursor();

}
Ejemplo n.º 26
0
/* Highlight the current word being replaced or spell checked.  We
 * expect word to have tabs and control characters expanded. */
void do_replace_highlight(bool highlight, const char *word)
{
	size_t y = xplustabs(), word_len = strlenpt(word);

	y = get_page_start(y) + COLS - y;
	/* Now y is the number of columns that we can display on this
	 * line. */

	assert(y > 0);

	if (word_len > y) {
		y--;
	}

	reset_cursor();
	wnoutrefresh(edit);

	if (highlight) {
		wattron(edit, highlight_attribute);
	}

	/* This is so we can show zero-length matches. */
	if (word_len == 0) {
		waddch(edit, ' ');
	} else {
		waddnstr(edit, word, actual_x(word, y));
	}

	if (word_len > y) {
		waddch(edit, '$');
	}

	if (highlight) {
		wattroff(edit, highlight_attribute);
	}
}
Ejemplo n.º 27
0
void Browser::output_formatCB(Widget , XtPointer , XtPointer )
{
#ifdef Comment
UIVDATA *uivdata;
    
    XtVaGetValues(w, XmNuserData, &uivdata, NULL);
    set_watch(uivdata->text);
    if(w == uivdata->ascii_w)
	uivdata->output_format = ASCII;
    else if(w == uivdata->hex8_w)
	uivdata->output_format = HEX8;
    else if(w == uivdata->hex16_w)
	uivdata->output_format = HEX16;
    else if(w == uivdata->hex32_w)
	uivdata->output_format = HEX32;
    else if(w == uivdata->float_w)
	uivdata->output_format = FLOAT;
    else if(w == uivdata->double_w)
	uivdata->output_format = DOUBLE;

    setPageNum(uivdata, uivdata->page_num);
    reset_cursor(uivdata->text);
#endif
}
Ejemplo n.º 28
0
int	core_run_termcap(t_core *core)
{
  int	ret;
  char	buffer[BUF_CAPS_SIZE];

  put_str(PROMPT_1(core->prompt));
  while (!core->shutdown && (ret = read(0, buffer, 3)) > 0)
    {
      clear_buffer_caps(buffer, ret);
      if (key_hook(core, buffer) == FALSE)
	core->buf_caps = str_cat(core->buf_caps, buffer, FREE_LEFT);
      clear_buffer_caps(buffer, BUF_CAPS_SIZE);
      if (!core->shutdown && !reset_cursor(core, 0))
	return (ERROR);
      core->prompt = get_prompt(core);
      if (!core->shutdown)
	put_str(PROMPT_1(core->prompt));
      put_str(core->buf_caps);
    }
  free(core->buf_caps);
  free(core->prompt);
  module_free(core);
  return (NO_ERR);
}
Ejemplo n.º 29
0
void remap_imagecolors(void)
{
    int		    i;

    /* if monochrome, return */
    if (tool_cells <= 2 || appres.monochrome)
	return;

    npixels = 0;

    /* first see if there are enough colorcells for all image colors */
    usenet = False;

    /* see if the total number of colors will fit without using the neural net */
    ncolors = count_colors();
    if (ncolors == 0)
	return;

    put_msg(REMAP_MSG);
    set_temp_cursor(wait_cursor);
    app_flush();

    if (ncolors > appres.max_image_colors) {
	if (appres.DEBUG) 
		fprintf(stderr,"More colors (%d) than allowed (%d), using neural net\n",
				ncolors,appres.max_image_colors);
	ncolors = appres.max_image_colors;
	usenet = True;
    }

    /* if this is the first image, allocate the number of colorcells we need */
    if (num_oldcolors != ncolors) {
	if (num_oldcolors != -1) {
	    unsigned long   pixels[MAX_USR_COLS];
	    for (i=0; i<num_oldcolors; i++)
		pixels[i] = image_cells[i].pixel;
	    if (tool_vclass == PseudoColor)
		XFreeColors(tool_d, tool_cm, pixels, num_oldcolors, 0);
	}
	alloc_imagecolors(ncolors);
	/* hmm, we couldn't get that number of colors anyway; use the net, Luke */
	if (ncolors > avail_image_cols) {
	    usenet = True;
	    if (appres.DEBUG) 
		fprintf(stderr,"More colors (%d) than available (%d), using neural net\n",
				ncolors,avail_image_cols);
	}
	num_oldcolors = avail_image_cols;
	if (avail_image_cols < 2 && ncolors >= 2) {
	    file_msg("Cannot allocate even 2 colors for pictures");
	    reset_cursor();
	    num_oldcolors = -1;
	    reset_cursor();
	    put_msg(REMAP_MSG2);
	    app_flush();
	    return;
	}
    }
    reset_cursor();

    if (usenet) {
	int	stat;
	int	mult = 1;

	/* check if user pressed cancel button (in file preview) */
	if (check_cancel())
	    return;

	/* count total number of pixels in all the pictures */
	npixels = count_pixels();

	/* check if user pressed cancel button */
	if (check_cancel())
	    return;

	/* initialize the neural network */
	/* -1 means can't alloc memory, -2 or more means must have that many times
		as many pixels */
	set_temp_cursor(wait_cursor);
	if ((stat=neu_init(npixels)) <= -2) {
	    mult = -stat;
	    npixels *= mult;
	    /* try again with more pixels */
	    stat = neu_init2(npixels);
	}
	if (stat == -1) {
	    /* couldn't alloc memory for network */
	    fprintf(stderr,"Can't alloc memory for neural network\n");
	    reset_cursor();
	    put_msg(REMAP_MSG2);
	    app_flush();
	    return;
	}
	/* now add all pixels to the samples */
	for (i=0; i<mult; i++)
	    add_all_pixels();

	/* make a new colortable with the optimal colors */
	avail_image_cols = neu_clrtab(avail_image_cols);

	/* now change the color cells with the new colors */
	/* clrtab[][] is the colormap produced by neu_clrtab */
	for (i=0; i<avail_image_cols; i++) {
	    image_cells[i].red   = (unsigned short) clrtab[i][N_RED] << 8;
	    image_cells[i].green = (unsigned short) clrtab[i][N_GRN] << 8;
	    image_cells[i].blue  = (unsigned short) clrtab[i][N_BLU] << 8;
	}
	YStoreColors(tool_cm, image_cells, avail_image_cols);
	reset_cursor();

	/* check if user pressed cancel button */
	if (check_cancel())
	    return;

	/* get the new, mapped indices for the image colormap */
	remap_image_colormap();
    } else {
	/*
	 * Extract the RGB values from the image's colormap and allocate
	 * the appropriate X colormap entries.
	 */
	scol = 0;	/* global color counter */
	set_temp_cursor(wait_cursor);
	extract_cmap();
	for (i=0; i<scol; i++) {
	    image_cells[i].flags = DoRed|DoGreen|DoBlue;
	}
	YStoreColors(tool_cm, image_cells, scol);
	scol = 0;	/* global color counter */
	readjust_cmap();
	if (appres.DEBUG) 
	    fprintf(stderr,"Able to use %d colors without neural net\n",scol);
	reset_cursor();
    }
    put_msg(REMAP_MSG2);
    app_flush();
}
Ejemplo n.º 30
0
//
//  Callbackfunctions from menu entries
//
void WPkg::activate_distribute()
{
  WItemPkg **itemlist;
  int item_count;
  int sts;

  message( ' ', "");

  sts = wpkgnav->get_select( &itemlist, &item_count);
  if ( EVEN(sts)) {
    message( 'E', "Select a node or package");
    return;
  }

  if ( item_count > 1) {
    for ( int i = 0; i < item_count; i++) {
      if ( typeid( *itemlist[i]) != typeid( WItemPkgNode)) {
	message( 'E', "All selected items are not nodes");
	free( itemlist);
	return;
      }
    }
    
    set_clock_cursor();
    for ( int i = 0; i < item_count; i++) {
      try {
	wb_pkg *pkg = new wb_pkg( ((WItemPkgNode *)itemlist[i])->nodename);
	delete pkg;
      }
      catch ( wb_error &e) {
	message(' ', (char *)e.what().c_str());
	reset_cursor();
	free( itemlist);
	return;
      }
      wpkgnav->refresh_node( itemlist[i]);

      char msg[80];
      sprintf( msg, "Distribution successful to %s", ((WItemPkgNode *)itemlist[i])->nodename);
      message('I', msg);
      flush();
    }
    reset_cursor();
    free( itemlist);
  }
  else {
    // One is selected
    if ( typeid( *itemlist[0]) == typeid( WItemPkgNode)) {
      set_clock_cursor();
      try {
	wb_pkg *pkg = new wb_pkg( ((WItemPkgNode *)itemlist[0])->nodename);
	delete pkg;
      }
      catch ( wb_error &e) {
	message(' ', (char *)e.what().c_str());
      }
      wpkgnav->refresh_node( itemlist[0]);

      char msg[80];
      sprintf( msg, "Distribution successful to %s", ((WItemPkgNode *)itemlist[0])->nodename);
      message('I', msg);
      reset_cursor();
    }
    else if ( typeid( *itemlist[0]) == typeid( WItemPkgPackage)) {
      set_clock_cursor();
      wb_pkg::copyPackage( ((WItemPkgPackage *)itemlist[0])->packagename);
      char msg[80];
      sprintf( msg, "Distribution successful of %s", ((WItemPkgPackage *)itemlist[0])->packagename);
      message('I', msg);
      reset_cursor();
    }
    else {
      message( 'E', "Select a node or package");
    }
  }
}