|
|
1.1 root 1: /****** KEYFUNCS.C - a collection of routines to service special keys
2: * each routine has the name of the key it services
1.1.1.2 ! root 3: *
! 4: * Created by Microsoft Corp. 1987
1.1 root 5: */
6:
1.1.1.2 ! root 7: #define INCL_SUB
! 8:
1.1 root 9: #include <ctype.h>
1.1.1.2 ! root 10: #include <os2def.h>
! 11: #include <bsesub.h>
1.1 root 12: #include "ssedefs.h"
13: #include "keydefs.h"
14:
15:
16: /*** insert(c) - inserts the character c at the current cursor position
17: *
18: * This routine is called when any regular printable character is hit.
19: *
20: * insert(c) checks to see if there is room in EditBuff[] to insert the
21: * character it is passed by seeing if there is already a printable
22: * character in the 80th column. If so, no character can be inserted
23: * so we just call badkey(). If there is room, insert the character
24: * at the position indicated by CurCol and shift everything past that
25: * over one; mark EditBuff[] as dirty.
26: *
27: * If there is text that has been marked, insert() will call del() to
28: * remove it before inserting its character where the marked text was.
29: *
30: * The character we are passed has already been checked as being a
31: * valid printable characters.
32: *
33: * insert(c)
34: *
35: * ENTRY: c - the validated character to be inserted
36: *
37: * EFFECTS: EditBuff[] - changes its contents if successful
38: * EditBuffDirty - sets this flag if EditBuff changed
39: * LinesMarked - clears this if set
40: * CharsMarked - clears this if set
41: * CurCol - increments this one
42: *
43: * The effects of del() should also be considered since it may be
44: * called from this function.
45: */
46:
47: insert(c)
48: char c; /* the character we are to insert, already validated */
49: {
50:
1.1.1.2 ! root 51: register SHORT i; /* indexing variable */
1.1 root 52:
53: if (LinesMarked || CharsMarked) /* if there is marked text around, */
54: del(); /* we first want to delete it */
55:
56: if ( EditBuff[LINESIZE - 1] == ' ') /* can only insert when there's room */
57: {
1.1.1.2 ! root 58: for ( i = 0; i < LINESIZE-CurCol-1; ++i )
! 59: EditBuff[LINESIZE-i-1] = EditBuff[LINESIZE-i-2];/* shift end by one */
1.1 root 60: EditBuff[CurCol] = c; /* put in the new character */
61: drawline();
62: CurCol += 1; /* update display */
1.1.1.2 ! root 63: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 64: EditBuffDirty = 1; /* mark edit buffer as dirty */
65: }
66:
67: else badkey(); /* if no room, exit as for invalid key */
68:
69: }
70:
71:
72: /*** up() - moves the cursor up one row
73: *
74: * up() moves the cursor position up one row. If we are at the top of
75: * the screen already, up() scrolls the screen down one line. If we
76: * are at the top of the file, it does nothing. If there is marked text
77: * around, up() will clear it without deleting. Because the current row
78: * in the file is changed by up(), EditBuff[] is flushed and refilled
79: * and line25() is called to update the line information at the bottom
80: * of the screen.
81: *
82: * EFFECTS: EditBuff[] - flushes its current contents and reloads
83: * EditBuffDirty - clears this flag
84: * LinesMarked - clears this flag
85: * MarkedLine[] - clears all
86: * CharsMarked - clears this flag
87: * MarkedChar[] - clears all
88: * TopRow - if at top of screen, decrements this one
89: * CurRow - otherwise, decrements this one
90: */
91:
92:
93: void up()
94: {
95:
96: register short i; /* indexing variable */
97:
98: char buff[2]; /* local buffer for scrolling fill character */
99: buff[0] = 32; /* character = 32 = <blank> */
100: buff[1] = ForeNorm; /* attribute = normal */
101:
102: if (EditBuffDirty) { /* this call will change */
103: EditBuffDirty = 0; /* cursor line, so flush */
104: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
105: }
106:
107: if ( LinesMarked || CharsMarked ) {
108: LinesMarked = 0; /* if there's marked text */
109: CharsMarked = 0; /* around, clear it and */
110: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
111: MarkedLine[i] = 0;
112: for ( i = 0; i < LINESIZE; i++ )
113: MarkedChar[i] = 0;
114: drawscr(TopRow);
115: }
116:
117: if ( (TopRow + CurRow) != 0 ) { /* if top of file, do nothing */
118: if ( CurRow == 0 ) {
119: TopRow -= 1; /* if top of screen, scroll down */
1.1.1.2 ! root 120: VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1,
! 121: (PBYTE)buff, 0);
1.1 root 122: getline( (TopRow + CurRow), &EditBuff[0] );
123: drawline();
124: }
125: else {
126: CurRow -= 1; /* otherwise just move cursor up */
127: getline( (TopRow + CurRow), &EditBuff[0] );
1.1.1.2 ! root 128: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 129: }
130: }
131:
132: line25(); /* reset line numbers on 25th line to reflect change */
133:
134: }
135:
136:
1.1.1.2 ! root 137: /*** down() - moves the cursor down one row
1.1 root 138: *
139: * down() moves the cursor down one row. If we are at the top of
140: * the screen already, down() scrolls the screen up one line. If we
141: * are at the end of the file, it does nothing. If there is marked text
142: * around, down() will clear it without deleting. Because the current row
143: * in the file is changed by down(), EditBuff[] is flushed and refilled
144: * and line25() is called to update the line information at the bottom
145: * of the screen.
146: *
147: * EFFECTS: EditBuff[] - flushes its current contents and reloads
148: * EditBuffDirty - clears this flag
149: * LinesMarked - clears this flag
150: * MarkedLine[] - clears all
151: * CharsMarked - clears this flag
152: * MarkedChar[] - clears all
153: * TopRow - if at bottom of screen, increments this one
154: * CurRow - otherwise, increments this one
155: */
156:
157:
158: void down()
159: {
160:
161: register short i; /* indexing variable */
162:
163: char buff[2]; /* local buffer for scrolling fill character */
164: buff[0] = 32; /* character = 32 = <blank> */
165: buff[1] = ForeNorm; /* attribute = normal */
166:
167: if (EditBuffDirty) { /* this call will change */
168: EditBuffDirty = 0; /* cursor line, so flush */
169: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
170: }
171:
172: if ( LinesMarked || CharsMarked ) {
173: LinesMarked = 0; /* if there's marked text */
174: CharsMarked = 0; /* around, clear it and */
175: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
176: MarkedLine[i] = 0;
177: for ( i = 0; i < LINESIZE; i++ )
178: MarkedChar[i] = 0;
179: drawscr(TopRow);
180: }
181:
182: if ( (TopRow + CurRow) < (TotalLines) ) { /* if EOF, do nothing */
183: if ( CurRow == (PageSize - 1) ) { /* if end of screen, scroll up */
184: TopRow += 1;
1.1.1.2 ! root 185: VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1,
! 186: (PBYTE)buff, 0);
1.1 root 187: getline( (TopRow + CurRow), &EditBuff[0] );
188: drawline();
189: }
190: else {
191: CurRow += 1; /* else move cursor down */
192: getline( (TopRow + CurRow), &EditBuff[0] );
1.1.1.2 ! root 193: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 194: }
195: }
196:
197: line25(); /* reset line numbers on 25th line to reflect change */
198:
199: }
200:
201:
202: /*** home() - moves the cursor to beginning of the line
203: *
204: * home() moves the cursor to the position of the first printable character
205: * in the current line. If there is marked text, home() will clear it
206: * without deleting. We need to be able to get correct information about
207: * the length of the current line from LineTable[], so we flush EditBuff[]
208: * on entry; but since the current line does not get changed, we do not
209: * reload it (current contents remain correct) and we do not call line25().
210: *
211: * EFFECTS: EditBuffDirty - clears this flag
212: * LinesMarked - clears this flag
213: * MarkedLine[] - clears all
214: * CharsMarked - clears this flag
215: * MarkedChar[] - clears all
216: * CurCol - set to position of first printable character
217: */
218:
219: void home()
220: {
221:
222: register short i, j; /* indexing variables */
223:
224:
225: if (EditBuffDirty) { /* this call will need to */
226: EditBuffDirty = 0; /* get correct info on */
227: flushline((TopRow + CurRow), EditBuff); /* line length, so flush */
228: } /* edit buffer if dirty */
229:
230: if ( LinesMarked || CharsMarked ) {
231: LinesMarked = 0; /* if there's marked text */
232: CharsMarked = 0; /* around, clear it and */
233: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
234: MarkedLine[i] = 0;
235: for ( i = 0; i < LINESIZE; i++ )
236: MarkedChar[i] = 0;
237: drawscr(TopRow);
238: }
239:
240: if( (TopRow + CurRow) < TotalLines ) {
241: i = LineTable[TopRow + CurRow]->linelength; /* i is position of */
242: i--; /* last char in line */
243: }
244: else i = 0; /* if we're off the end of the file, that's 0... */
245:
246:
247: for( j = 0; ( j <= i ) && !isgraph(EditBuff[j]); j++ );
248:
249: CurCol = j; /* j is position of */
1.1.1.2 ! root 250: VioSetCurPos( CurRow, CurCol, 0 ); /* first non-blank */
1.1 root 251:
252: }
253:
254:
255: /*** end_() - moves the cursor to one position past the end of the current line
256: *
257: * end_() moves the cursor to one position beyond the position of the last
258: * printable character in the current line. If the last printable character
259: * is already in column 80, we just go there. If there is marked text,
260: * end_() will clear it without deleting. We need to be able to get correct
261: * information about the length of the current line from LineTable[], so
262: * we flush EditBuff[] on entry; but since the current line does not get
263: * changed, we do not reload it (current contents remain correct) and we
264: * do not call line25(). Note that this routine had to be named end_() not
265: * end() since that is a reserved word under the compiler used.
266: *
267: * EFFECTS: EditBuffDirty - clears this flag
268: * LinesMarked - clears this flag
269: * MarkedLine[] - clears all
270: * CharsMarked - clears this flag
271: * MarkedChar[] - clears all
272: * CurCol - set to position of last printable
273: * character, plus one if possible
274: */
275:
276: void end_()
277: {
278:
279: register short i; /* indexing variable */
280:
281: if (EditBuffDirty) { /* this call will need to */
282: EditBuffDirty = 0; /* get correct info on */
283: flushline((TopRow + CurRow), EditBuff); /* line length, so flush */
284: } /* edit buffer if dirty */
285:
286: if ( LinesMarked || CharsMarked ) {
287: LinesMarked = 0; /* if there's marked text */
288: CharsMarked = 0; /* around, clear it and */
289: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
290: MarkedLine[i] = 0;
291: for ( i = 0; i < LINESIZE; i++ )
292: MarkedChar[i] = 0;
293: drawscr(TopRow);
294: }
295:
296: if( (TopRow + CurRow) < TotalLines ) {
297: i = LineTable[TopRow + CurRow]->linelength; /* i is position of */
298: } /* last char in line */
299: else i = 0;
300:
301: CurCol = i;
1.1.1.2 ! root 302: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 303:
304: }
305:
306:
307: /*** pgup() - moves up one screen
308: *
309: * pgup() subtracts PageSize from the current value of TopRow and then
310: * redraws the screen, effectively moving us up one screen. If TopRow
311: * is less than PageSize, we just go to the start of the file. The
312: * position of the cursor on the screen is not altered. If there is marked
313: * text, pgup() will clear it without deleting. Because this call changes
314: * the current line, we flush and reload EditBuff[].
315: *
316: * EFFECTS: EditBuff[] - flushes and reloads
317: * EditBuffDirty - clears this flag
318: * LinesMarked - clears this flag
319: * MarkedLine[] - clears all
320: * CharsMarked - clears this flag
321: * MarkedChar[] - clears all
322: * TopRow - gets PageSize subtracted from it
323: * if possible, otherwise set to 0.
324: */
325:
326: void pgup()
327: {
328:
329: register short i; /* indexing variable */
330:
331: if (EditBuffDirty) { /* this call will change */
332: EditBuffDirty = 0; /* cursor line, so flush */
333: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
334: }
335:
336: if ( LinesMarked || CharsMarked ) {
337: LinesMarked = 0; /* if there's marked text */
338: CharsMarked = 0; /* around, clear it and */
339: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
340: MarkedLine[i] = 0;
341: for ( i = 0; i < LINESIZE; i++ )
342: MarkedChar[i] = 0;
343: }
344:
345: if ( TopRow >= PageSize ) /* go up one page if there's room */
346: TopRow -= PageSize;
347: else {
348: TopRow = 0; /* otherwise just go to top of file */
349: CurRow = 0;
1.1.1.2 ! root 350: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 351: }
352:
353: drawscr(TopRow); /* redraw screen and */
354: getline( (TopRow + CurRow), &EditBuff[0] ); /* update edit buffer */
355: line25(); /* reset line numbers on 25th line to reflect change */
356:
357: }
358:
359:
360: /*** pgdn() - moves down one screen
361: *
362: * pgdn() adds PageSize to the current value of TopRow and then
363: * redraws the screen, effectively moving us down one screen. If the
364: * result of adding TopRow and PageSize is greater than TotalLines
365: * (in other words, we would be moving off the end of the file), then
366: * we just move to one beyond the end of the file. The position of the
367: * cursor on the screen is not altered. If there is marked text,
368: * pgdn() will clear it without deleting. Because this call changes
369: * the current line, we flush and reload EditBuff[].
370: *
371: * EFFECTS: EditBuff[] - flushes and reloads
372: * EditBuffDirty - clears this flag
373: * LinesMarked - clears this flag
374: * MarkedLine[] - clears all
375: * CharsMarked - clears this flag
376: * MarkedChar[] - clears all
377: * TopRow - gets PageSize added to it if possible,
378: * otherwise set to TotalLines - PageSize - 1.
379: */
380:
381: void pgdn()
382: {
383:
384: register short i; /* indexing variable */
385:
386: if (EditBuffDirty) { /* this call will change */
387: EditBuffDirty = 0; /* cursor line, so flush */
388: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
389: }
390:
391: if ( LinesMarked || CharsMarked ) {
392: LinesMarked = 0; /* if there's marked text */
393: CharsMarked = 0; /* around, clear it */
394: for ( i = 0; i < MAXLINES; i++ )
395: MarkedLine[i] = 0;
396: for ( i = 0; i < LINESIZE; i++ )
397: MarkedChar[i] = 0;
398: }
399:
400: TopRow += PageSize; /* go down one page */
401: if ( TopRow > (TotalLines - (PageSize -1)) ) { /* if there's room, */
402: TopRow = (TotalLines - (PageSize -1)); /* else stop at last */
403: CurRow = (PageSize -1); /* full page */
1.1.1.2 ! root 404: VioSetCurPos(CurRow, CurCol, 0);
1.1 root 405: }
406:
407: drawscr(TopRow); /* redraw screen and */
408: getline( (TopRow + CurRow), &EditBuff[0] ); /* update edit buffer */
409: line25(); /* reset line numbers on 25th line to reflect change */
410:
411: }
412:
413:
414: /*** bksp() - deletes character to right of the cursor; moves cursor right one
415: *
416: * bksp() clears any marked text without deleting it, flushes EditBuff[],
417: * moves the cursor right one position and calls del(). If we're at the
418: * beginning of a line so there's nothing to our right, calls badkey().
419: *
420: * EFFECTS: EditBuff[] - flushes and reloads
421: * EditBuffDirty - clears this flag
422: * LinesMarked - clears this flag
423: * MarkedLine[] - clears all
424: * CharsMarked - clears this flag
425: * MarkedChar[] - clears all
426: * CurCol - decrements if possible
427: *
428: * The effects of del() should also be considered since it may be
429: * called from this function.
430: */
431:
432: void bksp()
433: {
434:
435: register short i; /* indexing variable */
436:
437: if ( LinesMarked || CharsMarked ) {
438: LinesMarked = 0; /* if there's marked text */
439: CharsMarked = 0; /* around, clear it and */
440: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
441: MarkedLine[i] = 0;
442: for ( i = 0; i < LINESIZE; i++ )
443: MarkedChar[i] = 0;
444:
445: if (EditBuffDirty) { /* flush before redraw */
446: EditBuffDirty = 0; /* to get any changes */
447: flushline((TopRow + CurRow), EditBuff);
448: }
449: drawscr(TopRow);
450: }
451:
452: if( CurCol == 0 ) /* can't backspace if already at left edge */
453: badkey();
454: else {
455: CurCol -= 1; /* otherwise, move left one and del */
1.1.1.2 ! root 456: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 457: del();
458: }
459: }
460:
461:
462: /*** del() - deletes all indicated text
463: *
464: * del() is the function for deleting text. What gets deleted depends on
465: * what is marked. If there are marked lines around (as indicated by the
466: * LinesMarked flag) then we delete the marked lines, clear all the line
467: * marking flags, and adjust LineTable[] to reflect the change. Note that
468: * if there are lines marked, there cannot be characters marked too. If
469: * there are no lines marked, but characters marked, these characters are
470: * deleted and EditBuff[] is adjusted to reflect the change and flagged
471: * as dirty. If there are no lines or characters marked, then the character
472: * under the cursor is deleted and EditBuff[] is adjusted accordingly and
473: * marked as dirty.
474: *
475: * EFFECTS: EditBuff[] - contents altered if no lines were marked
476: * EditBuffDirty - set if no lines were marked
477: * LineTable[] - contents altered if lines were marked
478: * TotalLines - altered if lines were marked
479: * LinesMarked - clears this flag
480: * MarkedLine[] - clears all
481: * CharsMarked - clears this flag
482: * MarkedChar[] - clears all
483: * TopRow - may change, depending on what's marked
484: * CurRow - may change, depending on what's marked
485: *
486: */
487:
488: void del()
489: {
490:
491: register short i, j; /* indexing variables */
492:
493: if (LinesMarked) { /* if lines are marked, do this */
494: for( i = 0; !MarkedLine[i]; i++ );
495: j = i; /* i, j refer to first marked line */
496: if( i <= TopRow ) {
497: if( i != 0 ) {
498: TopRow = i - 1; /* if first line to be deleted is */
499: CurRow = 1; /* off the top of the screen, then */
500: } /* set TopRow to last unmarked line */
501: else {
502: TopRow = 0; /* or if there are no unmarked */
503: CurRow = 0; /* lines ahead of the marked ones, */
504: } /* set TopRow to start of the file */
505: }
506: else CurRow = i - TopRow;
507: for( ; MarkedLine[i]; i++ ) /* delete all marked lines */
508: deleteline( i ); /* i refers to first unmarked line */
509: for( ; i < TotalLines; i++,j++ ) /* adjust LineTable[] */
510: LineTable[j] = LineTable[i];
511: TotalLines -= ( i - j ); /* adjust TotalLines */
512: LinesMarked = 0;
513: for( i = 0; i < MAXLINES; i++ ) /* clear line marking flags */
514: MarkedLine[i] = 0;
515: drawscr(TopRow); /* redraw screen */
1.1.1.2 ! root 516: VioSetCurPos(CurRow, CurCol, 0);
1.1 root 517: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload EditBuff[] */
518: }
519:
520: else if (CharsMarked) { /* if no lines marked but chars marked, do this */
521: for( i = 0; !MarkedChar[i] & ( i < LINESIZE ); i++ );
522: j = i; /* i, j refer to first marked character */
523: CurCol = j;
1.1.1.2 ! root 524: VioSetCurPos(CurRow, CurCol, 0); /* adjust cursor position */
1.1 root 525: for( ; MarkedChar[i] & (i < LINESIZE); i++ ); /* i now first unmarked */
526: for( ; i < LINESIZE; i++, j++ )
527: EditBuff[j] = EditBuff[i]; /* remove characters between i and j */
528: for( ; j < LINESIZE; j++ )
529: EditBuff[j] = ' '; /* fill end of line with blanks */
530: CharsMarked = 0;
531: for( i = 0; i < LINESIZE; i++ ) /* clear all character marking flags */
532: MarkedChar[i] = 0;
533: drawline(); /* redraw line */
534: EditBuffDirty = 1; /* mark EditBuff[] as dirty */
535: }
536:
537: else { /* if no lines or chars marked, do this */
538: for( i = (CurCol + 1); i < LINESIZE; i++ )
539: EditBuff[i-1] = EditBuff[i]; /* remove character under cursor */
540: EditBuff[LINESIZE-1] = ' '; /* fill end of line with blank */
541: drawline(); /* redraw line */
542: EditBuffDirty = 1; /* mark EditBuff[] as dirty */
543: }
544:
545: line25(); /* reset line numbers on 25th line to reflect changes */
546:
547: }
548:
549:
550: /*** F9() - saves the file being edited and exits
551: *
552: * F9() save the file being edited with any changes that have been made
553: * and exits the editor. The user is given a prompt to be sure they want
1.1.1.2 ! root 554: * to quit; hitting carriage return goes ahead with the save-and-quit,
1.1 root 555: * while any other key returns you to the editor.
556: *
557: * EFFECTS: If quit not completed: EditBuff[] - gets flushed
558: * EditBuffDirty - gets cleared
559: */
560:
561: void F9()
562: {
563:
564: static char message[LINESIZE] = "Save file as:";
1.1.1.2 ! root 565: KBDKEYINFO keydata;
1.1 root 566: char attrib = Fore25 + Back25;
567: int i;
568:
569: if (EditBuffDirty) { /* flush the edit buffer if dirty */
570: EditBuffDirty = 0; /* so all editting will be saved */
571: flushline((TopRow + CurRow), EditBuff);
572: }
573:
574: for( i = 0; (i < 65) && (fname[i] != 0); message[i + 14] = fname[i], i++ );
575: /* copy filename into prompt message */
576:
1.1.1.2 ! root 577: VioWrtCharStrAtt( message, 80, PageSize, 0, &attrib, 0 );
1.1 root 578: /* write out message */
579:
1.1.1.2 ! root 580: KbdCharIn( &keydata, 0, 0 ); /* wait for user response */
1.1 root 581:
1.1.1.2 ! root 582: if( keydata.chChar == CRETURN_CHAR ) { /* if response was <CR>... */
1.1 root 583: if ( !savefile(fhandle)) {
584: freesegs();
1.1.1.2 ! root 585: VioSetCurPos( 24, 0, 0 ); /* ... clean up and quit */
1.1 root 586: quit(0);
587: }
588: else error25(11);
589: }
590: name25(); /* ... otherwise restore message on */
591: /* 25th line and return to editor */
592: }
593:
594:
595: /*** F10() - exits the editor without saving the file being edited
596: *
597: * F10() exits from the editor without saving back the file being edited,
598: * leaving the file as it was before the editor was invoked. A prompt
599: * will be issued to give the user a chance to change their mind before
600: * all editing is lost.
601: *
602: * EFFECTS: If quit not completed: EditBuff[] - gets flushed
603: * EditBuffDirty - gets cleared
604: */
605:
606:
607: void F10()
608: {
609: static char message[51] = "WARNING: Any edits will be lost (y/n)? ";
1.1.1.2 ! root 610: KBDKEYINFO keydata;
1.1 root 611: char attrib = Fore25 + Back25; /* attributes for message */
612: int row, col; /* to save current cursor position */
613: int done = 0; /* flag to be set when have a valid response */
614:
615: if (EditBuffDirty) { /* flush EditBuff[] if dirty */
616: EditBuffDirty = 0;
617: flushline((TopRow + CurRow), EditBuff);
618: }
619:
1.1.1.2 ! root 620: VioWrtCharStrAtt( message, 51, PageSize, 0, &attrib, 0 );
! 621: VioGetCurPos( &row, &col, 0 ); /* print prompt and set */
! 622: VioSetCurPos( PageSize, 42, 0 ); /* cursor to await reply */
1.1 root 623:
624: while( !done ) {
625:
1.1.1.2 ! root 626: KbdCharIn( &keydata, 0, 0 ); /* get a character from KBD */
1.1 root 627:
1.1.1.2 ! root 628: if( (keydata.chChar == 'y') || (keydata.chChar == 'Y') ) {
! 629: VioWrtCharStrAtt( &keydata.chChar, 1, PageSize, 42, &attrib, 0 );
1.1 root 630: freesegs();
631: quit(0); /* if Y, quit without saving */
632: }
1.1.1.2 ! root 633: else if( (keydata.chChar == 'n') || (keydata.chChar == 'N') ) {
! 634: VioSetCurPos( row, col, 0 );
1.1 root 635: name25();
636: done = 1; /* if N, return to editor */
637: }
638: else badkey(); /* otherwise wait for another key */
639:
640: }
641:
642: }
643:
644:
645: /*** ctrl_home() - repositions cursor to upper left hand corner of screen
646: *
647: * ctrl_home() moves the cursor to the upper left hand corner of the
648: * screen, coordinate position (0,0). Since the current cursor line is
649: * probably changed, we flush and reload EditBuff[]. If there is any
650: * text marked, this call will clear the marking without deleting.
651: * Line number information on 25th line is redrawn to reflect changes.
652: * The actual content of the screen - i.e. the value of TopRow - is
653: * unchanged by this call.
654: *
655: * EFFECTS: EditBuff[] - flushes and reloads
656: * EditBuffDirty - clears this flag
657: * LinesMarked - clears this flag
658: * MarkedLine[] - clears all
659: * CharsMarked - clears this flag
660: * MarkedChar[] - clears all
661: * CurRow - set to 0
662: * CurCol - set to 0
663: */
664:
665: void ctrl_home()
666: {
667:
668: register short i; /* indexing variable */
669:
670: if (EditBuffDirty) { /* this call will change */
671: EditBuffDirty = 0; /* cursor line, so flush */
672: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
673: }
674:
675: if ( LinesMarked || CharsMarked ) {
676: LinesMarked = 0; /* if there's marked text */
677: CharsMarked = 0; /* around, clear it and */
678: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
679: MarkedLine[i] = 0;
680: for ( i = 0; i < LINESIZE; i++ )
681: MarkedChar[i] = 0;
682: drawscr(TopRow);
683: }
684:
685: if ( CurRow != 0 || CurCol != 0 ) {
686: CurRow = 0; /* reposition to (0,0) */
687: CurCol = 0;
1.1.1.2 ! root 688: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 689: getline( (TopRow + CurRow), &EditBuff[0] );
690: }
691:
692: line25(); /* update line numbers on 25th line to reflect changes */
693:
694: }
695:
696:
697: /*** ctrl_end() - repositions cursor to lower left hand corner of screen
698: *
699: * ctrl_end() moves the cursor to the lower left hand corner of the
700: * screen. Since the current cursor line is probably changed, we flush
701: * and reload EditBuff[]. If there is any text marked, this call will
702: * clear the marking without deleting. Line number information on 25th
703: * line is redrawn to reflect changes. The actual content of the screen
704: * is unchanged by this call.
705: *
706: * EFFECTS: EditBuff[] - flushes and reloads
707: * EditBuffDirty - clears this flag
708: * LinesMarked - clears this flag
709: * MarkedLine[] - clears all
710: * CharsMarked - clears this flag
711: * MarkedChar[] - clears all
712: * CurRow - set to PAGESIZE - 1
713: * CurCol - set to 0
714: */
715:
716: void ctrl_end()
717: {
718:
719: register short i;
720:
721: if (EditBuffDirty) { /* this call will change */
722: EditBuffDirty = 0; /* cursor line, so flush */
723: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
724: }
725:
726: if ( LinesMarked || CharsMarked ) {
727: LinesMarked = 0; /* if there's marked text */
728: CharsMarked = 0; /* around, clear it and */
729: for ( i = 0; i < MAXLINES; i++ ) /* redraw the screen */
730: MarkedLine[i] = 0;
731: for ( i = 0; i < LINESIZE; i++ )
732: MarkedChar[i] = 0;
733: drawscr(TopRow);
734: }
735:
736: if( CurRow != (PageSize - 1) || CurCol != 0 ) {
737: CurRow = (PageSize - 1); /* reposition cursor */
738: CurCol = 0;
1.1.1.2 ! root 739: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 740: getline( (TopRow + CurRow), &EditBuff[0] );
741: }
742:
743: line25(); /* update line numbers on 25th line to reflect changes */
744:
745: }
746:
747:
748: /*** ctrl_pgup() - repositions cursor to beginning of file
749: *
750: * ctrl_pgup() redraws the screen with the first screenfull of the file
751: * and moves the cursor to the upper left hand corner of the screen,
752: * coordinate position (0,0). Since the current cursor line is
753: * probably changed, we flush and reload EditBuff[]. If there is any
754: * text marked, this call will clear the marking without deleting.
755: * Line number information on 25th line is redrawn to reflect changes.
756: *
757: * EFFECTS: EditBuff[] - flushes and reloads
758: * EditBuffDirty - clears this flag
759: * LinesMarked - clears this flag
760: * MarkedLine[] - clears all
761: * CharsMarked - clears this flag
762: * MarkedChar[] - clears all
763: * TopRow - set to 0
764: * CurRow - set to 0
765: * CurCol - set to 0
766: */
767:
768: void ctrl_pgup()
769: {
770:
771: register short i; /* indexing variable */
772:
773: if (EditBuffDirty) { /* this call will change */
774: EditBuffDirty = 0; /* cursor line, so flush */
775: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
776: }
777:
778: if ( LinesMarked || CharsMarked ) {
779: LinesMarked = 0; /* if there's marked text */
780: CharsMarked = 0; /* around, clear it - no */
781: for ( i = 0; i < MAXLINES; i++ ) /* need to redraw screen */
782: MarkedLine[i] = 0;
783: for ( i = 0; i < LINESIZE; i++ )
784: MarkedChar[i] = 0;
785: }
786:
787: TopRow = 0;
788: CurRow = 0; /* reposition and redraw */
789: CurCol = 0;
1.1.1.2 ! root 790: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 791: drawscr(TopRow);
792: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload EditBuff[] */
793: line25(); /* update 25th line */
794:
795: }
796:
797:
798: /*** ctrl_pgdn() - repositions cursor to beginning of file
799: *
800: * ctrl_pgdn() redraws the screen with the last screenfull of the file
801: * and moves the cursor to the lower left hand corner of the screen,
802: * one line past the end of the file. Since the current cursor line is
803: * probably changed, we flush and reload EditBuff[]. If there is any
804: * text marked, this call will clear the marking without deleting.
805: * Line number information on 25th line is redrawn to reflect changes.
806: *
807: * EFFECTS: EditBuff[] - flushes and reloads
808: * EditBuffDirty - clears this flag
809: * LinesMarked - clears this flag
810: * MarkedLine[] - clears all
811: * CharsMarked - clears this flag
812: * MarkedChar[] - clears all
813: * TopRow - set to TotalLines - (PageSize - 1)
814: * CurRow - set to end of file + 1
815: * CurCol - set to 0
816: */
817:
818: void ctrl_pgdn()
819: {
820: register short i; /* indexing variable */
821:
822: if (EditBuffDirty) { /* this call will change */
823: EditBuffDirty = 0; /* cursor line, so flush */
824: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
825: }
826:
827: if ( LinesMarked || CharsMarked ) {
828: LinesMarked = 0; /* if there's marked text */
829: CharsMarked = 0; /* around, clear it - no */
830: for ( i = 0; i < MAXLINES; i++ ) /* need to redraw screen */
831: MarkedLine[i] = 0; /* as it gets done later */
832: for ( i = 0; i < LINESIZE; i++ )
833: MarkedChar[i] = 0;
834: }
835: if (TotalLines > (PageSize - 1))
836: TopRow = TotalLines - (PageSize - 1); /* recalculate TopRow */
837: else TopRow = 0;
838: CurRow = TotalLines - TopRow; /* set cursor row and column */
839: CurCol = 0;
1.1.1.2 ! root 840: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 841: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload EditBuff[] */
842: drawscr(TopRow); /* redraw screen */
843: line25(); /* update 25th line */
844:
845: }
846:
847:
848: /*** shift_left() - moves cursor left one and marks that character for deletion.
849: *
850: * shift_left() moves the cursor one position to the left. If we are on
851: * a line that is already marked, that's all it does - just like regular
852: * left, but markings are not cleared. If we are not on a marked line,
853: * then the character we just moved to is marked for deletion. Unless it
854: * already was marked for deletion, in which case it gets un-marked.
855: *
856: * EFFECTS: CharsMarked - sets this flag if LinesMarked not set
857: * MarkedChar[] - sets this for the character we just moved to
858: * CurCol - decremented one
859: */
860:
861: void shift_left()
862: {
863:
864: if ( LinesMarked ) { /* if this line is marked, just move left */
865: if ( CurCol > 0 ) {
866: CurCol -= 1;
1.1.1.2 ! root 867: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 868: }
869: }
870: else if( CurCol > 0 ) { /* otherwise, see if there's room... */
871: CurCol -= 1;
1.1.1.2 ! root 872: VioSetCurPos( CurRow, CurCol, 0 ); /* ...if so move left */
1.1 root 873: CharsMarked = 1;
874: if (MarkedChar[CurCol])
875: MarkedChar[CurCol] = 0; /* and set marking for that character */
876: else MarkedChar[CurCol] = 1;
877: drawline(); /* redraw line to update markings */
878: }
879:
880: }
881:
882:
883: /*** shift_right() - moves cursor right one and marks the character
884: * we were previously on for deletion.
885: *
886: * shift_right() moves the cursor one position to the right. If we are on
887: * a line that is already marked, that's all it does - just like regular
888: * right, but markings are not cleared. If we are not on a marked line,
889: * then the character we just moved from is marked for deletion. Unless it
890: * already was marked for deletion, in which case it gets un-marked.
891: *
892: * EFFECTS: CharsMarked - sets this flag if LinesMarked not set
893: * MarkedChar[] - sets this for the character we just left
894: * CurCol - incremented one
895: */
896:
897: void shift_right()
898: {
899:
900: if ( LinesMarked ) { /* if this line marked, just move right */
901: if (CurCol < (LINESIZE - 1)) {
902: CurCol += 1;
1.1.1.2 ! root 903: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 904: }
905: }
906: else if( CurCol < (LINESIZE - 1)) { /* otherwise, see if there's room.. */
907: CharsMarked = 1;
908: if (MarkedChar[CurCol]) /* if so, mark character we're on */
909: MarkedChar[CurCol] = 0;
910: else MarkedChar[CurCol] = 1;
911: CurCol += 1; /* then move right one */
1.1.1.2 ! root 912: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 913: drawline(); /* and redraw line */
914: }
915:
916: }
917:
918:
919: /*** shift_up() - moves cursor up one line and marks lines for deletion
920: *
921: * shift_up() moves the cursor one line up. If no lines are marked, then
922: * both the previous line and the line moved to get marked for deletion.
923: * If lines are already marked, and were marked starting with another
924: * shift_up, then only the line we move to gets marked (the one we just
925: * left would already be marked). If there are lines marked but they
926: * were marked starting with a shift_down, then we un-mark the line we
927: * just left and do nothing to the line moved to. Unless the line moved
928: * to is the last one marked, in which case we un-mark it also to clear all
929: * markings. To determine how lines first got marked - by a shift_up or
930: * shift_down - we give the flag LinesMarked two different TRUE values,
931: * 1 or 2 respectively.
932: *
933: * EFFECTS: EditBuff[] - flushes and reloads
934: * EditBuffDirty - clears
935: * LinesMarked - sets this flag, unless un-marking only
936: * marked line present, in which case clears it
937: * MarkedLine[] - may set or clear this
938: * CharsMarked - clears this flag as we now have marked lines
939: * MarkedChar[] - clears all
940: * TopRow - decremented one if at top of page
941: * CurRow - decremented one if not at top of page
942: */
943:
944: void shift_up()
945: {
946: register short i; /* indexing variable */
947:
948: char buff[2]; /* local buffer for scrolling fill character */
949: buff[0] = 32; /* character = 32 = <blank> */
950: buff[1] = ForeHilite + BackHilite; /* attribute = highlighted */
951:
952: if (EditBuffDirty) { /* this call will change */
953: EditBuffDirty = 0; /* cursor line, so flush */
954: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
955: }
956:
957: if ( CharsMarked ) { /* clear CharsMarked flags */
958: CharsMarked = 0; /* since we now will have */
959: for ( i = 0; i < LINESIZE; i++ ) /* the whole line marked. */
960: MarkedChar[i] = 0;
961: }
962:
963: /* if no lines currently marked, do this */
964: if( !LinesMarked ) {
965: LinesMarked = 1; /* set flag to indicate marking started UP */
966: MarkedLine[ TopRow + CurRow ] = 1; /* mark line */
967: drawline(); /* redraw it */
968: if ( (TopRow + CurRow) != 0 ) { /* if there's room, */
969: MarkedLine[ TopRow + CurRow - 1 ] = 1; /* mark line above */
970: if ( CurRow == 0 ) {
971: TopRow -= 1; /* ...may have to scroll */
1.1.1.2 ! root 972: VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1,
! 973: buff, 0);
1.1 root 974: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
975: }
976: else { /* ...or may not have to scroll */
977: CurRow -= 1;
978: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1.1.1.2 ! root 979: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 980: }
981: drawline(); /* redraw new line */
982: }
983: }
984:
985: /* if lines marked, and shift_up started marking, do this */
986: else if( LinesMarked == 1 ) {
987: if ( (TopRow + CurRow) != 0 ) { /* if not at top of screen, */
988: MarkedLine[ TopRow + CurRow - 1 ] = 1; /* mark next line up */
989: if ( CurRow == 0 ) {
990: TopRow -= 1; /* ...may have to scroll */
1.1.1.2 ! root 991: VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1,
! 992: buff, 0);
1.1 root 993: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
994: }
995: else {
996: CurRow -= 1; /* ...or may not have to scroll */
997: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1.1.1.2 ! root 998: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 999: }
1000: drawline(); /* redraw line move to */
1001: }
1002: }
1003:
1004: /* if lines marked, and shift_down started marking, do this */
1005: else if( LinesMarked == 2 ) {
1006: MarkedLine[ TopRow + CurRow ] = 0; /* un-mark current line */
1007: drawline(); /* redraw it */
1008: if( (TopRow + CurRow) != 0 ) {
1009: if( CurRow == 0 ) { /* ...may have to scroll down */
1010: TopRow -= 1;
1.1.1.2 ! root 1011: VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1,
! 1012: buff, 0);
1.1 root 1013: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1014: }
1015: else { /* or may not have to scroll down */
1016: CurRow -= 1;
1017: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1.1.1.2 ! root 1018: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 1019: }
1020: if( !MarkedLine[ TopRow + CurRow - 1 ] ) { /* if line moved to */
1021: MarkedLine[ TopRow + CurRow ] = 0; /* is last marked, */
1022: LinesMarked = 0; /* clear it too */
1023: drawline();
1024: }
1025: }
1026: }
1027:
1028: line25(); /* update line numbers on 25th line to reflect changes */
1029:
1030: }
1031:
1032:
1033: /*** shift_down() - moves cursor down one line and marks lines for deletion
1034: *
1035: * shift_down() moves the cursor one line down. If no lines are marked, then
1036: * both the previous line and the line moved to get marked for deletion.
1037: * If lines are already marked, and were marked starting with another
1038: * shift_down, then only the line we move to gets marked (the one we just
1039: * left would already be marked). If there are lines marked but they
1040: * were marked starting with a shift_up, then we un-mark the line we
1041: * just left and do nothing to the line moved to. Unless the line moved
1042: * to is the last one marked, in which case we un-mark it also to clear all
1043: * markings. To determine how lines first got marked - by a shift_up or
1044: * shift_down - we give the flag LinesMarked two different TRUE values,
1045: * 1 or 2 respectively.
1046: *
1047: * EFFECTS: EditBuff[] - flushes and reloads
1048: * EditBuffDirty - clears
1049: * LinesMarked - sets this flag, unless un-marking only
1050: * marked line present, in which case clears it
1051: * MarkedLine[] - may set or clear this
1052: * CharsMarked - clears this flag as we now have marked lines
1053: * MarkedChar[] - clears all
1054: * TopRow - incremented one if at bottom of page
1055: * CurRow - incremented one if not at bottom of page
1056: */
1057:
1058: void shift_down()
1059: {
1060: register short i; /* indexing variable */
1061:
1062: char buff[2]; /* local buffer for fill character */
1063: buff[0] = 32; /* character = 32 = <blank> */
1064: buff[1] = ForeHilite + BackHilite; /* attribute = highlighted */
1065:
1066: if (EditBuffDirty) { /* this call will change */
1067: EditBuffDirty = 0; /* cursor line, so flush */
1068: flushline((TopRow + CurRow), EditBuff); /* edit buffer if dirty */
1069: }
1070:
1071: if ( CharsMarked ) { /* clear all character */
1072: CharsMarked = 0; /* markings, since line */
1073: for ( i = 0; i < LINESIZE; i++ ) /* is now marked. */
1074: MarkedChar[i] = 0;
1075: }
1076:
1077: /* if no lines are currently marked, do this */
1078: if( !LinesMarked ) {
1079: LinesMarked = 2; /* set flag to show marking started with DOWN */
1080: MarkedLine[ TopRow + CurRow ] = 1; /* mark current line */
1081: drawline(); /* and redraw it */
1082: if( ( TopRow + CurRow ) < TotalLines ) { /* if room to move down, */
1083: MarkedLine[ TopRow + CurRow + 1 ] = 1; /* mark line below */
1084: if ( CurRow == (PageSize - 1) ) {
1085: TopRow += 1; /* ...may have to scroll */
1.1.1.2 ! root 1086: VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1,
! 1087: buff, 0);
1.1 root 1088: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1089: }
1090: else { /* ...or may not have to scroll */
1091: CurRow += 1;
1092: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1.1.1.2 ! root 1093: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 1094: }
1095: drawline(); /* redraw new line */
1096: }
1097: }
1098:
1099: /* if lines are marked, and first marking was another shift_down, do this */
1100: else if( LinesMarked == 2 ) {
1101: if ( (TopRow + CurRow) < TotalLines ) { /* if room to move down */
1102: MarkedLine[ TopRow + CurRow + 1 ] = 1; /* mark line below */
1103: if ( CurRow == (PageSize - 1) ) {
1104: TopRow += 1; /* ...may have to scroll */
1.1.1.2 ! root 1105: VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1,
! 1106: buff, 0);
1.1 root 1107: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1108: }
1109: else { /* ...or may not have to scroll */
1110: CurRow += 1;
1111: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1.1.1.2 ! root 1112: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 1113: }
1114: drawline(); /* redraw the current line to show markings */
1115: }
1116: }
1117:
1118: /* if lines are marked, and first marking was a shift_up, do this */
1119: else if( LinesMarked == 1 ) {
1120: MarkedLine[ TopRow + CurRow ] = 0; /* un-mark current line */
1121: drawline(); /* and redraw it */
1122: if ( (TopRow + CurRow) < TotalLines ) {
1123: if ( CurRow == (PageSize - 1) ) {
1124: TopRow += 1; /* ...may have to scroll */
1.1.1.2 ! root 1125: VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1,
! 1126: buff, 0);
1.1 root 1127: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1128: }
1129: else { /* ...or may not have to scroll */
1130: CurRow += 1;
1131: getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */
1.1.1.2 ! root 1132: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 1133: }
1134: }
1135: if( (TopRow + CurRow) < TotalLines ) {
1136: if( !MarkedLine[ TopRow + CurRow + 1 ] ) {
1137: MarkedLine[ TopRow + CurRow ] = 0;
1138: LinesMarked = 0; /* if only 1 line left */
1139: } /* marked, un-mark it too */
1140: }
1141: drawline(); /* redraw line to reflect markings */
1142:
1143: }
1144:
1145: line25(); /* update line info on bottom line to show changes */
1146:
1147: }
1148:
1149:
1150: /*** shift_home() - moves cursor to first character in current line and
1151: * marks all characters in between for deletion
1152: *
1153: * shift_down() moves the cursor to the first printable character in the
1154: * current line. If the line is already marked, that's all it does, just
1155: * like a regular home except markings are not cleared. Otherwise, all
1156: * characters between the cursor position when the function is called and
1157: * the first character in the line get their markings toggled - that is, if
1158: * they are not marked they get marked, if they are already marked they
1159: * get un-marked.
1160: *
1161: * EFFECTS: EditBuff[] - flushes and reloads
1162: * EditBuffDirty - clears
1163: * CharsMarked - sets this flag unless line is marked
1164: * MarkedChar[] - sets for all appropriate characters
1165: * CurCol - set to position of first printable character
1166: */
1167:
1168: void shift_home()
1169: {
1170:
1171: register short i, j; /* indexing variables */
1172:
1173: if (EditBuffDirty) { /* this call will need to */
1174: EditBuffDirty = 0; /* get correct info on */
1175: flushline((TopRow + CurRow), EditBuff); /* line length, so flush */
1176: } /* edit buffer if dirty */
1177:
1178: if( (TopRow + CurRow) < TotalLines ) {
1179: i = LineTable[TopRow + CurRow]->linelength; /* i is position + 1 */
1180: } /* last char in line */
1181: else i = 0;
1182:
1183: for( j = 0; ( j < i ) && !isgraph(EditBuff[j]); j++ );
1184: /* j is position of */
1185: /* first non-blank */
1186: if( !LinesMarked ) { /* if no lines marked, */
1187: if( j < CurCol ) { /* flag everything between */
1188: CharsMarked = 1; /* CurCol and j as Marked */
1189: for( i = j; i < CurCol; i++ ) {
1190: if( !MarkedChar[i] )
1191: MarkedChar[i] = 1; /* may be moving forward... */
1192: else MarkedChar[i] = 0;
1193: }
1194: }
1195: else if( j > CurCol ) {
1196: CharsMarked = 1;
1197: for( i = CurCol; i < j; i++ ) { /* ... or backward */
1198: if( !MarkedChar[i] )
1199: MarkedChar[i] = 1;
1200: else MarkedChar[i] = 0;
1201: }
1202: }
1203: }
1204:
1205: CurCol = j; /* if lines are marked, just move */
1.1.1.2 ! root 1206: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 1207: drawline(); /* redraw line to show markings */
1208:
1209: }
1210:
1211:
1212: /*** shift_end() - moves cursor to one beyond last character in current line
1213: * and marks all characters in between for deletion
1214: *
1215: * shift_down() moves the cursor to one position beyond the last printable
1216: * character in the current line. If the line is already marked, that's all
1217: * it does, just like a regular end_ except markings are not cleared.
1218: * Otherwise, all characters between the cursor position when the function
1219: * is called and the final cursor position get their markings toggled - that
1220: * is, if they are not marked they get marked, if they are already marked
1221: * they get un-marked.
1222: *
1223: * EFFECTS: EditBuff[] - flushes and reloads
1224: * EditBuffDirty - clears
1225: * CharsMarked - sets this flag unless line is marked
1226: * MarkedChar[] - sets for all appropriate characters
1227: * CurCol - set to one beyond position of
1228: * last printable character
1229: */
1230:
1231: void shift_end()
1232: {
1233:
1234: register short i, j; /* indexing variables */
1235:
1236: if (EditBuffDirty) { /* this call will need to */
1237: EditBuffDirty = 0; /* get correct info on */
1238: flushline((TopRow + CurRow), EditBuff); /* line length, so flush */
1239: } /* edit buffer if dirty */
1240:
1241: if( (TopRow + CurRow) < TotalLines ) {
1242: i = LineTable[TopRow + CurRow]->linelength; /* i is position + 1 */
1243: } /* last char in line */
1244: else i = 0;
1245:
1246: if( !LinesMarked ) { /* if no lines marked, */
1247: if( i < CurCol ) { /* flag everything between */
1248: CharsMarked = 1; /* CurCol and i as Marked */
1249: for( j = i; j < CurCol; j++ ) {
1250: if( !MarkedChar[j] ) /* may move forwards... */
1251: MarkedChar[j] = 1;
1252: else MarkedChar[j] = 0;
1253: }
1254: }
1255: else if( i > CurCol ) {
1256: CharsMarked = 1; /* ... or backwards */
1257: for( j = CurCol; j < i; j++ ) {
1258: if( !MarkedChar[j] )
1259: MarkedChar[j] = 1;
1260: else MarkedChar[j] = 0;
1261: }
1262: }
1263: }
1264:
1265: CurCol = i; /* if line is marked, just move */
1.1.1.2 ! root 1266: VioSetCurPos( CurRow, CurCol, 0 );
1.1 root 1267: drawline(); /* redraw */
1268:
1269: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.