Пример #1
0
/* Draws box and title of the menu. */
static void
draw_menu_frame(const menu_state_t *m)
{
	const size_t title_len = getmaxx(menu_win) - 2*4;
	const char *const suffix = menu_and_view_are_in_sync(m->d, m->view)
	                         ? ""
	                         : replace_home_part(m->d->cwd);
	const char *const at = (suffix[0] == '\0' ? "" : " @ ");
	char *const title = format_str("%s%s%s", m->d->title, at, suffix);

	if(utf8_strsw(title) > title_len)
	{
		const size_t len = utf8_nstrsnlen(title, title_len - 3);
		strcpy(title + len, "...");
	}

	box(menu_win, 0, 0);
	wattron(menu_win, A_BOLD);
	checked_wmove(menu_win, 0, 3);
	wprint(menu_win, " ");
	wprint(menu_win, title);
	wprint(menu_win, " ");
	wattroff(menu_win, A_BOLD);

	free(title);
}
Пример #2
0
void
ui_stat_draw_popup_line(WINDOW *win, const char item[], const char descr[],
		size_t max_width)
{
	char *left, *right, *line;
	const size_t text_width = utf8_strsw(item);
	const size_t win_width = getmaxx(win);
	const int align_columns = (max_width <= win_width/4);
	const char *const fmt = align_columns ? "%-*s  %-*s" : "%-*s  %*s";
	size_t width_left;
	size_t item_width;

	if(text_width >= win_width)
	{
		char *const whole = right_ellipsis(item, win_width, curr_stats.ellipsis);
		wprint(win, whole);
		free(whole);
		return;
	}

	left = right_ellipsis(item, win_width - 3, curr_stats.ellipsis);

	item_width = align_columns ? max_width : utf8_strsw(left);
	width_left = win_width - 2 - MAX(item_width, utf8_strsw(left));

	right = right_ellipsis(descr, width_left, curr_stats.ellipsis);

	line = format_str(fmt, (int)item_width, left, (int)width_left, right);
	free(left);
	free(right);

	wprint(win, line);

	free(line);
}
Пример #3
0
/*
 * Prints a measurement with optional conversion to units 
 */
void utilWprintMeasure(QString &baseMess, Imod *imod, float measure, bool area)
{
  measure *= imod->pixsize;
  if (area)
    measure *= imod->pixsize;
  if (strcmp("pixels", imodUnits(imod)))
    wprint("%s, %g %s%s\n", LATIN1(baseMess), measure, imodUnits(imod), area ? "^2" : "");
  else
    wprint("%s\n", LATIN1(baseMess));
}
Пример #4
0
int reduc_unload( int inout )
{

	struct		mtop 	mt_command;
	char		msg1[1024] = "Unloading Data Input Exabyte tape ...";
	char		msg2[1024] = "Unloading Data Output Exabyte tape ...";
	char		msgd1[1024] = "Closing Input Disc file ...";
	char		msgd2[1024] = "Closing Output Disc File ...";

	char		err[1024] = "*** ERROR *** Unload operation failed";
	int			stor1_off = 2;
	int			stor2_off = 12;
	int			*stor1p;
	int			*stor2p;
	int			*typep;
	int			tapetype_off = 3;

	stor1p = messp + stor1_off;
	stor2p = messp + stor2_off;
	typep  = messp + tapetype_off;
	
	if ( inout == 1 && *stor1p > 0) {
		if (*typep/10 != 3){
	      wprint("%s\n",msg1);
	      mt_command.mt_op = MTOFFL;
	      if (ioctl( *stor1p, MTIOCTOP, &mt_command) == -1) {
	         errprint("%s\n",err);
	         return -1;
			}
		} else {
	      wprint("%s\n",msgd1);
		}
		close ( *stor1p );
  	   *stor1p = 0;
		*typep  = 0*10 + (*typep - (*typep /10)*10);
	}

	if ( inout == 2  && *stor2p > 0) {
		if((*typep - (*typep /10)*10) != 3) {
	      wprint("%s\n",msg2);
	      mt_command.mt_op = MTOFFL;
	      if (ioctl( *stor2p, MTIOCTOP, &mt_command) == -1) {
	         errprint("%s\n",err);
	         return -1;
			}
		} else {
		wprint("%s\n",msgd2);
	}
	close ( *stor2p );
	*stor2p = 0;
	*typep = (*typep/10) * 10;
	}
	return 0;
}
Пример #5
0
int16_t wgetkey (vptype *vp, int16_t x, int16_t y, int16_t font) {
	char tempstr[2];
	int16_t oldclock;
	tempstr [1]=0;

	while (!k_pressed()) {
		oldclock=getclock();
		do {} while (oldclock==getclock());
		cursorchar=(cursorchar&7)+1;
		tempstr[0]=cursorchar;
		wprint (vp,x,y,font,tempstr);
		};
	wprint (vp,x,y,font," ");
	return (k_read());
	};
Пример #6
0
void infname (char *msg, char *fname) {
	fontcolor (&statvp,7,0);
	clearvp (&statvp);
	wprint (&statvp,2,1,1,msg);
	fontcolor (&statvp,2,0);
	winput (&statvp,2,13,1,fname,12);
	};
Пример #7
0
// Entry for hot key copying
void iccCopyContour(void)
{
  if (!sData.dia)
    wprint("\aContour Copy dialog must be open to copy with this hot key.\n");
  else
    sData.dia->apply();
}
Пример #8
0
int offline_stop( )
{
	int		sort_off = 0;
	int		acqs_off = 4;
	int		recc_off = 5;

	int		*sortp;
	int		*engnp;
	int		*acqsp;
	int		*reccp;

	int		*savep;
	int		j;
	FILE	*fp;

	struct	mtop 	mt_command;

	char	msg[1024] = "Number of records accumulated: ";
	char	err1[1024]= "*** ERROR *** Stop of offline_sort failed"; 

	sortp = messp + sort_off;
	acqsp = messp + acqs_off;
	reccp = messp + recc_off;

/* Print number of records read */
	wprint("%s %d\n",msg,*reccp);

/* Stop the offline sorting program */
/* This is done by setting message_box(0) to the value '9' */
	*sortp = 9;

/* Set acq status to stopped */
	*acqsp = 0;  
	return 0;
}
Пример #9
0
/* Draws all components of the mode onto the screen. */
static void
draw_all(const char text[])
{
    int attr;

    /* Clean up everything. */
    werase(menu_win);
    werase(status_bar);

    /* Draw the text. */
    checked_wmove(menu_win, 0, 0);
    wprint(menu_win, text);

    /* Draw status line. */
    attr = cfg.cs.color[CMD_LINE_COLOR].attr;
    wattron(status_bar, COLOR_PAIR(cfg.cs.pair[CMD_LINE_COLOR]) | attr);
    checked_wmove(status_bar, 0, 0);
    mvwprintw(status_bar, 0, 0, "-- More -- %d-%d/%d", curr_vline + 1,
              MIN(nvlines, curr_vline + viewport_height), nvlines);

    /* Inform curses of the changes. */
    wnoutrefresh(menu_win);
    wnoutrefresh(status_bar);

    /* Apply all changes. */
    doupdate();

    was_redraw = 1;
}
Пример #10
0
int offline_start( )
{


    const char	*startsort = "/user/schiller/osloware/bin/startoffsort &";

    int		sort_off = 0;
    int		time_off = 1;
    int		offl_off = 4;
    int		recc_off = 5;
    int		badr_off = 6;
    int		retstat_off = 9;

    int		*sortp;
    int		*timep;
    int             *offlp;
    int		*reccp;
    int		*badrp;
    int		*retstatp;

    char		msg[1024] = "Off-line sorting started ";
    char		err2[1024]= "*** ERROR *** Start of offline_sort failed";

    time_t		*tp;
    time_t		syst;

    tp = (void *) malloc(4);
    syst = time(tp);


    sortp = messp + sort_off;
    timep = messp + time_off;
    offlp = messp + offl_off;
    reccp = messp + recc_off;
    badrp = messp + badr_off;
    retstatp = messp + retstat_off;


    /* Put message box flags to start values */
    *sortp = 0;
    *timep = tp;
    *offlp = 1;
    *reccp = 0;
    *badrp = 0;
    *retstatp = 0;



    /*  Activate the sorting task  (f77) */
    if ( system( startsort ) == -1) {
        errprint("%s\n",err2);
        return -1;
    }

    wprint("%s %s",msg,asctime(localtime(tp)));


    return 0;
}
Пример #11
0
/* DNM 2/7/02: keep it from sending up another window if one is already up */
void imod_quit(void)
{
  int done, err;

  if (imodDebug('T') || (windowKeys && strchr(windowKeys, '2')) ||
      !imod_model_changed(Model)) {
    imod_cleanup_autosave();
    imod_exit(0);
    return;
  }

  done = dia_choice("Save model before quitting?", "Yes", "No", "Cancel");

  switch(done){
  case 1:
          
    if ((err = SaveModel(Model))){
      if (err == IMOD_IO_SAVE_CANCEL)
        break;
      wprint("%s\n", imodIOGetErrorString());
      wprint("Model not saved; quit aborted.\n");
      break;
    }else{
      imod_cleanup_autosave();
      imod_exit(0);
      return;
    }
    break;

  case 2:
    imod_cleanup_autosave();
    /* DNM: It used to make one last autosave and quit, but if the user
       says NO, then just clean up and quit! */
    imod_exit(0);
    return;
    break;

  case 3:
    break;

  default:
    break;
  }
  return;
}
Пример #12
0
/* Takes a message for "puts", adds newline, prints and flushes stderr */
void imodPuts(const char *message)
{
  if (ClipHandler && ClipHandler->disconnectedFromStderr()) {
    wprint("%s\n", message);
    return;
  }
  fprintf(stderr, "%s\n", message);
#ifdef _WIN32
  fflush(stderr);
#endif
}
Пример #13
0
/* Prints item prefixed with a label truncating the item if it's too long.
 * Returns increment for curr_y. */
static int
print_item(const char label[], const char path[], int curr_y)
{
	const int max_width = getmaxx(menu_win) - strlen(label) - 2;
	const size_t print_len = utf8_nstrsnlen(path, max_width);

	mvwaddstr(menu_win, curr_y, 2, label);
	if(path[print_len] == '\0')
	{
		wprint(menu_win, path);
	}
	else
	{
		char path_buf[PATH_MAX];
		copy_str(path_buf, MIN(sizeof(path_buf), print_len + 1), path);
		wprint(menu_win, path_buf);
	}

	return 2;
}
Пример #14
0
/*
 * Open the tumbler window
 */
int xtumOpen(struct ViewInfo *vi)
{
  TumblerStruct *xtum;
     
  xtum = (TumblerStruct *)malloc(sizeof(TumblerStruct));
  if (!xtum)
    return(-1);

  xtum->vi      = vi;
  xtum->zoom    = 1;
  xtum->image   = NULL;
  xtum->slice = xtum->stslice = xtum->bwslice = xtum->count = NULL;
  xtum->highres = 0;
  xtum->tstep = 2.;
  xtum->nx = xtum->ny = xtum->nz = XTUM_SIZE_INI;
  xtum->cx = (int)vi->xmouse;
  xtum->cy = (int)vi->ymouse;
  xtum->cz = (int)(vi->zmouse + 0.5);
  xtum->ms = (int)(sqrt((double)(xtum->nx * xtum->nx + xtum->ny * xtum->ny +
				xtum->nz * xtum->nz)) + 0.9);
  xtum->minval = 0;
  xtum->maxval = 255;
  xtum->locked = 0;
  xtum->bbox   = 0;
  xtum->stereo = 0;
  xtum->plax = 4.0f;
  xtum->alpha = 0.0;
  xtum->beta = 0.0;
  xtum->gamma = 0.0;
  xtum->closing = 0;
     
  xtum->dialog = new TumblerWindow(xtum, App->rgba, 
                                   App->doublebuffer, App->qtEnableDepth,
                                   imodDialogManager.parent(IMOD_IMAGE),
                                   "tumbler window");
  if (!xtum->dialog){
    free(xtum);
    wprint("Error opening tumbler window.");
    return(-1);
  }

  if (!App->rgba)
    xtum->dialog->mGLw->setColormap(*(App->qColormap));

  xtum->dialog->setWindowTitle(imodCaption("3dmod Tumbler"));
  xtum->ctrl = ivwNewControl(vi, xtumDraw_cb, xtumClose_cb, xtumKey_cb, (void *)xtum);
  imodDialogManager.add((QWidget *)xtum->dialog, IMOD_IMAGE, TUMBLER_WINDOW_TYPE, 
                        xtum->ctrl);
  adjustGeometryAndShow((QWidget *)xtum->dialog, IMOD_IMAGE, false);
     
  return(0);
}
Пример #15
0
void winput (vptype *vp, int16_t x, int16_t y, int16_t font, char *text, int16_t maxlen) {
	int16_t key;
	int16_t fontx;
	int16_t templen;
	char tempstr[2];
	int16_t firstflag=1;

	switch (font) {
		case 1: fontx=8; break;			// 8x8
		case 2: fontx=6; break;			// 6x6
		default: fontx=0;
		};
	wprint (vp,x,y,font,text);
	tempstr[1]=0;
	do {
		key=wgetkey (vp,x+fontx*strlen(text),y,font);
		if ((key>=32)&&(key<128)) {
			if (firstflag) {
				firstflag=0;
				while (text[firstflag]!='\0') text [firstflag++]=' ';
				text [firstflag++]=' ';
				text [firstflag]='\0';
				wprint (vp,x,y,font,text);
				text[0]='\0';
				};
			if (strlen (text)<maxlen) {
				templen=strlen(text);
				text [templen]=key;
				text [templen+1]=0;
				tempstr[0]=key;
				wprint (vp,x+fontx*templen,y,font,tempstr);
				};
			}
		else if ((key==k_bs)||(key==k_left)) {
			if (strlen(text)>0) text [strlen(text)-1]=0;
			};
		firstflag=0;
		} while ((key!=enter)&&(key!=escape));
	};
Пример #16
0
/* Prints the leading character of the str to the win window parsing terminal
 * escape sequences. */
static void
print_char_esc(WINDOW *win, const char str[], esc_state *state)
{
    if(str[0] == '\033')
    {
        esc_state_update(state, str);
        wattrset(win, COLOR_PAIR(colmgr_get_pair(state->fg, state->bg)) | state->attrs);
    }
    else
    {
        wprint(win, str);
    }
}
Пример #17
0
int acq_dump( )
{
    const char	*startp = "/Applications/sirius/bin/acq_specdump &";
    char		msg[1024] = "Dumping spectra to disk files ...";
    char		err[1024] = "*** ERROR *** Could not start acq_specdump";

    if ( system( startp ) == -1) {
        errprint("%s\n",err);
        return -1;
    }
    wprint("%s\n",msg);
    return 0;
}
Пример #18
0
Icont *utilAutoNewContour(ImodView *vi, Icont *cont, bool notInPlane, bool timeMismatch,
                          int timeLock, int setSurface, const char *planeText,
                          const char *surfText)
{
  Iobj *obj = imodObjectGet(vi->imod);
  const char *baseMess = "Started a new contour even though last contour had only 1 pt. ";
  if (cont->psize == 1) {
    if (notInPlane && iobjClose(obj->flags))
      wprint("\a%s Use open contours to model across %s.\n", baseMess, planeText);
    else if (notInPlane)
      wprint("\a%s Turn off \"Start new contour at new Z\" to model "
             "across %s.\n", baseMess, planeText);
    else
      wprint("\a%s Set contour time to 0 to model across times.\n", baseMess);
  }
  inputNewContourOrSurface(vi, setSurface, timeLock);
  cont = imodContourGet(vi->imod);
  if (!cont)
    return NULL;
  if (setSurface == INCOS_NEW_SURF)
    wprint("Started new surface # %d due to change in %s\n", cont->surf, surfText);
  return cont;
}
Пример #19
0
Файл: send.c Проект: xTaiChi/lsh
int send_handler(int argc,char **argv){
    int buflen = 0;
    if(uart < 0){
        wprint(cmdwin,"UART don't connect!\n");
        return -1;
    }
    for(int i = 1;i < argc;i++){
        int len = strlen(argv[i]);
        memcpy(outbuf + buflen,argv[i],len);
        buflen += len;
    }
    write(uart,outbuf,buflen);
    return 0;
}
Пример #20
0
// Resize comes in: record size, set viewport, and get new arrays
void TumblerGL::resizeGL( int wdth, int hght )
{
  mTum->width = wdth;
  mTum->height = hght;
  b3dResizeViewportXY(wdth, hght);
  mTum->image   = b3dGetNewCIImageSize(mTum->image, App->depth, wdth, hght);
  if (!mTum->image) {
    wprint("\aInsufficient memory to run this Tumbler window.\n"
           "Please close it\n");
    return;
  }

  mTum->dialog->setSlice(mTum);
}
Пример #21
0
// If a new surface is required, get one; in any case assign newSurf to cont
void utilAssignSurfToCont(ImodView *vi, Iobj *obj, Icont *cont, int newSurf)
{
  if (newSurf != cont->surf) {
    if (newSurf < 0) {
      vi->undo->objectPropChg();
      newSurf = imodel_unused_surface(obj);
      obj->surfsize = B3DMAX(newSurf, obj->surfsize);
      if (newSurf)
        wprint("Started new surface # %d for modeling in this plane\n", newSurf);
    }
    vi->undo->contourPropChg();
    cont->surf = newSurf;
  }
}
Пример #22
0
void
update_stat_window(FileView *view, int lazy_redraw)
{
	int x;
	char *buf;

	if(!cfg.display_statusline)
	{
		return;
	}

	/* Don't redraw anything until :restart command is finished. */
	if(curr_stats.restart_in_progress)
	{
		return;
	}

	ui_stat_job_bar_check_for_updates();

	if(cfg.status_line[0] == '\0')
	{
		update_stat_window_old(view, lazy_redraw);
		return;
	}

	x = getmaxx(stdscr);
	wresize(stat_win, 1, x);
	wbkgdset(stat_win, COLOR_PAIR(cfg.cs.pair[STATUS_LINE_COLOR]) |
			cfg.cs.color[STATUS_LINE_COLOR].attr);

	buf = expand_status_line_macros(view, cfg.status_line);
	buf = break_in_two(buf, getmaxx(stdscr));

	werase(stat_win);
	checked_wmove(stat_win, 0, 0);
	wprint(stat_win, buf);

	if(lazy_redraw)
	{
		wnoutrefresh(stat_win);
	}
	else
	{
		wrefresh(stat_win);
	}

	free(buf);
}
Пример #23
0
// Parse the message, see if it is for us, and save in local variables
bool ImodClipboard::handleMessage()
{
  int newStamp, arg;
  QStringList tmpStrings;
  if (!ImodInfoWin && ImodvClosed)
    return false;

  // get the text from the clipboard
  QClipboard *cb = QApplication::clipboard();
  //cb->setSelectionMode(false);
  QString text = cb->text();
  if (Imod_debug) {
    imodPrintStderr("imodHCM in handleMessage = %s\n", LATIN1(text));
    wprint("handleMessage = %s\n", LATIN1(text));
  }                   

  // Return if text is empty
  if (text.isEmpty())
    return false;

  // Split the string, ignoring multiple spaces, and return false if fewer
  // than 3 elements
  tmpStrings = text.split(" ", QString::SkipEmptyParts);
  if (tmpStrings.count() < 3)
    return false;

  // Return false if this is not our info window ID
  if (tmpStrings[0].toUInt() != ourWindowID())
    return false;

  // If we see the same message again, send the last response again
  newStamp = tmpStrings[1].toInt();
  if (newStamp == sMessageStamp) {
    sendResponse(-1);
    return false;
  }
  sMessageStamp = newStamp;

  // Clear out the list or accumulate it in initial load, then strip ID and stamp
  if (!sInitialLoad)
    sMessageStrings.clear();
  for (arg = 2; arg < tmpStrings.count(); arg++)
    sMessageStrings << tmpStrings[arg];
    
  return true;
}
Пример #24
0
/* Fills job bar with up-to-date content. */
static void
update_job_bar(void)
{
	if(!is_job_bar_visible())
	{
		return;
	}

	werase(job_bar);
	checked_wmove(job_bar, 0, 0);
	wprint(job_bar, format_job_bar());

	wnoutrefresh(job_bar);
	/* Update status_bar after job_bar just to ensure that it owns the cursor.
	 * Don't know a cleaner way of doing this. */
	wnoutrefresh(status_bar);
	doupdate();
}
Пример #25
0
/* Takes fprintf-type arguments and prints to stderr, and flushes on Windows */
void imodPrintStderr(const char *format, ...)
{
  char errorMess[512];
  va_list args;
  va_start(args, format);
  vsprintf(errorMess, format, args);

  // Send to wprint if disconnected from stderr (THIS WILL BE A PROBLEM IF
  // WPRINT IS CHANGED TO SEND TO STDERR!)
  if (ClipHandler && ClipHandler->disconnectedFromStderr()) {
    wprint(errorMess);
    return;
  }
  fprintf(stderr, errorMess);
#ifdef _WIN32
  fflush(stderr);
#endif
}
Пример #26
0
int msg_level1 (int n, int msg, int z) {
	int c;
	char tempstr[4];
	char dest[12];
	char *src1 = "LEVEL ", *src2 = itoa(pl.level, tempstr, 10);
	strcpy(dest, src1);
	strcat(dest, src2);

	switch (msg) {
		case msg_update:
			if (++objs[n].count2==50) objs[n].yd = -8;
			objs[n].y += objs[n].yd;
			if (objs[n].y + 8 < 0) killobj(n); return (1);
		case msg_draw:
			c = random(5) + 10;
			fontcolor (&gamevp, c, -1);
			wprint (&gamevp, objs[n].x, objs[n].y, 1, dest);
		}; return (0);
	};
Пример #27
0
/*
 * Clipboard change event slot and timeout for performing actions
 */
void ImodClipboard::clipboardChanged()
{
  if (Imod_debug) {
    QClipboard *cb = QApplication::clipboard();
    //cb->setSelectionMode(false);
    QString text = cb->text();
    imodPrintStderr("imodHCM in clipboardChanged - clipboard = %s\n", 
                    LATIN1(text));
    if (ImodInfoWin)
      wprint("clipboardChanged = %s\n", LATIN1(text));
  }
  // If already handling a change or the message is not for us, return
  if (mHandling || !handleMessage())
    return;

  // Otherwise create and start a timer to execute the action
  // Set flag because event comes in twice in Windows
  mHandling = true;
  QTimer::singleShot(10, this, SLOT(clipTimeout()));
}
Пример #28
0
int
main ()
{
  /* Initialise handler vector */
  int_init();

  /* Install ethernet interrupt handler, it is enabled here too */
  int_add(ETH0_IRQ, oeth_interrupt, 0);

  ethmac_setup(ETH0_PHY, ETH0_BUF); /* Configure MAC, TX/RX BDs and enable RX and TX in MODER */
  
  wprint("Entering loop\n");
  while (1) { }

  ethmac_halt();
  
  exit(0x8000000d);

  return 0;
}
Пример #29
0
int msg_score (int n, int msg, int z) {
	int c;
	char tempstr[12];
	switch (msg) {
		case msg_update:
			if (objs[n].count==0) {
				pl.score += points;	statmodflg |= mod_screen;
				objs[n].count2 = points; objs[n].count = 1;
				objs[n].xl = strlen(ultoa(points, tempstr, 10))*8;
					if (objs[n].x + objs[n].xl >= scrn_x)
						objs[n].x=scrn_x-objs[n].xl;
				};
			objs[n].x += objs[n].xd; objs[n].y += objs[n].yd;
			if (++objs[n].count3==40) killobj(n); return (1);
		case msg_draw:
			c = random(5) + 10;
			fontcolor (&gamevp, c, -1);
			wprint (&gamevp, objs[n].x, objs[n].y, 1,
			ultoa (objs[n].count2, tempstr, 10));
		}; return (0);
	};
Пример #30
0
void wait (void) {
	int x, y;
	int c,q;

	clrpal (); setpagemode (1);
	for (x=0; x<20; x++) {
		for (y=0; y<12; y++) {
			drawshape (&mainvp,0x7501+x+y*20,x*16,y*16);
			};
		};
	fontcolor (&mainvp,71,-1);
	wprint (&mainvp,168,8,1,"THE SECRET CHAMBER");
//	fontcolor (&mainvp,7,-1);
//	wprint (&mainvp,79,194,2,"-Press Any Key to Continue-");
	pageflip (); setpagemode (0);	fadein ();
	do {
		gamecount++; checkctrl0(0);
		for (c=64; c<80; c++) {
			q=64+((c+gamecount)&15);
			setcolor (c,vgapal[q*3+0],vgapal[q*3+1],vgapal[q*3+2]);
			};
		} while ((key==0)&&(fire1==0)&&(fire2==0)&&(dx1==0)&&(dy1==0));
	};