Exemple #1
0
int buffers_goto(int n)
{
	extern int gui_scrollclear;
	int loadpos;

	if(n < 0 || n >= count)
		return 1;

	if((loadpos = current != n))
		buffers_save_pos();

	last = current;
	current = n;
	if(current_buf)
		buffer_free(current_buf);
	current_buf = buffers_readfname(fnames[current]->fname);

	if(arg_ro)
		buffer_readonly(buffers_current()) = 1;

	fnames[n]->read = 1;

	gui_move(fnames[n]->last_y, 0); /* do this for checking regardless */
	if(loadpos){
		gui_scrollclear = 0;
		gui_scroll(CURSOR_MIDDLE);
		gui_scrollclear = 1;
	}
	return 0;
}
Exemple #2
0
static void	gui_place_size_callback(GtkWidget*	widget,
                                     GtkAllocation*	allocation,
                                     gpointer	user_data)
{
  (void)allocation;
  position_t* position = (position_t*)user_data;
  gui_move(widget, position->screen, position->x, position->y);
}
Exemple #3
0
void	gui_place(GtkWidget* window, position_t* position, GtkLayout* screen)
{
#if 0
  position_t current_position;
  gtk_window_get_position(GTK_WINDOW(window), &current_position.x, &current_position.y);
  if ((current_position.x == position->x)
      && (current_position.y == position->y))
    return;
#endif
  g_signal_connect(G_OBJECT(window), "show",
                   G_CALLBACK(gui_place_show_callback), position);
  g_signal_connect(G_OBJECT(window), "size-allocate",
                   G_CALLBACK(gui_place_size_callback),
                   position);
  position->screen = screen;
  gtk_widget_show_all(window);
  gui_move(window, screen, position->x, position->y);
}
Exemple #4
0
void buffers_load(const char *fname)
{
	int i;

	buffers_save_pos();

	if(fname){
		if((i = buffers_find(fname)) != -1)
			buffers_goto(i);
		else
			buffers_goto(buffers_add(fname));
	}else{
		/* :new */
		if(current_buf)
			buffer_free(current_buf);
		current_buf = buffers_readfname(NULL);
		current     = -1;
		gui_move(0, 0);
	}
}
Exemple #5
0
void tilde(unsigned int rep)
{
	char *data = (char *)buffer_getindex(buffers_current(), gui_y())->data;
	char *pos = data + gui_x();

	if(!rep)
		rep = 1;

	gui_move(gui_y(), gui_x() + rep);

	while(rep --> 0){
		if(islower(*pos))
			*pos = toupper(*pos);
		else
			*pos = tolower(*pos);

		/* *pos ^= (1 << 5); * flip bit 100000 = 6 */

		if(!*++pos)
			break;
	}

	buffer_modified(buffers_current()) = 1;
}
Exemple #6
0
static void	gui_place_show_callback(GtkWidget*	widget,
                                     gpointer	user_data)
{
  position_t* position = (position_t*)user_data;
  gui_move(widget, position->screen, position->x, position->y);
}