コード例 #1
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
load_room (void)
{
  load_floor ();
  load_broken_floor ();
  load_skeleton_floor ();
  load_loose_floor ();
  load_opener_floor ();
  load_closer_floor ();
  load_spikes_floor ();
  load_wall ();
  load_pillar ();
  load_big_pillar ();
  load_door ();
  load_level_door ();
  load_chopper ();
  load_bricks ();
  load_torch ();
  load_window ();
  load_balcony ();
  load_arch ();
  load_carpet ();
  load_stars ();
  load_mirror ();
}
コード例 #2
0
ファイル: workshop.c プロジェクト: UTSASRG/DoubleTake
/*ARGSUSED*/
    void
workshop_load_file(
	char	*filename,		/* the file to load */
	int	 line,			/* an optional line number (or 0) */
	char	*frameid)		/* used for multi-frame support */
{
#ifdef WSDEBUG_TRACE
    if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
	wstrace("workshop_load_file(%s, %d)\n", filename, line);
#endif

#ifdef FEAT_BEVAL
    if (balloonEval == NULL)
    {
	/*
	 * Set up the Balloon Expression Evaluation area.
	 * It's enabled by default.  Disable it when 'ballooneval' is off.
	 */
# ifdef FEAT_GUI_GTK
	balloonEval = gui_mch_create_beval_area(gui.drawarea, NULL,
							      &bevalCB, NULL);
# else
	balloonEval = gui_mch_create_beval_area(textArea, NULL, bevalCB, NULL);
# endif
	if (!p_beval)
	    gui_mch_disable_beval_area(balloonEval);
    }
#endif

    load_window(filename, line);
}
コード例 #3
0
ファイル: ff_radial.c プロジェクト: robwink/davinci
Var* ff_radial_symmetry2(vfuncptr func, Var* arg)
{
	Var *obj = NULL, *rval = NULL;
	float ignore = FLT_MIN;
	float* out;
	int x, y, z, i, j;
	int size  = 0;
	int width = 0, height = 0;
	Window* w;

	Alist alist[9];
	alist[0]      = make_alist("object", ID_VAL, NULL, &obj);
	alist[1]      = make_alist("x", DV_INT32, NULL, &width);
	alist[2]      = make_alist("y", DV_INT32, NULL, &height);
	alist[3]      = make_alist("size", DV_INT32, NULL, &size);
	alist[4]      = make_alist("ignore", DV_FLOAT, NULL, &ignore);
	alist[5].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);

	if (obj == NULL) {
		parse_error("%s: No object specified\n", func->name);
		return (NULL);
	}

	if (size) {
		width  = size;
		height = size;
	}

	if (width <= 0 || height <= 0) {
		parse_error("%s: Invalid size specified (%dx%d)\n", func->name, width, height);
		return (NULL);
	}

	x = GetX(obj);
	y = GetY(obj);
	z = GetZ(obj);
	w = create_window(width, height, DV_FLOAT);

	out  = calloc((size_t)x * (size_t)y, sizeof(float));
	rval = newVal(BSQ, x, y, 1, DV_FLOAT, out);

	for (i = 0; i < x; i += 1) {
		load_window(w, obj, i, 0, ignore);
		for (j = 0; j < y; j += 1) {
			if (j) roll_window(w, obj, i, j, ignore);

			out[cpos(i, j, 0, rval)] = radial_symmetry2(w->row, width, height, ignore);
		}
	}

	free_window(w);
	return (rval);
}
コード例 #4
0
ファイル: workshop.c プロジェクト: UTSASRG/DoubleTake
    void
workshop_show_file(
    char	*filename)
{
#ifdef WSDEBUG_TRACE
    if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
	wstrace("workshop_show_file(%s)\n", filename);
#endif

    load_window(filename, 0);
}
コード例 #5
0
ファイル: workshop.c プロジェクト: UTSASRG/DoubleTake
/*
 * Reload the WorkShop buffer
 */
    void
workshop_reload_file(
	char	*filename,
	int	 line)
{
#ifdef WSDEBUG_TRACE
    if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
	wstrace("workshop_reload_file(%s, %d)\n", filename, line);
#endif
    load_window(filename, line);
}
コード例 #6
0
/*ARGSUSED*/
    void
workshop_load_file(
	char	*filename,		/* the file to load */
	int	 line,			/* an optional line number (or 0) */
	char	*frameid)		/* used for multi-frame support */
{
#ifdef WSDEBUG_TRACE
    if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
	wstrace("workshop_load_file(%s, %d)\n", filename, line);
#endif

#ifdef FEAT_BEVAL
    bevalServers |= BEVAL_WORKSHOP;
#endif

    load_window(filename, line);
}
コード例 #7
0
ファイル: ff_median.c プロジェクト: robwink/davinci
Var* ff_local_maximum(vfuncptr func, Var* arg)
{
	Var *obj = NULL, *rval = NULL;
	float ignore = FLT_MIN;
	float* out;
	int x, y, i, j;
	int size        = 3;
	float threshold = FLT_MIN;
	Window* w;

	Alist alist[9];
	alist[0]      = make_alist("object", ID_VAL, NULL, &obj);
	alist[1]      = make_alist("size", DV_INT32, NULL, &size);
	alist[2]      = make_alist("ignore", DV_FLOAT, NULL, &ignore);
	alist[3]      = make_alist("threshold", DV_FLOAT, NULL, &threshold);
	alist[4].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);

	if (obj == NULL) {
		parse_error("%s: No object specified\n", func->name);
		return (NULL);
	}

	x = GetX(obj);
	y = GetY(obj);
	w = create_window(size, size, DV_FLOAT);

	out  = calloc(x * y, sizeof(float));
	rval = newVal(BSQ, x, y, 1, DV_FLOAT, out);

	for (i = 0; i < x; i += 1) {
		load_window(w, obj, i, 0, ignore);
		for (j = 0; j < y; j += 1) {
			if (j) roll_window(w, obj, i, j, ignore);

			out[cpos(i, j, 0, rval)] = local_maximum(w, threshold, ignore);
		}
	}

	free_window(w);
	return (rval);
}
コード例 #8
0
//-----------------------------------------------------------------------------
CE_EXPORT int32_t luaopen_libcrown(lua_State* L)
{
	LuaEnvironment env(L);

	load_vec2(env);
	load_vec3(env);
	load_mat4(env);
	load_quat(env);
	load_math(env);

	load_mouse(env);
	load_keyboard(env);
	load_accelerometer(env);

	load_device(env);

	load_window(env);

	return 1;
}
コード例 #9
0
ファイル: ff_radial.c プロジェクト: robwink/davinci
Var* ff_radial_symmetry3(vfuncptr func, Var* arg)
{
	Var* obj     = NULL;
	float ignore = FLT_MIN;
	int width = 0, height = 0;
	int end   = 1;
	Var* rval = NULL;
	int x, y;
	float* out;
	Window* w;

	int *distance, d;
	int dx, dy;
	double ssxx, ssyy, ssxy;
	int i, j, p, q, r;
	int h2, w2;
	float v1, v2;
	int total;
	float *r1, *r2;
	int start = 0, step = 1;

	struct dstore {
		double sumx;
		double sumy;
		double sumxx;
		double sumyy;
		double sumxy;
		int count;
	} * accum, *a1, *a2;

	Alist alist[6];
	alist[0]      = make_alist("object", ID_VAL, NULL, &obj);
	alist[1]      = make_alist("size", DV_INT32, NULL, &end);
	alist[2]      = make_alist("ignore", DV_FLOAT, NULL, &ignore);
	alist[3]      = make_alist("start", DV_INT32, NULL, &start);
	alist[4]      = make_alist("step", DV_INT32, NULL, &step);
	alist[5].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);

	if (obj == NULL) {
		parse_error("%s: No object specified\n", func->name);
		return (NULL);
	}

	if (end <= 0) {
		parse_error("%s: Invalid end value specified\n", func->name);
		return (NULL);
	}

	x = GetX(obj);
	y = GetY(obj);

	width  = end * 2 + 1;
	height = end * 2 + 1;
	// width = end;
	// height = end;
	w = create_window(width, height, DV_FLOAT);

	/* cache some frequently used computed values */
	h2    = height / 2;
	w2    = width / 2;
	total = width * height;

	/* precompute the distance of every point in a given sized window
	** to the center of the window.
	**
	** In theory, this only needs to be 1 quadrant of the window, but that's
	** too hard to bookkeep, and doesn't save much.
	*/
	distance = calloc(total, sizeof(int));
	for (i = 0; i < width; i++) {
		dx = i - w2;
		for (j = 0; j < height; j++) {
			dy                      = j - h2;
			distance[i + j * width] = floor(sqrt(dx * dx + dy * dy));
			/* precheck for values outside the largest circle */
			if (distance[i + j * width] > end) distance[i + j * width] = 0;
		}
	}

	out   = calloc((size_t)x * (size_t)y * (size_t)((end - start) / step + 1), sizeof(float));
	rval  = newVal(BSQ, x, y, ((end - start) / step + 1), DV_FLOAT, out);
	accum = calloc(end + 1, sizeof(struct dstore));

	/* run a window over every pixel and do the math */
	for (i = 0; i < x; i += 1) {
		load_window(w, obj, i, 0, ignore);
		for (j = 0; j < y; j += 1) {
			if (j) roll_window(w, obj, i, j, ignore);

			v1 = ((float**)w->row)[h2][w2];

			if (v1 == ignore) {
				continue;
			}

			memset(accum, 0, (end + 1) * sizeof(struct dstore));

			/*
			** pick a pair of opposing points, and add them to the
			** accumulator for their given distance.  We'll sum all the
			** accumulators later for a complete result from dist 1..N.
			*/

			for (q = 0; q <= h2; q++) {
				/* one of the double-derefs moved to here for speed */
				r1 = ((float**)w->row)[q];
				r2 = ((float**)w->row)[(height - 1) - q];
				for (p = 0; p < width; p++) {
					if (q == h2 && p == w2) {
						/* We only run the window up to the center point  */
						break;
					}

					v1 = r1[p];
					v2 = r2[(width - 1) - p];

					if (v1 == ignore || v2 == ignore) continue;

					if ((d = distance[p + q * width]) != 0) {
						a1 = &(accum[d]);
						a1->sumx += v1;
						a1->sumy += v2;
						a1->sumxx += v1 * v1;
						a1->sumyy += v2 * v2;
						a1->sumxy += v1 * v2;
						a1->count++;
					}
				}
			}

			/* now compute correlation from per-radii accumulators */
			for (r = 1; r <= end; r++) {
				/* sum the values in preceeding bins */
				a1 = &accum[r - 1];
				a2 = &accum[r];
				if (a1->count) {
					a2->sumx += a1->sumx;
					a2->sumy += a1->sumy;
					a2->sumxx += a1->sumxx;
					a2->sumyy += a1->sumyy;
					a2->sumxy += a1->sumxy;
					a2->count += a1->count;
				}
				// Don't bother if at least 1/2 the box isn't ignore values
				// this is M_PI_4 because we're only counting half the pixels
				// to begin with.
				if ((r - start) % step == 0) {
					if (a2->count > r * r * M_PI_4) {
						double c = a2->count;
						ssxx     = a2->sumxx - a2->sumx * a2->sumx / c;
						ssyy     = a2->sumyy - a2->sumy * a2->sumy / c;
						ssxy     = a2->sumxy - a2->sumx * a2->sumy / c;
						if (ssxx != 0 && ssyy != 0) {
							out[cpos(i, j, ((r - start) / step), rval)] =
							    sqrt(ssxy * ssxy / (ssxx * ssyy));
						}
					}
				}
			}
		}
		printf("%d/%d\r", i, x);
		fflush(stdout);
	}

	free_window(w);
	free(distance);
	free(accum);

	return (rval);
}
コード例 #10
0
ファイル: ff_radial.c プロジェクト: robwink/davinci
Var* ff_radial_symmetry(vfuncptr func, Var* arg)
{
	Var *obj = NULL, *rval = NULL;
	float ignore = FLT_MIN;
	float* out   = NULL;
	int x, y, z, i, j, k;
	int size   = 10;
	int xdelta = 0.0, ydelta = 0.0;
	float* line = NULL;
	int all     = 0;
	int first   = 1;
	Window* w;

	Alist alist[9];
	alist[0]      = make_alist("object", ID_VAL, NULL, &obj);
	alist[1]      = make_alist("size", DV_INT32, NULL, &size);
	alist[2]      = make_alist("xdelta", DV_INT32, NULL, &xdelta);
	alist[3]      = make_alist("ydelta", DV_INT32, NULL, &ydelta);
	alist[4]      = make_alist("ignore", DV_FLOAT, NULL, &ignore);
	alist[5]      = make_alist("all", DV_INT32, NULL, &all);
	alist[6]      = make_alist("first", DV_INT32, NULL, &first);
	alist[7].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);

	if (obj == NULL) {
		parse_error("%s: No object specified\n", func->name);
		return (NULL);
	}

	if (size < 0) {
		parse_error("%s: Invalid size specified\n", func->name);
		return (NULL);
	}

	x = GetX(obj);
	y = GetY(obj);
	z = GetZ(obj);
	w = create_window(size, size, DV_FLOAT);

	if (all) {
		size_t n = (size_t)x * (size_t)y * (size_t)(size - first + 1);
		out      = (float*)calloc(n, sizeof(float));
		rval     = newVal(BSQ, x, y, (size - first + 1), DV_FLOAT, out);
		line     = (float*)calloc(size, sizeof(float));
	} else {
		size_t n = (size_t)x * (size_t)y;
		out      = (float*)calloc(n, sizeof(float));
		rval     = newVal(BSQ, x, y, 1, DV_FLOAT, out);
		line     = NULL;
	}

	for (i = 0; i < x; i += 1) {
		load_window(w, obj, i, 0, ignore);
		for (j = 0; j < y; j += 1) {
			if (j) roll_window(w, obj, i, j, ignore);

			out[cpos(i, j, 0, rval)] =
			    radial_symmetry(w->row, size, size, ignore, xdelta, ydelta, size, line);
			if (all) {
				for (k = first; k <= size; k++) {
					out[cpos(i, j, k - first, rval)] = line[k];
				}
			}
		}
	}

	free_window(w);
	return (rval);
}
コード例 #11
0
ファイル: help.c プロジェクト: CivilPol/sdcboot
int
main (int argc, char *argv[])
{
  /* These have been moved from global to local variables */
  /* this reduces binary size and improves code structure. RP */
  /* Also size of home_page and help_page reduced from 257. RP 11-mar-04 */
  char home_page[20] = "index.htm";
  char help_page[20] = "help.htm";
  char base_dir[257];

  char *showcommand = 0;
  char *oldscreen;
  int oldcursorx = wherex (), oldcursory = wherey ();
  int i;			/* counter for loop */
  int forcemono = 0, fancyscheme = 0;
  int AsciiExtendedChars = 1;
  int codepage = 0;

  cat = catopen("htmlhelp", 0);

  if (getenv ("HELPPATH") == NULL)
    {
      get_base_dir (base_dir, argv[0]);
      strcat (base_dir, "..\\help\\"); /* default location */

      if (lang_add(base_dir, home_page) != 0)
      {
         char testpath[257];
         get_base_dir (base_dir, argv[0]);
         strcat (base_dir, "..\\help\\"); /* bookshelf location */

         strcpy(testpath, base_dir);
         strcat(testpath, home_page);
         if (checkForFile(testpath) != 0)
         {
            get_base_dir (base_dir, argv[0]); /* try same dir as exe */
            strcpy(testpath, base_dir);
            strcat(testpath, home_page);
            if (checkForFile(testpath) != 0)
            {
               *base_dir = '\0'; /* try current dir */
               strcpy(testpath, home_page);
               if (checkForFile(testpath) != 0)
               {
                  get_base_dir (base_dir, argv[0]);
                  strcat (base_dir, "..\\help\\");
               }
            }
         }
      }
    }
  else
    {
      strcpy (base_dir, getenv ("HELPPATH"));
      if (lang_add(base_dir, home_page) != 0)
      {
         strcpy (base_dir, getenv ("HELPPATH"));
         if (base_dir[0] != '\0')
         {
            if (base_dir[strlen(base_dir)-1] != '\\' &&
                base_dir[strlen(base_dir)-1] != '/');
	            strcat (base_dir, "\\");
         }
      }

    }

  if (getenv ("HELPCMD"))
    {
      if (strstr (getenv ("HELPCMD"), "/A"))
	AsciiExtendedChars = 0;
      if (strstr (getenv ("HELPCMD"), "/M"))
	forcemono = 1;
      if (strstr (getenv ("HELPCMD"), "/F1"))
         fancyscheme = 1;
      if (strstr (getenv ("HELPCMD"), "/F2"))
         fancyscheme = 2;
    }

  for (i = 1; i < argc; i++)
    {
      if (argv[i][0] == '/')
	{
	  switch (argv[i][1])
	    {

	    default:
	      printf ("%s -- %s\n", hcatInvArg, argv[i] + 1);
		   printf ("%s\n", hcatHowGetUsage);
         break;

	    case '?':
	      show_usage ();
	      return 0;

	    case 'a':
	    case 'A':
	      if (argv[i][2] == 0)
		AsciiExtendedChars = 0;
	      break;

       case 'c':
       case 'C':
       codepage = atoi(argv[i]+2);
       if (codepage == 0)
       {
          printf("%s (/Cnnn)\n", hcatCodepagePlease);
          printf("%s:\n%s\n", hcatCodepagesSupported, supportedCodepages);
          return 0;
       }
       break;

	    case 'f':
	    case 'F':
	      fancyscheme = atoi(argv[i] + 2);
         if (fancyscheme < 1 || fancyscheme > 2)
            fancyscheme = 1;
         break;

	    case 'h':
	    case 'H':
	      if (argv[i][2] == 0)	/* Only put /h or /H */
		{
        printf ("%s\n", hcatInvArg);
		  printf ("%s\n", hcatHowGetUsage);
		  return 0;
		}
	      else
		{
           strncpy(help_page, argv[i] + 2, 14);
		}
	      break;

	    case 'l':
	    case 'L':
	      strcat (base_dir, argv[i] + 2);
	      checkForFile (base_dir);
	      get_home_page (home_page, base_dir);
	      get_base_dir (base_dir, base_dir);
	      break;

	    case 'm':
	    case 'M':
	      if (argv[i][2] == '\0')
		forcemono = 1;
	      else
		{
		  printf ("%s -- %s\n", hcatInvArg, argv[i] + 1);
		  printf ("%s\n", hcatHowGetUsage);
		  return 0;
		}
	      break;

	    case 'o':		/* Override index file path/name */
	    case 'O':
	      strcpy (base_dir, argv[i] + 2);
         if (lang_add(base_dir, home_page) != 0)
         {
	         strcpy (base_dir, argv[i] + 2);
	         checkForFile (base_dir);
	         get_home_page (home_page, base_dir);
	         get_base_dir (base_dir, base_dir);
         }
	    }
	}
      else if (showcommand == 0)
	{
	  showcommand = malloc (strlen (argv[i]) + 11);
	  if (!showcommand)
	    {
	      printf ("%s\n", hcatMemErr);
	      return 0;
	    }
	  sprintf (showcommand, "#%s", argv[i]);
	}
      else
	{
	  printf ("%s\n", hcat2ManyTopics);
	  printf ("%s\n", hcatHowGetUsage);
	  return 0;
	}
    }

  if (fancyscheme && forcemono)
  {
     printf ("%s\n", hcatFwithN);
	  printf ("%s\n", hcatHowGetUsage);
     return 0;
  }

  /* detect (or force) the codepage to select UTF-8 and entity
     substition support */
  if (selectCodepage(codepage) != codepage && codepage > 0)
  {
     printf("%s\n", hcatCodepageNotSupported);
     printf("%s:\n%s\n", hcatCodepagesSupported, supportedCodepages);
     return 0;
  }

  /* initialise user interface */
  conio_init (forcemono);

  if (forcemono == 0)
    {
      oldscreen = malloc (W * H * 2);
      if (oldscreen)
	save_window (X, Y, W, H, oldscreen);
    }

  if (MonoOrColor == COLOR_MODE && fancyscheme == 0)
    {
      TEXT_COLOR = C_TEXT_COLOR;
      BOLD_COLOR = C_BOLD_COLOR;
      ITALIC_COLOR = C_ITALIC_COLOR;
      BORDER_BOX_COLOR = C_BORDER_COLOR;
      BORDER_TEXT_COLOR = C_BORDER_TEXT_COLOR;
      LINK_COLOR = C_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = C_LINK_HIGHLIGHTED_COLOR;
    }
  else if (MonoOrColor == COLOR_MODE && fancyscheme == 1)
    {
      TEXT_COLOR = F1_TEXT_COLOR;
      BOLD_COLOR = F1_BOLD_COLOR;
      ITALIC_COLOR = F1_ITALIC_COLOR;
      BORDER_BOX_COLOR = F1_BORDER_COLOR;
      BORDER_TEXT_COLOR = F1_BORDER_TEXT_COLOR;
      LINK_COLOR = F1_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = F1_LINK_HIGHLIGHTED_COLOR;
    }
  else if (MonoOrColor == COLOR_MODE && fancyscheme == 2)
    {
      TEXT_COLOR = F2_TEXT_COLOR;
      BOLD_COLOR = F2_BOLD_COLOR;
      ITALIC_COLOR = F2_ITALIC_COLOR;
      BORDER_BOX_COLOR = F2_BORDER_COLOR;
      BORDER_TEXT_COLOR = F2_BORDER_TEXT_COLOR;
      LINK_COLOR = F2_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = F2_LINK_HIGHLIGHTED_COLOR;
    }
  else
    {
      TEXT_COLOR = M_TEXT_COLOR;
      BOLD_COLOR = M_BOLD_COLOR;
      ITALIC_COLOR = M_ITALIC_COLOR;
      BORDER_BOX_COLOR = M_BORDER_COLOR;
      BORDER_TEXT_COLOR = M_BORDER_TEXT_COLOR;
      LINK_COLOR = M_LINK_COLOR;
      LINK_HIGHLIGHTED_COLOR = M_LINK_HIGHLIGHTED_COLOR;
    }
  if (AsciiExtendedChars == 0)
    {
      strcpy (Border22f, "+-+( )+-+");
      strcpy (Border22if, "+-+( )+-+");
      BarBlock1 = '.';
      BarBlock2 = '#';
    }
  show_mouse ();
  move_mouse (80, 25);
  drawmenu ();
  html_view (showcommand, base_dir, home_page, help_page);
  free (showcommand);
  hide_mouse ();
  if ((oldscreen != 0) && (forcemono == 0))
    {
      load_window (X, Y, W, H, oldscreen);
      free (oldscreen);
    }
  conio_exit ();
  gotoxy (oldcursorx, oldcursory);

  return 0;
}
コード例 #12
0
ファイル: help_htm.c プロジェクト: CivilPol/sdcboot
void
displayProcess (struct eventState *pes)
{
  long i, k = 0, ch, line = 0, len = 0;
  char link_started, bold_started, it_started;
  char *link_reference;
  char str[2 * LEN + 3], col[LEN + 1], tmp[LEN + 1];

  if (pes->force_redraw == 1 || pes->check_mouse == 1)
    {
      pes->p = pes->top;
      pes->link_under_mouse = 0;
      /* The following bit checks for formatting and links started above
         the top of the screen (before pes->top in the text buffer)
         RP 11-mar-04 */
      bold_started = checkAboveTop (pes, "<b>", "</b>");
      it_started = checkAboveTop (pes, "<i>", "</i>");
      link_started = checkAboveTop (pes, "<a href=", "</a>");
      if (link_started)
	{
	  link_reference = pes->p;
	  while (strncmp (link_reference, "<a href=", 8))
	    {
	      link_reference--;
	      if (link_reference == pes->body_start)
		break;
	    }
	  link_reference += 8;
	  if (*link_reference == '"')
	    link_reference++;
	}

      while (1)
	{
	  if (*pes->p == '\n' || len == LEN || pes->p == pes->body_end)
	    {
	      if (*pes->p != '\n' && pes->p != pes->body_end)
		while (*pes->p != '\n' && pes->p != pes->body_end)
		  pes->p++;

	      if (*pes->p == '\n' && pes->p != pes->body_end)
		pes->p++;

	      while (len != LEN)
		{
		  tmp[(size_t) len] = ' ';
		  col[(size_t) len] = TEXT_COLOR;
		  len++;
		}

	      if (pes->force_redraw)
		{
		  int j;
		  for (i = 0, j = 0; i < LEN; i++)
		    {
		      str[j++] = tmp[i];
		      str[j++] = col[i];
		    }
		  load_window (X + 2, Y + 1 + line, LEN, 1, str);
		}

	      line++;
	      len = 0;

	      if (pes->p == pes->body_end || line == N)
		{
		  if (line != N)
		    clear_window (TEXT_COLOR, X + 2, Y + 1 + line, LEN,
				  N - line);

		  break;
		}

	      continue;
	    }

	  if (*pes->p == '\r')
	    {
	      pes->p++;
	      continue;
	    }

	  if (*pes->p == '<' && (pes->p[1] >= 'A' && pes->p[1] <= 'Z' ||
				 pes->p[1] >= 'a' && pes->p[1] <= 'z' ||
				 pes->p[1] == '/' || pes->p[1] == '!'))
	    {
	      if (link_started == 0 && (pes->p[1] == 'a' || pes->p[1] == 'A'))
		{
		  /* modified for help 5.0.2 so that links without href= in them
		     e.g <A NAME="..."> are not accidentally loaded. - RP */
		  char *closearrow;
		  closearrow = strchr (pes->p, '>');
		  *closearrow = 0;
		  link_reference = strstr (pes->p, "href=");
		  *closearrow = '>';

		  if (link_reference)
		    {
		      link_reference += 5;
		      if (*link_reference == '\"')
			link_reference++;

		      link_started = 1;
		    }
		}
	      else if (link_started == 1 && strncmp (pes->p, "</a>", 4) == 0)
		link_started = 0;
	      else if (bold_started == 0 && strncmp (pes->p, "<b>", 3) == 0)
		bold_started = 1;
	      else if (bold_started == 1 && strncmp (pes->p, "</b>", 4) == 0)
		bold_started = 0;
	      else if (it_started == 0 && strncmp (pes->p, "<i>", 3) == 0)
		it_started = 1;
	      else if (it_started == 1 && strncmp (pes->p, "</i>", 4) == 0)
		it_started = 0;

	      while (*pes->p != '>' && pes->p != pes->body_end)
		pes->p++;

	      if (*pes->p == '>')
		pes->p++;
	    }
	  else
	    {
	      /* Translate some &-escape codes. */
	      ch = *pes->p;
	      if (*pes->p == '&')
		ch = ampSubs (pes);

	      tmp[len] = (ch != '\t') ? ch : ' ';

	      col[len] = link_started ? LINK_COLOR : TEXT_COLOR &&
		bold_started ? BOLD_COLOR : TEXT_COLOR &&
		it_started ? ITALIC_COLOR : TEXT_COLOR;

	      if (link_started && link_reference == pes->clink)
		col[len] = LINK_HIGHLIGHTED_COLOR;

	      if (line == mline && len == mpos && link_started
		  && pes->check_mouse == 1)
		pes->link_under_mouse = link_reference;

	      len++;

	      if (ch != '\t' || len % 8 == 0)
		pes->p++;
	    }
	}

      if (pes->force_redraw == 1)
	{
	  pes->bottom = pes->p;
	  for (i = 0; i < BARLEN; i++)
	    {
	      write_char (BORDER_BOX_COLOR, BARX, BARY + i, ((i != pes->barpos) && (pes->maxtop != 0)) ? BarBlock1 : BarBlock2);	/* modified RP */
	    }
	  pes->old_top = pes->top;
	  pes->force_redraw = 0;
	}
    }

  /* The following has lines of code in this function were modified
     to show the link selected by the tab key for those users without
     mice - RP. */
  if (pes->link_under_mouse && pes->link_priority == LP_MOUSE)
    pes->p = pes->link_under_mouse;
  else if (pes->clink)
    pes->p = pes->clink;

  if (pes->clink || pes->link_under_mouse)
    {
      k = strchr (pes->p, '\"') - pes->p;
      if (k < 0 || k > LEN - 12)
	k = LEN - 12;

      sprintf (pes->text_holder, "%.*s", (int) k, pes->p);
      statusbar (pes->text_holder);
      *pes->text_holder = 0;
    }
  else
    statusbar (NULL);		/* 11--mar-04 */

  pes->p = pes->link_text;
}				/* end displayProcess. */
コード例 #13
0
ファイル: help_htm.c プロジェクト: CivilPol/sdcboot
void
html_view (const char *target,
	   char *base_dir, char *home_page, const char *help_page)
{
  struct eventState *pes = 0;
  char *p, *q;
  char fullpath[257];
  char target_name[257];
  char *after_base_dir;
  int pleaseLoad = 1;

  if (pesListInitialise () == FAIL)
    return;

  if (target == 0)
    *target_name = 0;
  else
    strcpy (target_name, target);

  strcpy (fullpath, base_dir);

  while (1)
    {
      if (pleaseLoad)
	{
	  if (*target_name == 0 || *target_name == '#')
	    {
	      strcpy (fullpath, base_dir);
	      /* Cosmetic:
	         since default home_page is in ..\help
	         clear the .. and take a directory of the
	         base directory if possible.
	         When files aren't found, the error msgs
	         will look better: */
	      if (home_page[0] == '.' && home_page[1] == '.'
		  && *base_dir != 0)
		{
		  char *forwardslash, *backwardslash;
		  char *lastchar;
		  lastchar = fullpath + strlen (fullpath) - 1;
		  if (*lastchar == '\\' || *lastchar == '/')
		    *lastchar = 0;
		  forwardslash = strrchr (fullpath, '/');
		  backwardslash = strrchr (fullpath, '\\');
		  after_base_dir = (forwardslash > backwardslash)
		    ? forwardslash : backwardslash;
		  if (after_base_dir == 0)
		    after_base_dir = fullpath;

		  strcpy (after_base_dir, home_page + 2);
		}
	      else
		{
		  after_base_dir = fullpath + strlen (fullpath);
		  strcat (after_base_dir, home_page);
		}
	      q = target_name;
	    }
	  else
	    {
	      after_base_dir = fullpath + strlen (fullpath);

	      for (q = target_name, p = after_base_dir;
		   (*q != 0) && (*q != '#'); q++, p++)
		*p = *q;

	      *p = 0;
	    }

	  if (pes)
	    if (pes->hidden)
	      pes = pesListBackward ();

	  /* The following strange combination of an if and a ? is there
	     to compare pes->filename and fullpath, so as not to create the pes
	     if the desired file is already the current page.
	     But if pes is 0, then it can't be the current page, and also
	     there is nothing to compare. So if pes is 0, we wish to
	     create the pes for sure - hence the ': 1' condition. -RP */
	  if (pes ? stricmp (pes->filename, fullpath) : 1)
	    {
	      /* Attempt to create a new pes in the list */
	      if ((pes = pesListAdd (fullpath, home_page)) != 0)
		   {
		      preparepes (pes);
		   }
	      else
         {
            readFileError(after_base_dir);
            if ((pes = pesListCurrent ()) == 0)
               return;
            q = NULL;
         }
	    }

	  if (q != 0)
	    pes->link_text = (*q != 0) ? q : 0;
	  else
	    pes->link_text = 0;
	}

      *after_base_dir = 0;	/* Truncate fullpath to just base_dir */

      switch (html_view_internal (pes, base_dir, home_page))
	{
	case NAVIGATE_BACK:
     pes->seek_base = backBookmark(pes);
     if (pes->seek_base)
     {
        pes->seek_cnt = -1;
        pes->clink = NULL;
        pleaseLoad = 0;
        break;
     }

	  save_window (X, Y, W, H - 3, pes->screen_buf);
	  if ((pes = pesListBackward ()) == 0)
	    {
	      pesListDestroy ();
	      return;
	    }
	  pes->left_was_pressed = 0;
	  load_window (X, Y, W, H - 3, pes->screen_buf);
	  pleaseLoad = 0;
	  break;

	case NAVIGATE_LINK:
	  save_window (X, Y, W, H - 3, pes->screen_buf);

	  if (pes->text_holder != 0)
	    {
	      /* Start the target_name off with the current files' path */
	      char *forwardslash, *backwardslash;
	      strcpy (target_name, pes->filename);

	      /* Find the last / or \ and truncate the string */
	      forwardslash = strrchr (target_name, '/');
	      backwardslash = strrchr (target_name, '\\');
	      p =
		(forwardslash > backwardslash) ? forwardslash : backwardslash;

	      if (p != NULL)
		*p = 0;
	      else
		*target_name = 0;

	      /* Clip off directories, if the target goes 'up' the
	         directory tree with ".."s. */
	      while ((strncmp (pes->text_holder, "..", 2) == 0)
		     && (p != NULL))
		{
		  forwardslash = strrchr (target_name, '/');
		  backwardslash = strrchr (target_name, '\\');
		  p = (forwardslash > backwardslash) ?
		    forwardslash : backwardslash;

		  if (p != NULL)
		    {
		      *p = 0;	/* modify target name */

		      /* Cut out the .. by copying backwards */
		      /* first make sure the string isn't just ".." */
		      if (strlen (pes->text_holder) >= 3)
			{
			  p = pes->text_holder;
			  while (p[2] != 0)
			    {
			      *p = p[3];	/* fixed. changed from 2 to 3. 9-MAR-04 RP */
			      ++p;
			    }
			}
		      else	/* treat as just "index.htm" */
			strcpy (pes->text_holder, "index.htm");
		    }
		}

	      /* Minor fix: changed || into && here - RP 2004 */
	      if ((*(pes->text_holder) != '/')
		  && (*(pes->text_holder) != '\\')
		  && (target_name[strlen (target_name)] != '/')
		  && (target_name[strlen (target_name)] != '\\')
		  && *target_name != 0)
		strcat (target_name, "\\");

	      strcat (target_name, pes->text_holder);
	      /* Since the target link is relative to the present link,
	         there is no need for the fullpath to contain the base
	         directory: */
	      *fullpath = 0;
	    }
	  else
	    *target_name = 0;

	  pleaseLoad = 1;
	  *pes->text_holder = 0;
	  break;

	case NAVIGATE_FORWARD:
     pes->seek_base = forwardBookmark(pes);
     if (pes->seek_base)
     {
        pes->seek_cnt = -1;
        pes->clink = NULL;
        pleaseLoad = 0;
        break;
     }
	  save_window (X, Y, W, H - 3, pes->screen_buf);
	  if ((pes = pesListForward ()) != 0)
	    load_window (X, Y, W, H - 3, pes->screen_buf);
	  else
	    pes = pesListCurrent ();
	  pes->left_was_pressed = 0;
	  pleaseLoad = 0;
	  break;

	case NAVIGATE_HOME:
	  save_window (X, Y, W, H - 3, pes->screen_buf);
	  *fullpath = 0;
	  *target_name = 0;
	  pleaseLoad = 1;
	  break;

	case NAVIGATE_HELP:
	  save_window (X, Y, W, H - 3, pes->screen_buf);
     /* help_page NOT relative to current page, but to base directory: */
     strcpy (fullpath, base_dir);
	  strcpy (target_name, help_page);
	  pleaseLoad = 1;
	  break;

	case NAVIGATE_EXIT:
	  pesListDestroy ();
	  return;

	case NAVIGATE_REFRESH:
	  strcpy (target_name, pes->filename);
	  *fullpath = 0;
	  pes = pesListBackward ();
	  pleaseLoad = 1;
	  break;

	case NAVIGATE_SEARCH:
	  save_window (X, Y, W, H - 3, pes->screen_buf);
	  if ((pes = helpsearch (pes, base_dir, home_page)) != NULL)
	    {
	      pesListDeleteForwards ();
	      preparepes (pes);
	      pes->link_text = 0;
	      *fullpath = 0;
	    }
	  else
	    pes = pesListCurrent ();
	  pleaseLoad = 0;
	  break;

	default:
	  pleaseLoad = 0;
	}
    }				/* END while(1) */
}