File: seqedInterface.c

package info (click to toggle)
staden 2.0.0%2Bb11-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 21,568 kB
  • sloc: ansic: 240,605; tcl: 65,360; cpp: 12,854; makefile: 11,201; sh: 2,952; fortran: 2,033; perl: 63; awk: 46
file content (150 lines) | stat: -rw-r--r-- 3,129 bytes parent folder | download | duplicates (5)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "seqedInterface.h"
#include "tkSeqedUtils.h"
#include "tkSeqed.h"

/*
 * Set the cursor position from an X,Y position within the sheet widget
 */
int seqedSetCursor(tkSeqed *se, int x, int y) {

#ifdef DEBUG
    printf("seqedSetCursor x %d y %d \n", x, y);
#endif
    if (y < 0 || y >= se->displayHeight || x < 0 || x >= se->displayWidth)
	return 1;
/*
    setCursorPosSeq(xx,
		    xx->displayPos - DB_RelPos(xx,seqList[y]) + x + 1,
		    seqList[y]);
*/
    seqed_setCursorPos(se, se->displayPos + x);

    if (se->cursorPos < se->extent_left)
	seqed_setCursorPos(se, se->extent_left);
    else
	if (se->cursorPos > se->extent_right)
	    seqed_setCursorPos(se, se->extent_right);

    /* 
     * always position cursor on row of sequence, irrespective of the actual
     * mouse position
     */
    seqed_positionCursor(se, se->cursorSeq, se->cursorPos);

    return 0;
}


/*
 * Move cursor right
 */
int seqedCursorRight(tkSeqed *se)
{
/*
    if (xx->editorState == StateDown)
	return 1;
*/
    /* check boundary cases */

    if ((se->cursorPos >= 1) && (se->cursorPos < se->extent_right)) {

	/* set cursor pos and do any callbacks */
	seqed_setCursorPos(se, se->cursorPos + 1);

	/* display cursor */
	seqed_showCursor(se, se->cursorSeq, se->cursorPos);
	return 0;
    } else {
	bell();
	return 1;
    }

}


/*
 * Move cursor left
 */
int seqedCursorLeft(tkSeqed *se)
{
/*
    if (xx->editorState == StateDown)
	return 1;
	*/

    if ((se->cursorPos > 1) && (se->cursorPos <= se->extent_right)) {
	seqed_setCursorPos(se, se->cursorPos - 1);
	seqed_showCursor(se, se->cursorSeq, se->cursorPos);
	return 0;
    } else {
	bell();
	return 1;
    }

}


/*
 * Move cursor down,
 * cycle if necessary
 */
int seqedCursorDown(tkSeqed *se)
{
/*    
    int *seqList,seqCount, cseq, cpos;
    int posInContig;
    int i;

    if (xx->editorState == StateDown)
	return 1;

    posInContig = positionInContig(xx,xx->cursorSeq,xx->cursorPos);
    seqList = sequencesInRegion(xx,posInContig-1,2);
    seqCount = linesInRegion(xx,posInContig-1,2);
    for(i=0;
	i<seqCount && seqList[i]!=xx->cursorSeq;
	i++);
    
    cseq = xx->cursorSeq;
    cpos = xx->cursorPos;
    caretDown2(xx, i, seqCount, &cseq, &cpos, seqList, posInContig);
    if (xx->cursorSeq != cseq || xx->cursorPos != cpos)
	setCursorPosSeq(xx, cpos, cseq);

    showCursor(xx, xx->cursorSeq, xx->cursorPos);
*/
    return 0;
}


/*
 * Move cursor up,
 * cycle if necessary
 */
int seqedCursorUp(tkSeqed *se)
{
/*
    int *seqList,seqCount, cseq, cpos;
    int posInContig;
    int i;

    if (xx->editorState == StateDown)
	return 1;

    posInContig = positionInContig(xx,xx->cursorSeq,xx->cursorPos);
    seqList = sequencesInRegion(xx,posInContig-1,2);
    seqCount = linesInRegion(xx,posInContig-1,2);
    for(i=0;
	i<seqCount && seqList[i]!=xx->cursorSeq;
	i++);
    
    cseq = xx->cursorSeq;
    cpos = xx->cursorPos;
    caretUp2(xx, i, seqCount, &cseq, &cpos, seqList, posInContig);
    if (xx->cursorSeq != cseq || xx->cursorPos != cpos)
	setCursorPosSeq(xx, cpos, cseq);

    showCursor(xx,xx->cursorSeq, xx->cursorPos);
*/
    return 0;
}