File: tedBlinkGtk.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (127 lines) | stat: -rw-r--r-- 2,983 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/************************************************************************/
/*									*/
/*  Ted: Handle user input.						*/
/*									*/
/************************************************************************/

#   include	"tedConfig.h"

#   include	<stddef.h>
#   include	<stdlib.h>
#   include	<stdio.h>
#   include	<ctype.h>

#   include	"tedApp.h"
#   include	"tedRuler.h"

#   include	<appDebugon.h>

# ifdef USE_GTK

/************************************************************************/
/*									*/
/*  Blinking cursor: GTK specific code.					*/
/*									*/
/*  Thanks to Andrea Frome who contributed the original code.		*/
/*									*/
/************************************************************************/

#   define	TED_BLINK_VISIBLE	(800L)
#   define	TED_BLINK_INVISIBLE	(400L)

static int tedHideIBar(	void *		voided );

static int tedShowIBar(	void *		voided )
    {
    EditDocument *		ed= (EditDocument *)voided;
    TedDocument *		td= (TedDocument *)ed->edPrivateData;
    AppDrawingData *		add= &(ed->edDrawingData);

    int				ox= ed->edVisibleRect.drX0;
    int				oy= ed->edVisibleRect.drY0;

    DocumentSelection		ds;
    SelectionGeometry		sg;
    SelectionDescription	sd;

    td->tdShowIBarId= (guint)0;

    if  ( tedGetSelection( &ds, &sg, &sd, td ) )
	{ LDEB(1); return 0;	}

    tedDrawIBar( &(sg.sgBegin), ox, oy, add );

    td->tdHideIBarId= gtk_timeout_add( TED_BLINK_VISIBLE,
						tedHideIBar, (void *)ed );
    return 0;
    }

static int tedHideIBar(	void *		voided )
    {
    EditDocument *		ed= (EditDocument *)voided;
    TedDocument *		td= (TedDocument *)ed->edPrivateData;

    td->tdHideIBarId= (guint)0;

    tedUndrawIBar( ed );

    td->tdShowIBarId= gtk_timeout_add( TED_BLINK_INVISIBLE,
						tedShowIBar, (void *)ed );
    return 0;
    }

void tedStartCursorBlink(	EditDocument *	ed )
    {
    TedDocument *		td= (TedDocument *)ed->edPrivateData;

    tedStopCursorBlink( ed );

    td->tdHideIBarId= gtk_timeout_add( TED_BLINK_VISIBLE,
						tedHideIBar, (void *)ed );
    }

void tedStopCursorBlink(	EditDocument *	ed )
    {
    TedDocument *		td= (TedDocument *)ed->edPrivateData;

    if  ( td->tdHideIBarId )
	{ gtk_timeout_remove( td->tdHideIBarId ); }

    if  ( td->tdShowIBarId )
	{
	AppDrawingData *	add= &(ed->edDrawingData);

	int			ox= ed->edVisibleRect.drX0;
	int			oy= ed->edVisibleRect.drY0;

	DocumentSelection	ds;
	SelectionGeometry	sg;
	SelectionDescription	sd;

	gtk_timeout_remove( td->tdShowIBarId );

	if  ( tedGetSelection( &ds, &sg, &sd, td ) )
	    { LDEB(1); return;	}

	tedDrawIBar( &(sg.sgBegin), ox, oy, add );
	}

    td->tdHideIBarId= (guint)0;
    td->tdShowIBarId= (guint)0;

    return;
    }

void tedCleanCursorBlink(	TedDocument *	td )
    {
    if  ( td->tdHideIBarId )
	{ gtk_timeout_remove( td->tdHideIBarId ); }
    if  ( td->tdShowIBarId )
	{ gtk_timeout_remove( td->tdShowIBarId ); }

    td->tdHideIBarId= (guint)0;
    td->tdShowIBarId= (guint)0;
    }

#   endif