Esempio n. 1
0
static int
view_event (Gpm_Event *event, void *x)
{
    WDiff *view = (WDiff *)x;
    int result = MOU_NORMAL;
    struct display_file *lf = &view->df[view->ord];
    struct display_file *rf = &view->df[view->ord ^ 1];

    /* We are not interested in the release events */
    if (!(event->type & (GPM_DOWN | GPM_DRAG))) {
	return result;
    }

    /* Wheel events */
    if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
	if (lf->move) lf->offs -= view->nbytes;
	if (rf->move) rf->offs -= view->nbytes;
	view_update(view);
	return result;
    }
    if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN)) {
	if (lf->move) lf->offs += view->nbytes;
	if (rf->move) rf->offs += view->nbytes;
	view_update(view);
	return result;
    }

    return result;
}
Esempio n. 2
0
static void views_sidebar_update(gint page_num, DebugState state)
{
	GtkWidget *page = gtk_notebook_get_nth_page(geany_sidebar, page_num);

	if (page == inspect_page)
		view_update(VIEW_INSPECT, state);
	else if (page == register_page)
		view_update(VIEW_REGISTERS, state);
}
Esempio n. 3
0
void on_event(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata)
{
    if((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK_INPUT) {
        /* sink input changed */
        if((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE) {
            if(idx != PA_INVALID_INDEX)
                pa_context_get_sink_input_info(c, idx, on_sink_input_update, NULL);
        }
        /* sink input removed */
        if((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
            if(idx != PA_INVALID_INDEX) {
                sink_input_remove(idx);
                view_update();
            }
        }
        /* sink input added */
        if((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
            if(idx != PA_INVALID_INDEX)
                pa_context_get_sink_input_info(c, idx, on_sink_input_update, NULL);
        }
    }
    if((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK) {
        /* sink changed */
        if((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE) {
            if(idx != PA_INVALID_INDEX)
                pa_context_get_sink_info_by_index(c, idx, on_sink_update, NULL);
        }
    }
}
Esempio n. 4
0
void debug_view_watchpoints::view_click(const int button, const debug_view_xy& pos)
{
	bool clickedTopRow = (m_topleft.y == pos.y);

	if (clickedTopRow)
	{
		if (pos.x < tableBreaks[0] && m_sortType == SORT_INDEX_ASCENDING)
			m_sortType = SORT_INDEX_DESCENDING;
		else if (pos.x < tableBreaks[0])
			m_sortType = SORT_INDEX_ASCENDING;
		else if (pos.x < tableBreaks[1] && m_sortType == SORT_ENABLED_ASCENDING)
			m_sortType = SORT_ENABLED_DESCENDING;
		else if (pos.x < tableBreaks[1])
			m_sortType = SORT_ENABLED_ASCENDING;
		else if (pos.x < tableBreaks[2] && m_sortType == SORT_CPU_ASCENDING)
			m_sortType = SORT_CPU_DESCENDING;
		else if (pos.x < tableBreaks[2])
			m_sortType = SORT_CPU_ASCENDING;
		else if (pos.x < tableBreaks[3] && m_sortType == SORT_SPACE_ASCENDING)
			m_sortType = SORT_SPACE_DESCENDING;
		else if (pos.x < tableBreaks[3])
			m_sortType = SORT_SPACE_ASCENDING;
		else if (pos.x < tableBreaks[4] && m_sortType == SORT_ADDRESS_ASCENDING)
			m_sortType = SORT_ADDRESS_DESCENDING;
		else if (pos.x < tableBreaks[4])
			m_sortType = SORT_ADDRESS_ASCENDING;
		else if (pos.x < tableBreaks[5] && m_sortType == SORT_TYPE_ASCENDING)
			m_sortType = SORT_TYPE_DESCENDING;
		else if (pos.x < tableBreaks[5])
			m_sortType = SORT_TYPE_ASCENDING;
		else if (pos.x < tableBreaks[6] && m_sortType == SORT_CONDITION_ASCENDING)
			m_sortType = SORT_CONDITION_DESCENDING;
		else if (pos.x < tableBreaks[6])
			m_sortType = SORT_CONDITION_ASCENDING;
		else if (pos.x < tableBreaks[7] && m_sortType == SORT_ACTION_ASCENDING)
			m_sortType = SORT_ACTION_DESCENDING;
		else if (pos.x < tableBreaks[7])
			m_sortType = SORT_ACTION_ASCENDING;
	}
	else
	{
		// Gather a sorted list of all the watchpoints for all the CPUs
		device_debug::watchpoint** wpList = NULL;
		const int numWPs = watchpoints(SORT_NONE, wpList);

		const int wpIndex = pos.y-1;
		if (wpIndex > numWPs || wpIndex < 0)
			return;

		// Enable / disable
		if (wpList[wpIndex]->enabled())
			wpList[wpIndex]->setEnabled(false);
		else
			wpList[wpIndex]->setEnabled(true);

		delete[] wpList;
	}

	view_update();
}
Esempio n. 5
0
void debug_view::end_update()
{
	/* if we hit zero, call the update function */
	if (m_update_level == 1)
	{
		while (m_update_pending)
		{
			// no longer pending, but flag for the OSD
			m_update_pending = false;
			m_osd_update_pending = true;

			// resize the viewdata if needed
			int size = m_visible.x * m_visible.y;
			if (size > m_viewdata_size)
			{
				m_viewdata_size = size;
				auto_free(machine(), m_viewdata);
				m_viewdata = auto_alloc_array(machine(), debug_view_char, m_viewdata_size);
			}

			// update the view
			view_update();
		}
	}

	// decrement the level
	m_update_level--;
}
Esempio n. 6
0
void
area_focus(Area *a) {
	Frame *f;
	View *v;
	Area *old_a;

	v = a->view;
	f = a->sel;
	old_a = v->sel;

	if(!a->floating && view_fullscreen_p(v, a->screen))
		return;

	v->sel = a;
	if(!a->floating) {
		v->selcol = area_idx(a);
		v->selscreen = a->screen;
	}
	if(a != old_a)
		v->oldsel = nil;

	if(old_a && a->floating != old_a->floating) {
		v->revert = old_a;
		if(v->floating->max)
			view_update(v);
	}

	if(v == selview) {
		move_focus(old_a->sel, f);
		client_focus(f ? f->client : nil);

		if(a != old_a)
			event("AreaFocus %a\n", a);
	}
}
Esempio n. 7
0
File: auth.c Progetto: firejox/mils
static char* retrieve_input (auth_t *au) {
    int timeout = -1, ret;
    data_handler_t *dht;
    struct epoll_event tmp;
    keysym_t sym;
    char *str;

    view_update (au->v, au->cur_v);
    while ((ret = epoll_wait (au->epfd, &tmp, 1, timeout)) > -1) {
        if (ret) {
            dht = tmp.data.ptr;
            dht->handler (dht->fd, dht->data);
        }

        sym = get_input_state_info (au->ist, &timeout);
        switch (sym) {
        case XKB_KEY_NoSymbol:
            break;
        case XKB_KEY_Return:
            goto input_end;
        case XKB_KEY_BackSpace:
            line_text_handle_event (au->cur_lt, DELETE_LEFT_CH);
            break;
        case XKB_KEY_Delete:
            line_text_handle_event (au->cur_lt, DELETE_RIGHT_CH);
            break;
        case XKB_KEY_Left:
            line_text_handle_event (au->cur_lt, CURSOR_MOVE_LEFT);
            break;
        case XKB_KEY_Right:
            line_text_handle_event (au->cur_lt, CURSOR_MOVE_RIGHT);
            break;
        default:
            line_text_handle_event (au->cur_lt, APPEND_CH, keysym_to_utf32(sym));
            break;
        }
        if (sym != XKB_KEY_NoSymbol)
            view_update (au->v, au->cur_v);

    }

input_end:
    str = line_text_to_string (au->cur_lt);
    line_text_unref (au->cur_lt);
    return str;
}
static void 
update_view_foreach (BonoboView *view, void *data)
{
	view_data_t *view_data;

	view_data = g_object_get_data (G_OBJECT (view), "view_data");
	view_update (view_data);
}
Esempio n. 9
0
static cb_ret_t
view_callback (Widget *w, widget_msg_t msg, int parm)
{
    cb_ret_t i;
    WDiff *view = (WDiff *)w;
    Dlg_head *h = view->widget.parent;

    switch (msg) {
	case WIDGET_INIT:
	    view_labels(view);
	    return MSG_HANDLED;

	case WIDGET_DRAW:
	    view->new_frame = 1;
	    view_update(view);
	    return MSG_HANDLED;

	case WIDGET_CURSOR:
	    return MSG_HANDLED;

	case WIDGET_KEY:
	    i = view_handle_key((WDiff *)view, parm);
	    if (view->view_quit)
		dlg_stop(h);
	    else {
		view_update(view);
	    }
	    return i;

	case WIDGET_IDLE:
	    return MSG_HANDLED;

	case WIDGET_FOCUS:
	    view_labels(view);
	    return MSG_HANDLED;

	case WIDGET_DESTROY:
	    return MSG_HANDLED;

	default:
	    return default_proc(msg, parm);
    }
}
Esempio n. 10
0
void views_update(DebugState state)
{
	if (option_update_all_views)
	{
		ViewIndex i;

		if (thread_state == THREAD_QUERY_FRAME)
		{
			if (!views[VIEW_THREADS].dirty)
				thread_query_frame('4');

			thread_state = THREAD_STOPPED;
		}

		for (i = 0; i < VIEW_COUNT; i++)
		{
			if (views[i].dirty)
			{
				view_update_unconditional(i, state);

				if (i == VIEW_STACK && thread_state >= THREAD_STOPPED)
					i = VIEW_WATCHES;
			}
		}
	}
	else
	{
		if (thread_state == THREAD_QUERY_FRAME)
		{
			if (view_current != VIEW_THREADS || !views[VIEW_THREADS].dirty)
				thread_query_frame('4');

			thread_state = THREAD_STOPPED;
		}

		view_update(view_current, state);
		view_update(VIEW_TOOLTIP, state);

		if (inspects_current())
			view_update(VIEW_INSPECT, state);
	}
}
Esempio n. 11
0
static void ui_window_resize(UiCursesWin *win, int width, int height) {
	win->width = width;
	win->height = height;
	if (win->winstatus)
		wresize(win->winstatus, 1, width);
	wresize(win->win, win->winstatus ? height - 1 : height, width - win->sidebar_width);
	if (win->winside)
		wresize(win->winside, height-1, win->sidebar_width);
	view_resize(win->view, width - win->sidebar_width, win->winstatus ? height - 1 : height);
	view_update(win->view);
}
Esempio n. 12
0
void views_update(DebugState state)
{
	if (option_update_all_views)
	{
		ViewIndex i;
		gboolean skip_frame = FALSE;

		if (thread_state == THREAD_QUERY_FRAME)
		{
			if (!views[VIEW_THREADS].dirty)
				thread_query_frame('4');

			thread_state = THREAD_STOPPED;
		}

		for (i = 0; i < VIEW_COUNT; i++)
		{
			if (views[i].dirty && (!skip_frame || views[i].context != VC_FRAME))
			{
				view_update_dirty(i, state);

				if (i == VIEW_STACK && thread_state >= THREAD_STOPPED)
					skip_frame = TRUE;
			}
		}
	}
	else
	{
		if (thread_state == THREAD_QUERY_FRAME)
		{
			if (view_current != VIEW_THREADS || !views[VIEW_THREADS].dirty)
				thread_query_frame('4');

			thread_state = THREAD_STOPPED;
		}

		view_update(view_current, state);
		view_update(VIEW_TOOLTIP, state);
		views_sidebar_update(gtk_notebook_get_current_page(geany_sidebar), state);
	}
}
Esempio n. 13
0
void on_client_update(pa_context *c, const pa_client_info * info, int eol, void *userdata)
{
    if(eol) {
        view_update();
    } else {
        sink_input_t * sink_input = sink_input_by_client_index(info->index);
        if(sink_input != NULL) {
            free(sink_input->client_name); 
            sink_input->client_name = strdup(info->name);
        }
    }
}
Esempio n. 14
0
void on_sink_update(pa_context * c, const pa_sink_info * info, int eol, void * userdata)
{
    if(eol) {
        view_update();
    } else {
        if(info->index != PA_INVALID_INDEX) {
            sink_t * sink = sink_by_index(info->index);
            if(sink == NULL) {
                sink_add(info);
            } else {
                sink->volume = info->volume;
            }
        }
    }
}
Esempio n. 15
0
Area*
column_new(View *v, Area *pos, int scrn, uint w) {
	Area *a;

	assert(!pos || !pos->floating && pos->screen == scrn);
	a = area_create(v, pos, scrn, w);
	return a;
#if 0
	if(!a)
		return nil;

	view_arrange(v);
	view_update(v);
#endif
}
Esempio n. 16
0
void
column_resize(Area *a, int w) {
	Area *an;
	int dw;

	an = a->next;
	assert(an != nil);

	dw = w - Dx(a->r);
	a->r.max.x += dw;
	an->r.min.x += dw;

	/* view_arrange(a->view); */
	view_update(a->view);
}
Esempio n. 17
0
File: area.c Progetto: bartman/wmii
void
area_focus(Area *a) {
	Frame *f;
	View *v;
	Area *old_a;

	v = a->view;
	f = a->sel;
	old_a = v->sel;

	if(!a->floating && view_fullscreen_p(v, a->screen))
		return;

	v->sel = a;
	if(!a->floating) {
		v->selcol = area_idx(a);
		v->selscreen = a->screen;
	}
	if(a != old_a)
		v->oldsel = nil;

	if((old_a) && (a->floating != old_a->floating)) {
		v->revert = old_a;
		if(v->floating->max)
			view_update(v);
	}

	if(v != selview)
		return;

	move_focus(old_a->sel, f);

	if(f)
		client_focus(f->client);
	else
		client_focus(nil);

	if(a != old_a) {
		event("AreaFocus %a\n", a);
		/* Deprecated */
		if(a->floating)
			event("FocusFloating\n");
		else
			event("ColumnFocus %d\n", area_idx(a));
	}
}
Esempio n. 18
0
void core_loop(void) {

    SDL_Event event;
    while (! app.exit) {
        while (SDL_PollEvent(&event)) {
            event_handle(&event);
        }

        if (! timer.paused) {
            process_update();
            view_update();
        }
        view_render();

        timer_step();
    }
}
static void
scrollbar_moved (GtkAdjustment *adj, WView *view)
{
	if (adj->value == view->start_display)
		return;
	
	if (adj->value < view->start_display){
		while (adj->value < view->start_display)
			view_move_backward (view, 1);
	} else {
		while (adj->value > view->start_display)
			view_move_forward (view, 1);
	}

	/* To force a display */
	view->dirty = max_dirt_limit + 1;
	view_update (view);
}
Esempio n. 20
0
void
column_resizeframe(Frame *f, Rectangle r) {
	Area *a, *al, *ar;
	View *v;
	uint minw;

	a = f->area;
	v = a->view;

	minw = column_minwidth();

	al = a->prev;
	ar = a->next;

	if(al)
		r.min.x = max(r.min.x, al->r.min.x + minw);
	else { /* Hm... */
		r.min.x = max(r.min.x, v->r[a->screen].min.x);
		r.max.x = max(r.max.x, r.min.x + minw);
	}

	if(ar)
		r.max.x = min(r.max.x, ar->r.max.x - minw);
	else {
		r.max.x = min(r.max.x, v->r[a->screen].max.x);
		r.min.x = min(r.min.x, r.max.x - minw);
	}

	a->r.min.x = r.min.x;
	a->r.max.x = r.max.x;
	if(al) {
		al->r.max.x = a->r.min.x;
		column_arrange(al, false);
	}
	if(ar) {
		ar->r.min.x = a->r.max.x;
		column_arrange(ar, false);
	}

	column_resizeframe_h(f, r);

	view_update(v);
}
Esempio n. 21
0
static void
view_goto_cmd (WDiff *view)
{
    static char prev[256];
    /* XXX some statics here, to be remembered between runs */

    off_t address;
    char *input;

    input = input_dialog(_(" Goto Address "), _(" Enter Address: "), prev);
    if (input != NULL) {
	const char *s = input;
	if (scan_unsigned(&s, &address) == 0 && *s == '\0') {
	    if (view->df[0].move) view->df[0].offs = address;
	    if (view->df[1].move) view->df[1].offs = address;
	    view->last_found = -1;
	    view_update(view);
	}
	g_free(input);
    }
}
Esempio n. 22
0
void
float_arrange(Area *a) {
	Frame *f;

	assert(a->floating);

	switch(a->mode) {
	case Coldefault:
		break;
	case Colstack:
		for(f=a->frame; f; f=f->anext)
			f->collapsed = !(f->client->w.ewmh.type & (TypeDock|TypeMenu|TypeToolbar))
				    && (f != a->sel);
		break;
	default:
		die("not reached");
		break;
	}
	for(f=a->frame; f; f=f->anext)
		f->r = f->floatr;
	view_update(a->view);
}
Esempio n. 23
0
void debug_view::end_update()
{
	/* if we hit zero, call the update function */
	if (m_update_level == 1)
	{
		while (m_update_pending)
		{
			// no longer pending, but flag for the OSD
			m_update_pending = false;
			m_osd_update_pending = true;

			// resize the viewdata if needed
			m_viewdata.resize(m_visible.x * m_visible.y);

			// update the view
			view_update();
		}
	}

	// decrement the level
	m_update_level--;
}
Esempio n. 24
0
void on_sink_input_update(pa_context * c, const pa_sink_input_info * info, int eol, void * userdata)
{
    if (eol) {
        view_update();
    } else {
        if(info->has_volume) {
            if(info->index != PA_INVALID_INDEX) {
                sink_input_t * sink_input = sink_input_by_index(info->index);
                if(sink_input == NULL) {
                    sink_input_add(info);
                    if(info->client != PA_INVALID_INDEX)
                        pa_context_get_client_info(c, info->client, on_client_update, NULL);
                } else {
                    sink_input->volume = info->volume;

                    if(sink_input->name == NULL || strcmp(sink_input->name, info->name) != 0) {
                        free(sink_input->name);
                        sink_input->name = strdup(info->name);
                    }
                }
            }
        }
    } 
}
Esempio n. 25
0
File: vis.c Progetto: ewqasd200g/vis
void vis_update(Vis *vis) {
	for (Win *win = vis->windows; win; win = win->next)
		view_update(win->view);
	view_update(vis->win->view);
	vis->ui->update(vis->ui);
}
Esempio n. 26
0
static cb_ret_t
view_handle_key (WDiff *view, int c)
{
    struct display_file *lf = &view->df[view->ord];
    struct display_file *rf = &view->df[view->ord ^ 1];

    c = convert_from_input_c(c);

    switch (c) {
	case 'l':
	    view->display_numbers ^= 1;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case 'f':
	    view->full ^= 1;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case '=': /* XXX testing only */
	    if (!view->full) {
		view->bias = 0;
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '>': /* XXX testing only */
	    if (!view->full) {
		view_compute_split(view, 1);
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '<': /* XXX testing only */
	    if (!view->full) {
		view_compute_split(view, -1);
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;

	case '+':
	    if (view->subtract) {
		view->subtract--;
		view->new_frame = 1;
	    }
	    return MSG_HANDLED;
	case '-':
	    view->subtract++;
	    view->new_frame = 1;
	    return MSG_HANDLED;

	case '1':
	    lf->move = 1;
	    rf->move ^= 1;
	    return MSG_HANDLED;
	case '2':
	    lf->move ^= 1;
	    rf->move = 1;
	    return MSG_HANDLED;

	case XCTRL('u'): {
	    view->ord ^= 1;
	    return MSG_HANDLED;
	}

	case XCTRL('r'):
	    view_redo(view);
	    return MSG_HANDLED;

	case 'n':
	    find_next_hunk(view);
	    return MSG_HANDLED;

	case 'p':
	    find_prev_hunk(view);
	    return MSG_HANDLED;

	case KEY_DC:
	    view->last_found = -1;
	    return MSG_HANDLED;

	case KEY_F(4):
	    view_edit(view, view->ord);
	    return MSG_HANDLED;

	case KEY_F(14):
	    view_edit(view, view->ord ^ 1);
	    return MSG_HANDLED;

	case KEY_F(17):
	    view_search(view, 1);
	    return MSG_HANDLED;

	case KEY_HOME:
	case ALT ('<'):
	case KEY_M_CTRL | KEY_PPAGE:
	    view->last_found = -1;
	    if (lf->move) lf->offs = 0;
	    if (rf->move) rf->offs = 0;
	    return MSG_HANDLED;

	case KEY_END:
	case ALT ('>'):
	case KEY_M_CTRL | KEY_NPAGE:
	    view->last_found = -1;
	    if (lf->move) lf->offs = view->max - 1;
	    if (rf->move) rf->offs = view->max - 1;
	    return MSG_HANDLED;

	case KEY_UP:
	    if (lf->move) lf->offs -= view->nbytes;
	    if (rf->move) rf->offs -= view->nbytes;
	    return MSG_HANDLED;

	case KEY_DOWN:
	    if (lf->move) lf->offs += view->nbytes;
	    if (rf->move) rf->offs += view->nbytes;
	    return MSG_HANDLED;

	case KEY_NPAGE:
	    if (lf->move) lf->offs += view->pbytes;
	    if (rf->move) rf->offs += view->pbytes;
	    return MSG_HANDLED;

	case KEY_PPAGE:
	    if (lf->move) lf->offs -= view->pbytes;
	    if (rf->move) rf->offs -= view->pbytes;
	    return MSG_HANDLED;

	case KEY_LEFT:
	    if (lf->move) lf->offs--;
	    if (rf->move) rf->offs--;
	    return MSG_HANDLED;

	case KEY_RIGHT:
	    if (lf->move) lf->offs++;
	    if (rf->move) rf->offs++;
	    return MSG_HANDLED;

	case KEY_M_CTRL | KEY_LEFT:
	    if (lf->move) lf->offs -= 16;
	    if (rf->move) rf->offs -= 16;
	    return MSG_HANDLED;

	case KEY_M_CTRL | KEY_RIGHT:
	    if (lf->move) lf->offs += 16;
	    if (rf->move) rf->offs += 16;
	    return MSG_HANDLED;

	case XCTRL('o'):
	    view_other_cmd();
	    return MSG_HANDLED;

	case 't':
	    diff_view(view->file[0], view->file[1]);
	    return MSG_HANDLED;

	case 'q':
	case ESC_CHAR:
	    view->view_quit = 1;
	    return MSG_HANDLED;

	case '\n':
	    return MSG_HANDLED;

#ifdef HAVE_CHARSET
	case XCTRL ('t'):
	    do_select_codepage ();
	    view_update (view);
	    return MSG_HANDLED;
#endif				/* HAVE_CHARSET */
    }

    /* Key not used */
    return MSG_NOT_HANDLED;
}
/*
 * When a part of the window is exposed, we must redraw it.
 */
static void
view_expose_cb (GtkWidget *drawing_area, GdkEventExpose *event, view_data_t *view_data)
{
	view_update (view_data);
}
Esempio n. 28
0
void view_inspect_update(void)
{
	view_update(VIEW_INSPECT, debug_state());
}
Esempio n. 29
0
void on_view_changed(G_GNUC_UNUSED GtkNotebook *notebook, G_GNUC_UNUSED gpointer page,
	gint page_num, G_GNUC_UNUSED gpointer gdata)
{
	view_current = page_num;
	view_update(view_current, debug_state());
}
Esempio n. 30
0
File: main.c Progetto: firejox/mils
int main(void) {
    int epfd, ret;
    struct epoll_event tmp;
    input_state_t *ist;
    data_handler_t *dht;
    view_t *v;
    line_text_t *lt;
    int timeout = -1;
    keysym_t sym;

    epfd = epoll_create1(0);
    if (epfd == -1) {
        perror ("epoll create failed");
        exit(-1);
    }

    screen_enter (epfd);
    ist = input_state_create (epfd);
    v = view_create ();
    lt = view_user_input_ref (v);

    view_update (v, VIEW_USER);
    while ((ret = epoll_wait (epfd, &tmp, 1, timeout)) > -1) {
        if (ret) {
            dht = tmp.data.ptr;
            dht->handler (dht->fd, dht->data);
        }

        
       sym = get_input_state_info (ist, &timeout);
       switch (sym) {
           case XKB_KEY_NoSymbol:
               break;
           case XKB_KEY_Return:
               goto input_end;
           case XKB_KEY_BackSpace:
               line_text_handle_event (lt, DELETE_LEFT_CH);
               break;
           case XKB_KEY_Delete:
               line_text_handle_event (lt, DELETE_RIGHT_CH);
               break;
           case XKB_KEY_Left:
               line_text_handle_event (lt, CURSOR_MOVE_LEFT);
               break;
           case XKB_KEY_Right:
               line_text_handle_event (lt, CURSOR_MOVE_RIGHT);
               break;
           default:
               line_text_handle_event (lt, APPEND_CH, keysym_to_utf32(sym));
               break;
       }
       if (sym != XKB_KEY_NoSymbol)
           view_update (v, VIEW_USER);
    
    }

input_end:

    line_text_unref (lt);

    view_destory (v);
    input_state_destroy (ist);
    screen_leave (epfd);
    return 0;
}