Esempio n. 1
0
VOID edit_bit(LONG tree, WORD sobj)
{
	WORD	where, exitobj, ok;
	BYTE	name[9];
	GRECT	p;

	if (rcs_state != ALRT_STATE)
	{
		objc_xywh(tree, sobj, &p);
		ini_tree(&tree, BITDIAL);
		where = set_obname(tree, BITNAME, name, ad_view, sobj);

		do {
			exitobj = hndl_dial(tree, 0, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
		}
	}
}
Esempio n. 2
0
VOID arrange_tree(LONG tree, WORD wint, WORD hint,WORD *maxw, WORD *maxh)
{
	WORD	obj, x, y, rowh, wroot;

	wroot = GET_WIDTH(tree, ROOT);
	if ( wroot )
	{
		x = wint;
		y = hint;
		rowh = 0;
		*maxw = 0;

		for (obj = GET_HEAD(tree, ROOT); obj != ROOT; 
			obj = GET_NEXT(tree, obj))
		{
			if (rowh && (x + GET_WIDTH(tree, obj)) > wroot)
			{
				x = wint;
				y += (rowh + hint);
				rowh = 0;
			}
			SET_X(tree, obj, x);
			SET_Y(tree, obj, y);
			if ( !(GET_FLAGS(tree, obj) & HIDETREE) )
			{
				x += (GET_WIDTH(tree, obj) + wint); 
				*maxw = max(*maxw, x);
				rowh = max(rowh, GET_HEIGHT(tree, obj));
			}
		}
		*maxh = y + rowh + hint;
	}
}
Esempio n. 3
0
LOCAL VOID flag_obj(LONG tree, WORD which, WORD bit)
{
	WORD	flags;

	flags = GET_FLAGS(tree, which);
	SET_FLAGS(tree, which, flags | bit);
}
Esempio n. 4
0
void cosmac_device::state_export(const device_state_entry &entry)
{
	switch (entry.index())
	{
		case STATE_GENPC:
			m_pc = R[P];
			break;

		case STATE_GENFLAGS:
			m_flagsio = GET_FLAGS();
			break;
	}
}
Esempio n. 5
0
kern_obj * spawn_thread(kern_obj * proc, int (*func)())
{
	ulong fl, pg;
	kern_obj * thrd = alloc_kobj();

	thrd->type = KOBJ_THREAD;
	thrd->u.thrd.proc = proc;
	
	thrd->u.thrd.sub = alloc_kobj();
	thrd->u.thrd.sub->type = KOBJ_THREAD_SUB;
	thrd->u.thrd.sub->u.thrd2.stack_ws = alloc_ws();

	pg = alloc_pages(2, PHYS_PAGES);
	if (pg == 0) {
		free_kobj(thrd->u.thrd.sub);
		free_kobj(thrd);
		return 0;
	}

	add_pgs_to_ws(thrd->u.thrd.sub->u.thrd2.stack_ws, USPACE_TOP - 0x2000, pg, 0x2000, 7);
	thrd->u.thrd.sub->u.thrd2.rsp = USPACE_TOP - 0x50;
	
	ATQ(KPT0_0_LOC) = (pg + 0x1000) | 3;
	INVLPG(KSPACE_LOC);	

	ATQ(KSPACE_LOC + 0xFB0) = (ulong)func;
	ATQ(KSPACE_LOC + 0xFB8) = USER_CS | 3;
	GET_FLAGS(fl);
	ATQ(KSPACE_LOC + 0xFC0) = fl;
	ATQ(KSPACE_LOC + 0xFC8) = USPACE_TOP - 0x1000;
	ATQ(KSPACE_LOC + 0xFD0) = USER_DS | 3;

	getlock(&procthrd_lock, 1);
	if (head_thread == NULL) {
		thrd->u.thrd.next = thrd;
		head_thread = thrd;
	} else {
		thrd->u.thrd.next = head_thread->u.thrd.next;
		head_thread->u.thrd.next = thrd;
	}
	unlock(&procthrd_lock, 1);

	return thrd;
}
Esempio n. 6
0
void cpu6502_irq(struct cpu6502_context *context)
{
    if (context->flags & FLAG_I) {
	return; /* interrupts disabled */
    }

    PUSH_BYTE(context, context->pc >> 8);
    PUSH_BYTE(context, context->pc & 0xff);
    PUSH_BYTE(context, (GET_FLAGS(context)) & ~FLAG_B);

    context->flags |= FLAG_I;
    context->flags &= ~FLAG_D;
    
    context->pc = context->readfunc(context->cpu, VECTOR_IRQ_LO);
    context->pc |= context->readfunc(context->cpu, VECTOR_IRQ_HI) << 8;

    context->cycles_left -= 7;
    
}
Esempio n. 7
0
VOID edit_box(LONG tree, WORD sobj)
{
	LONG	obspec; 
	WORD	where, type, exitobj, ok, nilok;
	BYTE	name[9], text[2], bxchar;
	GRECT	p;

	if (rcs_state != ALRT_STATE)
	{
		get_fields(tree, sobj, &type, &obspec, &p);

		ini_tree(&tree, BOXDIAL);
		where = set_obname(tree, BOXNAME, name, ad_view, sobj);
		if ( where != NIL && tree_view() && tree_kind( get_kind(where)) )
			nilok = FALSE;
		else
			nilok = TRUE;
		bxchar = LHIBT(LHIWD(LLGET(obspec)));
		set_text(tree, OCHRITEM, (LONG)ADDR(&text[0]), 2);
		text[0] = bxchar? bxchar: '@';
		text[1] = '\0';

		do {
			exitobj = hndl_dial(tree, OCHRITEM, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, nilok));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			bxchar = (text[0] == '@')? '\0': text[0];
			LLSET(obspec, (LLGET(obspec) & 0xffffffL) | 
				((LONG) ((UWORD) bxchar) << 24));
		}
	}
}
Esempio n. 8
0
VOID edit_icon(LONG tree, WORD sobj)
{
	LONG	obspec, taddr; 
	WORD	where, type, itmp, exitobj, ok;
	GRECT	p;
	BYTE	text[14], valid[2], name[9]; 
	WORD	trule, crule, w, h;

	if (rcs_state != ALRT_STATE)
	{
		get_fields(tree, sobj, &type, &obspec, &p);

		ini_tree(&tree, ICONDIAL);
		where = set_obname(tree, ICONNAME, name, ad_view, sobj);
		taddr = LLGET(obspec);
		set_text(tree, IBTEXT, (LONG)ADDR(&text[0]), 13);
		set_text(tree, IBCHAR, (LONG)ADDR(&valid[0]), 2);
		icon_set(taddr, &text[0], &valid[0]);
		trule = icon_twhich(LWGET(IB_YTEXT(taddr)), LWGET(IB_HICON(taddr)));
		sel_obj(tree, IBTPOS0 + trule);
		itmp = icon_cwhich(LWGET(IB_YCHAR(taddr)),
			gl_hschar, LWGET(IB_HICON(taddr)));
		crule = icon_cwhich(LWGET(IB_XCHAR(taddr)),
			gl_wschar, LWGET(IB_WICON(taddr)));
		crule += 3 * itmp;
		sel_obj(tree, IBCPOS0 + crule);

		do {
			exitobj = hndl_dial(tree, IBTEXT, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			icon_get(taddr, &text[0], &valid[0]);
			itmp = encode(tree, IBTPOS0, 3);
			if (itmp != trule)
			{		
				itmp = icon_tapply(itmp, gl_hschar,
					LWGET(IB_HICON(taddr)));
				LWSET(IB_YTEXT(taddr), itmp);
			}
			LWSET(IB_WTEXT(taddr), (WORD)(gl_wschar * strlen(text)));
			icon_tfix(taddr);
			itmp = encode(tree, IBCPOS0, 9);
			if (itmp != crule)
			{
				crule = itmp;
				itmp = icon_capply(crule / 3, gl_hschar,
					LWGET(IB_HICON(taddr)));
				LWSET(IB_YCHAR(taddr), itmp);
				itmp = icon_capply(crule % 3, gl_wschar,
					LWGET(IB_WICON(taddr)));
				LWSET(IB_XCHAR(taddr), itmp);
			}
			icon_wh(taddr, &w, &h);
			newsize_obj(ad_view, sobj, w, h, FALSE);
		}
		map_tree(tree, ROOT, NIL, (fkt_parm)desel_obj);	/* clear radio buttons */
	}
}
Esempio n. 9
0
*/	DEVICE_CMD Open_File(REBREQ *file)
/*
**		Open the specified file with the given modes.
**
**		Notes:
**		1.	The file path is provided in REBOL format, and must be
**			converted to local format before it is used.
**		2.	REBOL performs the required access security check before
**			calling this function.
**		3.	REBOL clears necessary fields of file structure before
**			calling (e.g. error and size fields).
**
***********************************************************************/
{
	int modes;
	int access = 0;
	int h;
	char *path;
	struct stat info;

	// Posix file names should be compatible with REBOL file paths:
	if (!(path = file->file.path)) {
		file->error = -RFE_BAD_PATH;
		return DR_ERROR;
	}

	// Set the modes:
	modes = O_BINARY | GET_FLAG(file->modes, RFM_READ) ? O_RDONLY : O_RDWR;

	if (GET_FLAGS(file->modes, RFM_WRITE, RFM_APPEND)) {
		modes = O_BINARY | O_RDWR | O_CREAT;
		if (
			GET_FLAG(file->modes, RFM_NEW) ||
			!(
				GET_FLAG(file->modes, RFM_READ) ||
				GET_FLAG(file->modes, RFM_APPEND) ||
				GET_FLAG(file->modes, RFM_SEEK)
			)
		) modes |= O_TRUNC;
	}

	//modes |= GET_FLAG(file->modes, RFM_SEEK) ? O_RANDOM : O_SEQUENTIAL;

	if (GET_FLAG(file->modes, RFM_READONLY))
		access = S_IREAD;
	else
		access = S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH;

	// Open the file:
	// printf("Open: %s %d %d\n", path, modes, access);
	h = open(path, modes, access);
	if (h < 0) {
		file->error = -RFE_OPEN_FAIL;
		goto fail;
	}

	// Confirm that a seek-mode file is actually seekable:
	if (GET_FLAG(file->modes, RFM_SEEK)) {
		if (lseek(h, 0, SEEK_CUR) < 0) {
			close(h);
			file->error = -RFE_BAD_SEEK;
			goto fail;
		}
	}

	// Fetch file size (if fails, then size is assumed zero):
	if (fstat(h, &info) == 0) {
		file->file.size = info.st_size;
		file->file.time.l = (long)(info.st_mtime);
	}

	file->id = h;

	return DR_DONE;

fail:
	return DR_ERROR;
}
Esempio n. 10
0
/* infere file map protection by channel prefix */
static int GetChannelMapProt(struct PreOpenedFileDesc* channel)
{
  GET_FLAGS(CHANNEL_MAP_PROT, channel);
}
Esempio n. 11
0
/* infere file map flags by channel prefix */
static int GetChannelMapFlags(struct PreOpenedFileDesc* channel)
{
  GET_FLAGS(CHANNEL_MAP_FLAGS, channel);
}
Esempio n. 12
0
/* infere file open flags by channel prefix */
static int GetChannelOpenFlags(struct PreOpenedFileDesc* channel)
{
  GET_FLAGS(CHANNEL_OPEN_FLAGS, channel);
}
Esempio n. 13
0
static void Append_Obj(REBSER *obj, REBVAL *arg)
{
	REBCNT i;
	REBCNT len = 0;
	REBVAL *val;
	REBVAL *start = arg;

	// Can be a word:
	if (ANY_WORD(arg)) {
		if (!Find_Word_Index(obj, VAL_WORD_SYM(arg), TRUE)) {
			if (VAL_WORD_CANON(arg) == SYM_SELF) Trap0(RE_SELF_PROTECTED);
			Expand_Frame(obj, 1, 1); // copy word table also
			Append_Frame(obj, 0, VAL_WORD_SYM(arg));
			// val is UNSET
		}
		return;
	}

	if (!IS_BLOCK(arg)) Trap_Arg(arg);

	// Verify word/value argument block:
	for (arg = VAL_BLK_DATA(arg); NOT_END(arg); arg += 2) {

		if (!IS_WORD(arg) && !IS_SET_WORD(arg)) Trap_Arg(arg);

		if (NZ(i = Find_Word_Index(obj, VAL_WORD_SYM(arg), TRUE))) {
			// Just change the value, do not append it.
			val = FRM_VALUE(obj, i);
			if (GET_FLAGS(VAL_OPTS(FRM_WORD(obj, i)), OPTS_HIDE, OPTS_LOCK)) { 
				// Back out... reset any prior flags:
				for (; arg != VAL_BLK_DATA(start); arg -= 2) VAL_CLR_OPT(arg, OPTS_TEMP);
				if (VAL_PROTECTED(FRM_WORD(obj, i))) Trap1(RE_LOCKED_WORD, FRM_WORD(obj, i));
				Trap0(RE_HIDDEN);
			}
			// Problem above: what about prior OPTS_FLAGS? Ok to leave them as is?
			if (IS_END(arg+1)) SET_NONE(val);
			else *val = arg[1];
			VAL_SET_OPT(arg, OPTS_TEMP);
		} else {
			if (VAL_WORD_CANON(arg) == SYM_SELF) Trap0(RE_SELF_PROTECTED);
			len++;
			// was: Trap1(RE_DUP_VARS, arg);
		}
	
		if (IS_END(arg+1)) break; // fix bug#708
	}

	// Append new values to end of frame (if necessary):
	if (len > 0) {
		Expand_Frame(obj, len, 1); // copy word table also
		for (arg = VAL_BLK_DATA(start); NOT_END(arg); arg += 2) {
			if (VAL_GET_OPT(arg, OPTS_TEMP)) VAL_CLR_OPT(arg, OPTS_TEMP);
			else {
				val = Append_Frame(obj, 0, VAL_WORD_SYM(arg));
				if (IS_END(arg+1)) {
					SET_NONE(val);
					break;
				}
				else *val = arg[1];
			}
		}
	}
}
Esempio n. 14
0
void
fetch_info(struct list *lst)
{
	struct fsmntinfo *fmi;
	int nummnt;
	statst *entbuf;
	statst vfsbuf, **fs;
	/* init fsmntinfo */
	if ((fmi = malloc(sizeof(struct fsmntinfo))) == NULL) {
		(void)fputs("Error while allocating memory to fmi", stderr);
		exit(EXIT_FAILURE);
		/* NOTREACHED */
	}
	*fmi = fmi_init();
	if ((nummnt = getmntinfo(&entbuf, MNT_NOWAIT)) <= 0)
		err(EXIT_FAILURE, "Error while getting the list of mountpoints");
		/* NOTREACHED */

	for (fs = &entbuf; nummnt--; (*fs)++) {
		vfsbuf = **fs;
		if ((fmi->fsnameog = strdup(entbuf->f_mntfromname)) == NULL)
			fmi->fsnameog = g_unknown_str;
		if ((fmi->mntdirog = strdup(entbuf->f_mntonname)) == NULL)
			fmi->mntdirog = g_unknown_str;
		if ((fmi->fstypeog = strdup(entbuf->f_fstypename)) == NULL)
			fmi->fstypeog = g_unknown_str;
		if (Wflag) { /* Wflag to avoid name truncation */
			fmi->fsname = fmi->fsnameog;
			fmi->mntdir = fmi->mntdirog;
			fmi->fstype = fmi->fstypeog;
		} else {
			if ((fmi->fsname = strdup(shortenstr(
				entbuf->f_mntfromname, STRMAXLEN))) == NULL) {
				fmi->fsname = g_unknown_str;
			}
			if ((fmi->mntdir = strdup(shortenstr(
				entbuf->f_mntonname, STRMAXLEN))) == NULL) {
				fmi->mntdir = g_unknown_str;
			}
			if ((fmi->fstype = strdup(shortenstr(
				entbuf->f_fstypename, STRMAXLEN))) == NULL) {
				fmi->fstype = g_unknown_str;
			}
		}

		/* infos from statvfs */
		fmi->flags    = GET_FLAGS(vfsbuf);
		fmi->bsize    = vfsbuf.f_bsize;
		fmi->frsize   = GET_FRSIZE(vfsbuf);
		fmi->blocks   = vfsbuf.f_blocks;
		fmi->bfree    = vfsbuf.f_bfree;
		fmi->bavail   = vfsbuf.f_bavail;
		fmi->files    = vfsbuf.f_files;
		fmi->ffree    = vfsbuf.f_ffree;
		fmi->favail   = GET_FAVAIL(vfsbuf);

		if ((fmi->mntopts = statfs_flags_to_str(fmi)) == NULL)
			fmi->mntopts = g_none_str;

		/* compute, available, % used, etc. */
		compute_fs_stats(fmi);

		/* pointer to the next element */
		fmi->next = NULL;

		/* enqueue the element into the queue */
		enqueue(lst, *fmi);

		update_maxwidth(fmi);
	}
	free(fmi);
}
Esempio n. 15
0
File: t-object.c Progetto: Oldes/r3
static void Append_Obj(REBSER *obj, REBVAL *arg)
{
	REBCNT i, len;
	REBVAL *word, *val;
	REBINT *binds; // for binding table

	// Can be a word:
	if (ANY_WORD(arg)) {
		if (!Find_Word_Index(obj, VAL_WORD_SYM(arg), TRUE)) {
			// bug fix, 'self is protected only in selfish frames
			if ((VAL_WORD_CANON(arg) == SYM_SELF) && !IS_SELFLESS(obj))
				Trap0(RE_SELF_PROTECTED);
			Expand_Frame(obj, 1, 1); // copy word table also
			Append_Frame(obj, 0, VAL_WORD_SYM(arg));
			// val is UNSET
		}
		return;
	}

	if (!IS_BLOCK(arg)) Trap_Arg(arg);

	// Process word/value argument block:
	arg = VAL_BLK_DATA(arg);

	// Use binding table
	binds = WORDS_HEAD(Bind_Table);
	// Handle selfless
	Collect_Start(IS_SELFLESS(obj) ? BIND_NO_SELF | BIND_ALL : BIND_ALL);
	// Setup binding table with obj words:
	Collect_Object(obj);

	// Examine word/value argument block
	for (word = arg; NOT_END(word); word += 2) {

		if (!IS_WORD(word) && !IS_SET_WORD(word)) {
			// release binding table
			BLK_TERM(BUF_WORDS);
			Collect_End(obj);
			Trap_Arg(word);
		}

		if (NZ(i = binds[VAL_WORD_CANON(word)])) {
			// bug fix, 'self is protected only in selfish frames:
			if ((VAL_WORD_CANON(word) == SYM_SELF) && !IS_SELFLESS(obj)) {
				// release binding table
				BLK_TERM(BUF_WORDS);
				Collect_End(obj);
				Trap0(RE_SELF_PROTECTED);
			}
		} else {
			// collect the word
			binds[VAL_WORD_CANON(word)] = SERIES_TAIL(BUF_WORDS);
			EXPAND_SERIES_TAIL(BUF_WORDS, 1);
			val = BLK_LAST(BUF_WORDS);
			*val = *word;
		}
		if (IS_END(word + 1)) break; // fix bug#708
	}

	BLK_TERM(BUF_WORDS);

	// Append new words to obj
	len = SERIES_TAIL(obj);
	Expand_Frame(obj, SERIES_TAIL(BUF_WORDS) - len, 1);
	for (word = BLK_SKIP(BUF_WORDS, len); NOT_END(word); word++)
		Append_Frame(obj, 0, VAL_WORD_SYM(word));

	// Set new values to obj words
	for (word = arg; NOT_END(word); word += 2) {

		i = binds[VAL_WORD_CANON(word)];
		val = FRM_VALUE(obj, i);
		if (GET_FLAGS(VAL_OPTS(FRM_WORD(obj, i)), OPTS_HIDE, OPTS_LOCK)) { 
			// release binding table
			Collect_End(obj);
			if (VAL_PROTECTED(FRM_WORD(obj, i)))
				Trap1(RE_LOCKED_WORD, FRM_WORD(obj, i));
			Trap0(RE_HIDDEN);
		}

		if (IS_END(word + 1)) SET_NONE(val);
		else *val = word[1];

		if (IS_END(word + 1)) break; // fix bug#708
	}

	// release binding table
	Collect_End(obj);
}
Esempio n. 16
0
    context->flags |= FLAG_I;
    context->flags &= ~FLAG_D;
    
    context->pc = context->readfunc(context->cpu, VECTOR_IRQ_LO);
    context->pc |= context->readfunc(context->cpu, VECTOR_IRQ_HI) << 8;

    context->cycles_left -= 7;
    
}

void cpu6502_nmi(struct cpu6502_context *context)
{
    PUSH_BYTE(context, context->pc >> 8);
    PUSH_BYTE(context, context->pc & 0xff);
    PUSH_BYTE(context, (GET_FLAGS(context)) & ~FLAG_B);

    context->pc = context->readfunc(context->cpu, VECTOR_NMI_LO);
    context->pc |= context->readfunc(context->cpu, VECTOR_NMI_HI) << 8;

    context->cycles_left -= 7;
}

#ifdef LAZY_FLAG_EVALUATION
u8 cpu6502_get_flags(struct cpu6502_context *context)
{
    u8 retval;

    retval = context->flags;
    retval &= ~(FLAG_N | FLAG_Z | FLAG_V | FLAG_C);
    retval |= context->flag_n & FLAG_N;
Esempio n. 17
0
VOID edit_text(LONG tree, WORD sobj)
{
	LONG	obspec, taddr; 
	WORD	min_width, where, type, deftext, w, h, exitobj, ok;
	GRECT	p;
	BYTE	text[73], valid[73], tmplt[73], name[9]; 

	if (rcs_state != ALRT_STATE)
	{
		get_fields(tree, sobj, &type, &obspec, &p);
		taddr = LLGET(obspec);
		if (type == G_FTEXT || type == G_FBOXTEXT)
			if (LSTRLEN(LLGET(TE_PTMPLT(taddr))) > 72)
				return;
		ini_tree(&tree, TEXTDIAL);
		where = set_obname(tree, TEXTNAME, name, ad_view, sobj);
		set_text(tree, OTMPITEM, (LONG)ADDR(&tmplt[0]), 73);
		set_text(tree, OVALITEM, (LONG)ADDR(&valid[0]), 73);
		set_text(tree, OTEXITEM, (LONG)ADDR(&text[0]), 73);
		LLSTRCPY(LLGET(TE_PTMPLT(taddr)), (LONG)ADDR(&tmplt[0]));
		ted_set(taddr, &tmplt[0], &valid[0], &text[0]);

		if (type == G_TEXT || type == G_BOXTEXT)
		{
			if (LSTRLEN(LLGET(TE_PTEXT(taddr))) > 72)
				return;
			hide_obj(tree, TMPLTTAG);
			hide_obj(tree, OTMPITEM);
			hide_obj(tree, VALIDTAG);
			hide_obj(tree, OVALITEM);
			deftext = OTEXITEM;
		}		   
		else
			deftext = (tmplt[0] != '@')? OTMPITEM: OTEXITEM;
		do {
			exitobj = hndl_dial(tree, deftext, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			ted_get(taddr, &tmplt[0], &valid[0], &text[0]);
			if (type == G_TEXT || type == G_FTEXT || type == G_BOXTEXT)
			{
				text_wh(taddr, type, &w, &h);
				min_width = GET_WIDTH(ad_view, sobj);
				if ( w > min_width)
					newsize_obj(ad_view, sobj, w, h, TRUE);
			}
		}

		unhide_obj(tree,TMPLTTAG);
		unhide_obj(tree,OTMPITEM);
		unhide_obj(tree, VALIDTAG);
		unhide_obj(tree,OVALITEM);
		map_tree(tree, ROOT, NIL, (fkt_parm)desel_obj);	/* clear radio buttons */
	}
}
Esempio n. 18
0
VOID edit_str(LONG tree, WORD sobj)
{
	LONG	obspec; 
	WORD	where, type, exitobj, ok;
	GRECT	p;
	WORD	min_width, neww, len; 
	BYTE	text[73], name[9]; 

	get_fields(tree, sobj, &type, &obspec, &p);
	len = (WORD)LSTRLEN(LLGET(obspec));
	if (len <= 72)
	{
		ini_tree(&tree, STRDIAL);
		where = set_obname(tree, STRNAME, name, ad_view, sobj);
		set_text(tree, OSTRITEM, (LONG)ADDR(&text[0]), 73);
		LLSTRCPY(LLGET(obspec), (LONG)ADDR(&text[0]));
		if ( rcs_state == ALRT_STATE )
			hide_obj( tree, STRNAME);
		if (!text[0])
			text[0] = '@';
		do {
			exitobj = hndl_dial(tree, OSTRITEM, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while ( ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			if (text[0] == '@')
				text[0] = '\0';

			if (rcs_state == ALRT_STATE)
			{		
				if (strlen(text) > 40 )
				{
					hndl_alert(1, string_addr(STOOLONG));
					text[40] = '\0';
				}
				update_if(obspec, &text[0]);
				fix_alert(ad_view);
				unhide_obj(tree, STRNAME);
			}
			else
			{
				neww = (WORD)(gl_wchar * strlen(text));
				if (rcs_state == MENU_STATE)
				{
					if (type == G_TITLE)
					{
						if (!newsize_obj(ad_view, sobj, neww,gl_hchar, TRUE))
							text[len] = '\0';
						fix_menu_bar(ad_view);
					}
					else if (in_which_menu(ad_view, sobj) == 1
						&& in_menu(ad_view, sobj) == 1
						&& strlen(text) > 20 )
		    		{
						hndl_alert(1, string_addr(STOOLONG));	
						text[20] = '\0';
					}
					else  if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
						text[len] = '\0';
				}
				else if (type == G_STRING || type == G_BUTTON )
				{
					min_width = GET_WIDTH(ad_view, sobj);
					if( neww > min_width )
						if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
							text[len] = '\0';
				}
			}
			if( rcs_state != ALRT_STATE)
				update_if(obspec, &text[0]);
		}
	}
}