示例#1
0
文件: niii.c 项目: c00kiemon5ter/niii
static void readinput(void) {
    char *input;
    if ((input = calloc(1, LINE_MAX)) == NULL)
        err(EXIT_FAILURE, "failed to allocate space for input");

    int r = wgetnstr(winp, input, LINE_MAX);
    updatewinp();

    if (r == ERR) readout();
    else if (r == KEY_RESIZE) redrawall();
    else if (input == NULL) return;
    else if (strlen(input) == 0) redrawall();
    else if (strcmp(input, ESCSYMB) == 0) running = false;
    else sendmesg(input);
}
示例#2
0
void MCScrollbar::munfocus()
{
	if (MCcurtheme && hover_part != WTHEME_PART_UNDEFINED && MCcurtheme->getthemepropbool(WTHEME_PROP_SUPPORTHOVERING))
	{
		hover_part = WTHEME_PART_UNDEFINED;
		// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
		redrawall();
	}
	MCControl::munfocus();
}
void MCScrollbar::Redraw(bool dirty)
{
	flags |= F_SAVE_ATTS;

	if (!opened || !dirty)
		return;

	compute_barsize();
	// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
	redrawall();
}
示例#4
0
文件: niii.c 项目: c00kiemon5ter/niii
static void createwins(void) {
    /* start curses mode - do not buffer input */
    initscr();
    cbreak();
    /* start color support and set up color pairs */
    if (has_colors() == TRUE) {
        start_color();
        init_pair(DATETIME,  COLOR_CYAN,  COLOR_BLACK);
        init_pair(NICK,      COLOR_GREEN, COLOR_BLACK);
        init_pair(SEPARATOR, COLOR_CYAN,  COLOR_BLACK);
        init_pair(MESG,      COLOR_WHITE, COLOR_BLACK);
        init_pair(WINP,      COLOR_GREEN, COLOR_BLACK);
    }
    /* create the windows and add contents */
    redrawall();
}
示例#5
0
Boolean MCScrollbar::mdown(uint2 which)
{
	if (state & CS_MFOCUSED)
		return False;
	if (state & CS_MENU_ATTACHED)
		return MCObject::mdown(which);
	state |= CS_MFOCUSED;
	if (!IsMacEmulatedLF() && flags & F_TRAVERSAL_ON && !(state & CS_KFOCUSED))
		getstack()->kfocusset(this);
	uint2 margin;
	MCRectangle brect = compute_bar();
	if (flags & F_SCALE)
		margin = 0;
	else
		if (getstyleint(flags) == F_VERTICAL)
			margin = brect.width - 1;
		else
			margin = brect.height - 1;
	Tool tool = state & CS_NO_MESSAGES ? T_BROWSE : getstack()->gettool(this);
	MCWidgetInfo winfo;
	winfo.type = (Widget_Type)getwidgetthemetype();
	switch (which)
	{
	case Button1:
		switch (tool)
		{
		case T_BROWSE:
			message_with_args(MCM_mouse_down, "1");
			if (flags & F_PROGRESS) //progress bar does not respond to mouse down event
				return False;
			if (MCcurtheme && MCcurtheme->iswidgetsupported(winfo.type))
			{
				getwidgetthemeinfo(winfo);
				Widget_Part wpart = MCcurtheme->hittest(winfo,mx,my,rect);
				// scrollbar needs to check first if mouse-down occured in arrows
				switch (wpart)
				{
				case WTHEME_PART_ARROW_DEC:
					if (MCmodifierstate & MS_SHIFT)
						mode = SM_BEGINNING;
					else
						mode = SM_LINEDEC;
					break;
				case WTHEME_PART_ARROW_INC:
					if (MCmodifierstate & MS_SHIFT)
						mode = SM_END;
					else
						mode = SM_LINEINC;
					break;
				case WTHEME_PART_TRACK_DEC:
					mode = SM_PAGEDEC;
					break;
				case WTHEME_PART_TRACK_INC:
					mode = SM_PAGEINC;
					break;
				}
			}
			else
			{ //Non-theme appearence stuff: for vertical scrollbar or scale
				if (getstyleint(flags) == F_VERTICAL)
				{
					uint2 height;
					if (brect.height <= margin << 1)
						height = 1;
					else
						height = brect.height - (margin << 1);
					markpos = (my - (brect.y + margin))
					          * fabs(endvalue - startvalue) / height;
					if (my < brect.y + margin)
						if (MCmodifierstate & MS_SHIFT)
							mode = SM_BEGINNING;
						else
							mode = SM_LINEDEC;
					else
						if (my > brect.y + brect.height - margin)
							if (MCmodifierstate & MS_SHIFT)
								mode = SM_END;
							else
								mode = SM_LINEINC;
						else
						{
							MCRectangle thumb = compute_thumb(thumbpos);
							if (my < thumb.y)
								mode = SM_PAGEDEC;
							else
								if (my > thumb.y + thumb.height)
									mode = SM_PAGEINC;
						}
				}
				else
				{ //for Horizontal scrollbar or scale
					uint2 width;
					if (brect.width <= (margin << 1))
						width = 1;
					else
						width = brect.width - (margin << 1);
					markpos = (mx - (brect.x + margin))
					          * fabs(endvalue - startvalue) / width;
					if (mx < brect.x + margin)
						if (MCmodifierstate & MS_SHIFT)
							mode = SM_BEGINNING;
						else
							mode = SM_LINEDEC;
					else
						if (mx > brect.x + brect.width - margin)
							if (MCmodifierstate & MS_SHIFT)
								mode = SM_END;
							else
								mode = SM_LINEINC;
						else
						{
							MCRectangle thumb = compute_thumb(thumbpos);
							if (mx < thumb.x)
								mode = SM_PAGEDEC;
							else
								if (mx > thumb.x + thumb.width)
									mode = SM_PAGEINC;
						}
				}
			} //end of Non-MAC-Appearance Manager stuff
			switch (mode)
			{
			case SM_BEGINNING:
				update(0, MCM_scrollbar_beginning);
				break;
			case SM_END:
				update(endvalue, MCM_scrollbar_end);
				break;
			case SM_LINEDEC:
			case SM_LINEINC:
				timer(MCM_internal, NULL);
				redrawarrow(mode);
				break;
			case SM_PAGEDEC:
			case SM_PAGEINC:
				timer(MCM_internal, NULL);
				break;
			default:
				state |= CS_SCROLL;
				markpos = thumbpos;
				if (IsMacEmulatedLF())
					movethumb(thumbpos--);
				else if (MCcurtheme)
				{
					// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
					redrawall();
				}
			}
			break;
		case T_POINTER:
		case T_SCROLLBAR:
			start(True);
			break;
		case T_HELP:
			break;
		default:
			return False;
		}
		break;
	case Button2:
		if (message_with_args(MCM_mouse_down, "2") == ES_NORMAL)
			return True;
		state |= CS_SCROLL;
		{
			real8 newpos;
			real8 range = endvalue - startvalue;
			real8 offset = startvalue;
			if (flags & F_SCALE)
				margin = MOTIF_SCALE_THUMB_SIZE >> 1;
			else
				if (MCproportionalthumbs)
					if (startvalue > endvalue)
						offset += thumbsize / 2.0;
					else
						offset -= thumbsize / 2.0;
				else
					margin = FIXED_THUMB_SIZE >> 1;
			if (getstyleint(flags) == F_VERTICAL)
				newpos = (my - brect.y - margin) * range
				         / (brect.height - (margin << 1)) + offset;
			else
				newpos = (mx - brect.x - margin) * range
				         / (brect.width - (margin << 1)) + offset;
			update(newpos, MCM_scrollbar_drag);
			markpos = thumbpos;
		}
		break;
	case Button3:
		message_with_args(MCM_mouse_down, "3");
		break;
	}
示例#6
0
Boolean MCScrollbar::mfocus(int2 x, int2 y)
{
	// MW-2007-09-18: [[ Bug 1650 ]] Disabled state linked to thumb size
	if (!(flags & F_VISIBLE || MCshowinvisibles)
	        || issbdisabled() && getstack()->gettool(this) == T_BROWSE)
		return False;
	if (state & CS_SCROLL)
	{
		// I.M. [[bz 9559]] disable scrolling where start value & end value are the same
		if (startvalue == endvalue)
			return True;

		real8 newpos;

		double t_thumbsize = thumbsize;
		if (t_thumbsize > fabs(endvalue - startvalue))
			t_thumbsize = fabs(endvalue - startvalue);
		if (flags & F_SCALE)
			t_thumbsize = 0;

		bool t_forward;
		t_forward = (endvalue > startvalue);
		MCRectangle t_bar_rect, t_thumb_rect, t_thumb_start_rect, t_thumb_end_rect;
		t_bar_rect = compute_bar();
		t_thumb_rect = compute_thumb(markpos);
		t_thumb_start_rect = compute_thumb(startvalue);
		if (t_forward)
			t_thumb_end_rect = compute_thumb(endvalue - t_thumbsize);
		else
			t_thumb_end_rect = compute_thumb(endvalue + t_thumbsize);

		int32_t t_bar_start, t_bar_length, t_thumb_start, t_thumb_length;
		int32_t t_movement;
		if (getstyleint(flags) == F_VERTICAL)
		{
			t_bar_start = t_thumb_start_rect.y;
			t_bar_length = t_thumb_end_rect.y + t_thumb_end_rect.height - t_bar_start;
			t_thumb_start = t_thumb_rect.y;
			t_thumb_length = t_thumb_rect.height;
			t_movement = y - my;
		}
		else
		{
			t_bar_start = t_thumb_start_rect.x;
			t_bar_length = t_thumb_end_rect.x + t_thumb_end_rect.width - t_bar_start;
			t_thumb_start = t_thumb_rect.x;
			t_thumb_length = t_thumb_rect.width;
			t_movement = x - mx;
		}

		t_bar_start += t_thumb_length / 2;
		t_bar_length -= t_thumb_length;

        // AL-2013-07-26: [[ Bug 11044 ]] Prevent divide by zero when computing scrollbar thumbposition
        if (t_bar_length == 0)
            t_bar_length = 1;
        
		int32_t t_new_position;
		t_new_position = t_thumb_start + t_thumb_length / 2 + t_movement;
		t_new_position = MCU_min(t_bar_start + t_bar_length, MCU_max(t_bar_start, t_new_position));
		
		if (t_forward)
			newpos = startvalue + ((t_new_position - t_bar_start) / (double)t_bar_length) * (fabs(endvalue - startvalue) - t_thumbsize);
		else
			newpos = startvalue - ((t_new_position - t_bar_start) / (double)t_bar_length) * (fabs(endvalue - startvalue) - t_thumbsize);

		update(newpos, MCM_scrollbar_drag);
		return True;
	}
	else if (!MCdispatcher -> isdragtarget() && MCcurtheme && MCcurtheme->getthemepropbool(WTHEME_PROP_SUPPORTHOVERING)
	         && MCU_point_in_rect(rect, x, y) )
	{
		if (!(state & CS_MFOCUSED) && !getstate(CS_SELECTED))
		{
			MCWidgetInfo winfo;
			winfo.type = (Widget_Type)getwidgetthemetype();
			if (MCcurtheme->iswidgetsupported(winfo.type))
			{
				getwidgetthemeinfo(winfo);
				Widget_Part wpart = MCcurtheme->hittest(winfo,mx,my,rect);
				if (wpart != hover_part)
				{
					hover_part = wpart;
					// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
					redrawall();
				}
			}
		}
	}
	return MCControl::mfocus(x, y);
}