示例#1
0
文件: ring.c 项目: gamma62/eda
/*
** list_buffers - open a special buffer with a list of open files and bookmarks,
**	switch to the open buffer or (re)generate it
*/
int
list_buffers (void)
{
	int ri, lno_read;
	LINE *lp=NULL, *lx=NULL;
	char one_line[CMDLINESIZE*2];
	int ret=1, bm_i;
	int origin = cnf.ring_curr;

	/* open or reopen? */
	ret = scratch_buffer("*ring*");
	if (ret==0) {
		/* switch to */
		if (origin != cnf.ring_curr && CURR_FILE.num_lines > 0)
			return (0);
		/* generate or regenerate */
		if (CURR_FILE.num_lines > 0)
			ret = clean_buffer();
	}
	if (ret) {
		return (ret);
	}
	CURR_FILE.num_lines = 0;
	CURR_FILE.fflag |= (FSTAT_SPECW);
	if (origin != cnf.ring_curr) {
		CURR_FILE.origin = origin;
	}

	/* fill with data from ring
	 */
	CURR_FILE.num_lines += cnf.ring_size;
	lp = CURR_FILE.bottom->prev;
	lno_read = 0;
	memset(one_line, 0, sizeof(one_line));
	for (ri=0; ret==0 && ri<RINGSIZE; ri++) {
		if (!(cnf.fdata[ri].fflag & FSTAT_OPEN))
			continue;

		/* base data
		*/
		if (cnf.fdata[ri].fflag & (FSTAT_SPECW | FSTAT_SCRATCH)) {
			snprintf(one_line, sizeof(one_line)-1, "%d \"%s\"   lines: %d   flags: %s%s%s%s\n",
				ri, cnf.fdata[ri].fname, cnf.fdata[ri].num_lines,
				(cnf.fdata[ri].fflag & FSTAT_SPECW) ? "special " : "",
				(cnf.fdata[ri].fflag & FSTAT_SCRATCH) ? "scratch " : "",
				(cnf.fdata[ri].fflag & FSTAT_CHMASK) ? "r/o " : "",
				(cnf.fdata[ri].pipe_output != 0) ? "pipe " : "");
		} else {
			snprintf(one_line, sizeof(one_line)-1, "%d \"%s\"   lines: %d   flags: %s%s%s%s\n",
				ri, cnf.fdata[ri].fname, cnf.fdata[ri].num_lines,
				(cnf.fdata[ri].fflag & FSTAT_RO) ? "R/O " : "R/W ",
				(cnf.fdata[ri].fflag & FSTAT_CHANGE) ? "Mod " : "",
				(cnf.fdata[ri].fflag & FSTAT_EXTCH) ? "Ext.Mod " : "",
				(cnf.fdata[ri].fflag & FSTAT_HIDDEN) ? "HIDDEN " : "");
		}

		if ((lx = append_line (lp, one_line)) != NULL) {
			lno_read++;
			lp=lx;
		} else {
			ret = 2;
			break;
		}

		/* optional: bookmarks
		*/
		for (bm_i=1; bm_i < 10; bm_i++) {
			if (ri == cnf.bookmark[bm_i].ring) {
				snprintf(one_line, sizeof(one_line)-1, "\tbookmark %d: %s\n",
					bm_i, cnf.bookmark[bm_i].sample);
				if ((lx = append_line (lp, one_line)) != NULL) {
					lno_read++;
					lp=lx;
				} else {
					ret = 2;
					break;
				}
			}
		}
	}/* for ri... */

	if (ret==0) {
		CURR_FILE.num_lines = lno_read;
		CURR_LINE = CURR_FILE.top->next;
		CURR_FILE.lineno = 1;
		update_focus(FOCUS_ON_2ND_LINE, cnf.ring_curr);
		go_home();
		CURR_FILE.fflag &= ~FSTAT_CHANGE;
		/* disable inline editing and adding lines */
		CURR_FILE.fflag |= (FSTAT_NOEDIT | FSTAT_NOADDLIN);
	} else {
		ret |= drop_file();
	}

	return (ret);
}
示例#2
0
bool MandelboxKernelControl::SetFrom(const SettingCollection &settings,
                                     CudaContext &context,
                                     size_t width,
                                     size_t height)
{
    bool changed = false;
    if (old_width != width || old_height != height || !scratch_buffer()
        || !rand_buffer())
    {
        changed = true;
        old_width = width;
        old_height = height;
        scratch_buffer.~CuMem();
        rand_buffer.~CuMem();
        new(&scratch_buffer) CuMem<char>(context,
                                         width * height * MandelboxStateSize);
        new(&rand_buffer) CuMem<uint64_t>(context, width * height);
    }
    MandelboxCfg temp;
#define DefineFlt(name) temp.name = (float)settings.Get(#name).AsFloat()
#define DefineInt(name) temp.name = (int)settings.Get(#name).AsInt()
#define DefineBool(name) temp.name = settings.Get(#name).AsBool() ? 1 : 0
    DefineFlt(posX);
    DefineFlt(posY);
    DefineFlt(posZ);
    DefineFlt(lookX);
    DefineFlt(lookY);
    DefineFlt(lookZ);
    DefineFlt(upX);
    DefineFlt(upY);
    DefineFlt(upZ);
    DefineFlt(fov);
    DefineFlt(focalDistance);

    DefineFlt(Scale);
    DefineFlt(FoldingLimit);
    DefineFlt(FixedRadius2);
    DefineFlt(MinRadius2);
    DefineFlt(DeRotationAmount);
    DefineFlt(DeRotationAxisX);
    DefineFlt(DeRotationAxisY);
    DefineFlt(DeRotationAxisZ);
    DefineFlt(DofAmount);
    DefineFlt(FovAbberation);

    DefineFlt(LightPosX);
    DefineFlt(LightPosY);
    DefineFlt(LightPosZ);
    DefineFlt(LightSize);

    DefineBool(WhiteClamp);

    DefineFlt(LightBrightnessHue);
    DefineFlt(LightBrightnessSat);
    DefineFlt(LightBrightnessVal);

    DefineFlt(AmbientBrightnessHue);
    DefineFlt(AmbientBrightnessSat);
    DefineFlt(AmbientBrightnessVal);

    DefineFlt(ReflectHue);
    DefineFlt(ReflectSat);
    DefineFlt(ReflectVal);

    DefineInt(MaxIters);
    DefineFlt(Bailout);
    DefineFlt(DeMultiplier);
    DefineInt(RandSeedInitSteps);
    DefineFlt(MaxRayDist);
    DefineInt(MaxRaySteps);
    DefineInt(NumRayBounces);
    DefineFlt(QualityFirstRay);
    DefineFlt(QualityRestRay);
    DefineInt(ItersPerKernel);
#undef DefineFlt
#undef DefineInt
#undef DefineBool
    if (!old_state)
    {
        changed = true;
        old_state = make_unique<MandelboxCfg>();
        *old_state = temp;
    }
    else if (memcmp(old_state.get(), &temp, sizeof(temp)))
    {
        changed = true;
        *old_state = temp;
    }
    temp.scratch = scratch_buffer();
    temp.randbuf = rand_buffer();
    kernelVariable.Set(temp);
    return changed;
}
示例#3
0
文件: rc.c 项目: gamma62/eda
/*
** show_commands - show table of commands with keyboard shortcuts
*/
int
show_commands (void)
{
	int ret=1;
	LINE *lp=NULL;
	char circle_line[1024];
	char key_buff[90];
	char name_buff[30];
	int ti, ki, i, j, mi;

	/* open or reopen? */
	ret = scratch_buffer("*cmds*");
	if (ret) {
		return (ret);
	}
	/* cnf.ring_curr is set now -- CURR_FILE and CURR_LINE alive */
	if (CURR_FILE.num_lines > 0) {
		clean_buffer();
	}
	CURR_FILE.fflag |= FSTAT_SPECW;
	CURR_FILE.fflag &= ~FSTAT_NOEDIT;	/* temporary */

	ret = type_text("\n\
command name          function name         keyboard shortcut\n\
--------------------  --------------------  -------------------------\n");

	if (!ret) {

		CURR_LINE = CURR_FILE.bottom->prev;
		memset(circle_line, '\0', sizeof(circle_line));
		memset(name_buff, '\0', sizeof(name_buff));
		memset(key_buff, '\0', sizeof(key_buff));

		for (ti=0; ret == 0 && ti < TLEN; ti++) {

			if (table[ti].minlen == -1 && table[ti].fkey == -1) {
				/* only for macros */
				continue;
			}

			/* command name with mandatory or optional arguments */
			name_buff[0] = '\0';
			if (table[ti].minlen >= 1) {
				i = 0;
				for (j=0; i < 20 && table[ti].name[j] != '\0'; j++) {
					if (i == table[ti].minlen)
						name_buff[i++] = '.';
					name_buff[i++] = table[ti].name[j];
				}
				name_buff[i++] = '\0';
				if (table[ti].tflag & TSTAT_ARGS) {
					strncat(name_buff, ((table[ti].tflag & TSTAT_OPTARG) ? " [<arg>]" : " <arg>"), 10);
				}
			} else {
				strncpy(name_buff, "n/a", 10);
			}

			/* list of keys, pretty printing, space limitation */
			key_buff[0] = '\0';
			if (table[ti].fkey == -1) {
				strncpy(key_buff, "n/a", 10);
			} else {
				for (ki=0; ki < KLEN; ki++) {
					if (keys[ki].table_index == ti) {
						if (pretty_print_key_names(ki, key_buff, sizeof(key_buff)))
							break;
					}
				}
				if (key_buff[0] == '\0') {
					strncat(key_buff, "none", 10);
				}
			}

			snprintf(circle_line, sizeof(circle_line)-1, "%-20s  %-20s  %s\n",
				name_buff, table[ti].fullname, key_buff);

			ret = type_text(circle_line);
		}
	}

	if (!ret && macros) {

		ret = type_text("\n\
macro key             macro name\n\
--------------------  ----------------------------------------\n");

		for (mi=0; ret == 0 && mi < MLEN; mi++) {
			key_buff[0] = '\0';
			ki = index_key_value( macros[mi].fkey );
			if (ki >= 0 && ki < KLEN && ki != RES_KLEN) { // KEY_NONE index is RES_KLEN
				pretty_print_key_names(ki, key_buff, sizeof(key_buff));
			} else {
				strncpy(key_buff, "none", 10);
			}

			name_buff[0] = '\0';
			if (macros[mi].name[0] == '\0') {
				strncpy(name_buff, "n/a", 10);
			} else {
				strncpy(name_buff, macros[mi].name, 20);
				if (macros[mi].mflag & TSTAT_ARGS) {
					strncat(name_buff, ((macros[mi].mflag & TSTAT_OPTARG) ? " [<arg>]" : " <arg>"), 10);
				}
			}

			snprintf(circle_line, sizeof(circle_line)-1, "%-20s  %s\n",
				key_buff, name_buff);

			ret = type_text(circle_line);
		}
	}