void menuInteractive()
{
    int i, num;
    char buf[255];
    
    while (1) {
        mvprintw (2, 0, "Dvorak7Min, Ragnar Hojland Espinosa, 1998-2003" );
        mvprintw (3, 0, "enhanced by Smoke of CRAP, 1999 and Nopik, 2003");
        for (i = 0; lessons[i*2]; ++i) {
            mvprintw (i/2 + 5, (i%2) * 40, "%2d. %s", i+1, lessons[i*2]);
        }
        move (21, 0); clrtobot();
        mvprintw (21, 0, "Type a lesson number ([N]astiness [H]ide keyboard [Q]uit)? ");
        refresh();
        echo();
        getnstr (buf, sizeof(buf));
        buf[0] = toupper(buf[0]);
        if (buf[0] == 'N') {
            nastiness = !nastiness;
            if (nastiness)
                mvprintw (23, 0, "Nastiness is now turned ON. Press any key.");
            else
                mvprintw (23, 0, "Nastiness is now turned OFF. Press any key.");
            getch();
            continue;
        }

        if (buf[0] == 'H') {
            hideKeys = !hideKeys;
            if (hideKeys)
                mvprintw (23, 0, "Keyboard layout is now OFF. Press any key.");
            else
                mvprintw (23, 0, "Keyboard layout is now ON. Press any key.");
            getch();
            continue;
        }
	
        if (buf[0] == 'Q' || buf[0] == 27) {
            clear();
            move (0,0);
            refresh();
            return;
        }
        num = atoi (buf);
        if (!buf[0] || num < 1 || num > i) {
            mvprintw (23, 0, "Invalid lesson number. Press any key.");
            getch();
            continue;
        }
        
        clear();
        refresh();
        do_text(lessons[(num-1)*2+1]);
    }
}
Example #2
0
/*
 * Given a context, update the window. Out of paranoia, we don't
 * allow WM_PAINT responses to do scrolling optimisations.
 */
static void do_paint (Context ctx, int may_optimise){ 
    int i, j, start, our_curs_y;
    unsigned long attr, rv, cursor;
    char ch[1024];

    cursor = (has_focus ? ATTR_ACTCURS : ATTR_PASCURS);
    rv = (rvideo ? ATTR_REVERSE : 0);
    our_curs_y = curs_y + (scrtop - disptop) / (cols+1);

    for (i=0; i<rows; i++) {
	int idx = i*(cols+1);
	for (j=0; j<=cols; j++,idx++) {
	    unsigned long *d = disptop+idx;
	    wanttext[idx] = ((*d ^ rv
			      ^ (selstart <= d && d < selend ?
				 ATTR_REVERSE : 0)) |
			     (i==our_curs_y && j==curs_x ? cursor : 0));
	}
    }

    /*
     * We would perform scrolling optimisations in here, if they
     * didn't have a nasty tendency to cause the whole sodding
     * program to hang for a second at speed-critical moments.
     * We'll leave it well alone...
     */

    for (i=0; i<rows; i++) {
	int idx = i*(cols+1);
	start = -1;
	for (j=0; j<=cols; j++,idx++) {
	    unsigned long t = wanttext[idx];
	    int needs_update = (j < cols && t != disptext[idx]);
	    int keep_going = (start != -1 && needs_update &&
			      (t & ATTR_MASK) == attr &&
			      j-start < sizeof(ch));
	    if (start != -1 && !keep_going) {
		do_text (ctx, start, i, ch, j-start, attr);
		start = -1;
	    }
	    if (needs_update) {
		if (start == -1) {
		    start = j;
		    attr = t & ATTR_MASK;
		}
		ch[j-start] = (char) (t & CHAR_MASK);
	    }
	    disptext[idx] = t;
	}
    }
}
int playFile(char *filename)
{
   char *buffer;
   int r;
   int len = 0;
   
#ifdef LIMIT_LENGTH
   len = LIMIT_LENGTH;
#endif   
   
   r = importText (filename, &buffer, len);
   if (r <= 0) {
      return -1;
   }

   do_text (buffer);
   return 0;
}
Example #4
0
/*
 * NAME:	cpo->text()
 * DESCRIPTION:	copy an HFS file to a UNIX file using text translation
 */
int cpo_text(hfsvol *vol, const char *srcname, const char *dstname)
{
  const char *ext = 0;
  hfsfile *ifile;
  int ofile, result = 0;

  if (strchr(srcname, '.') == 0)
    ext = ".txt";

  if (openfiles(vol, srcname, dstname, ext, &ifile, &ofile) == -1)
    return -1;

  result = do_text(ifile, ofile);

  closefiles(ifile, ofile, &result);

  return result;
}
Example #5
0
// Handle an inline equation.  Return 1 if it was an inline equation,
// otherwise.
static int inline_equation(FILE *fp, string &linebuf, string &str)
{
  linebuf += '\0';
  char *ptr = &linebuf[0];
  char *start = delim_search(ptr, start_delim);
  if (!start) {
    // It wasn't a delimiter after all.
    linebuf.set_length(linebuf.length() - 1); // strip the '\0'
    return 0;
  }
  start_string();
  inline_flag = 1;
  for (;;) {
    if (no_newline_in_delim_flag && strchr(start + 1, end_delim) == 0) {
      error("missing `%1'", end_delim);
      char *nl = strchr(start + 1, '\n');
      if (nl != 0)
	*nl = '\0';
      do_text(ptr);
      break;
    }
    int start_lineno = current_lineno;
    *start = '\0';
    do_text(ptr);
    ptr = start + 1;
    str.clear();
    for (;;) {
      char *end = strchr(ptr, end_delim);
      if (end != 0) {
	*end = '\0';
	str += ptr;
	ptr = end + 1;
	break;
      }
      str += ptr;
      if (!read_line(fp, &linebuf))
	fatal("unterminated `%1' at line %2, looking for `%3'",
	      start_delim, start_lineno, end_delim);
      linebuf += '\0';
      ptr = &linebuf[0];
    }
    str += '\0';
    if (output_format == troff && html) {
      printf(".as1 %s ", LINE_STRING);
      html_begin_suppress();
      printf("\n");
    }
    init_lex(str.contents(), current_filename, start_lineno);
    yyparse();
    if (output_format == troff && html) {
      printf(".as1 %s ", LINE_STRING);
      html_end_suppress();
      printf("\n");
    }
    if (output_format == mathml)
      printf("\n");
    if (xhtml) {
      /* skip leading spaces */
      while ((*ptr != '\0') && (*ptr == ' '))
	ptr++;
    }
    start = delim_search(ptr, start_delim);
    if (start == 0) {
      char *nl = strchr(ptr, '\n');
      if (nl != 0)
	*nl = '\0';
      do_text(ptr);
      break;
    }
  }
  restore_compatibility();
  if (output_format == troff)
    printf(".lf %d\n", current_lineno);
  output_string();
  if (output_format == troff)
    printf(".lf %d\n", current_lineno + 1);
  return 1;
}