Whole document tree
    

Whole document tree

Other ideas

Other ideas


Adding a scrollbar

Often a scrollbar will be added to the ZvtTerm widget to allow its scroll-back buffer to be controlled via a mouse (see ). Each ZvtTerm provides this via an adjustment defined in the object structure as simply adjustment.

Also note that mouse-wheel mice are automatically handled by the button event handler if the terminal widget has focus, and perform a page up/down function.

Example 4. Creating an appropriate scrollbar

	    gtk_vscrollbar_new (GTK_ADJUSTMENT (ZVT_TERM (term)->adjustment));
	    GTK_WIDGET_UNSET_FLAGS (scrollbar, GTK_CAN_FOCUS);
	  

You will normally want to disable focus on the scrollbar otherwise gtk may switch focus inappropriately.


Reading data from the screen

There are no helper functions for this, but the same may be achieved simply using the following code fragment.

Example 5. Converting window coordinates to character coordinates.

void mouse_to_char(ZvtTerm *term, int mousex, int mousey, int *x, int *y)
{
	*x = mousex/term->charwidth;
	*y = mousey/term->charheight;
}
	  

These values are then suitable for using with to let the application read data from the screen.