1 /* ELLE - Copyright 1982, 1984, 1987 by Ken Harrenstien, SRI International
2 * This software is quasi-public; it may be used freely with
3 * like software, but may NOT be sold or made part of licensed
4 * products without permission of the author.
7 * EEF3 Various Functions (Yanking, Indentation, miscellaneous)
13 /* EFUN: "Append Next Kill" */
15 { this_cmd
= KILLCMD
; /* Fake out next call to ed_kill */
17 #endif /*FX_APPNKILL*/
24 if((sd
= kill_ring
[kill_ptr
]) == 0)
28 mark_dot
= cur_dot
; /* Set mark at old location */
29 mark_p
= 1; /* Mark's been set */
30 sb_sins((SBBUF
*)cur_buf
,sbs_cpy(sd
)); /* Insert copy of stuff */
31 cur_dot
= e_dot(); /* We're now after the new stuff */
32 buf_tmat(mark_dot
); /* Say modified from here to cur_dot*/
38 /* EFUN: "Un-kill Pop" */
43 if (last_cmd
!= YANKCMD
)
47 ed_delete(cur_dot
,mark_dot
);
48 if(cur_dot
> mark_dot
)
53 kill_ptr
= KILL_LEN
-1;
54 if(sd
= kill_ring
[kill_ptr
])
58 /* kill_ptr now pointing to right place; effect the yank. */
59 e_gocur(); /* Make sure point at right place too! */
64 /* Indentation routines - still not polished */
67 /* EFUN: "Indent According to Mode" */
68 /* In Fundamental mode, just inserts a tab.
71 { f_insself(TAB
); /* This takes care of mode checking */
76 /* EFUN: "Indent New Line" */
77 f_indnl() /* execute CR followed by tab */
80 /* Not dispatch-based, but rather hard-wired to do Gosmacs thing */
92 /* EFUN: "Back to Indentation"
93 ** Moves to end of current line's indentation.
96 { e_gobol(); /* First move to beg of line */
97 e_gofwsp(); /* Then forward over whitespace */
100 #endif /*FX_BACKIND*/
105 static char *comm_beg
= "/* ";
106 static char *comm_end
= " */";
108 /* EFUN: "Indent for Comment" */
112 if(indtion(cur_dot
) < ev_ccolumn
)
113 ed_indto(ev_ccolumn
);
117 e_igoff(-strlen (comm_end
)); /* back over end string */
120 #endif /*FX_INDCOMM*/
123 /* EFUN: "Indent Relative" */
124 /* This used to mistakenly be called Indent Under.
125 ** Still not fully implemented.
126 ** If at beginning of line, looks back at previous indented line,
127 ** and indents this line that much. If there is no preceding indented
128 ** line or not at beginning of line, insert a tab.
138 int curind
, newind
, morebuf
;
139 #endif /*ICONOGRAPHICS*/
141 if((c
= e_rgetc()) == EOF
)
143 return(f_insself(TAB
)); /* Do mode-based tabbing */
145 return(ed_insert(TAB
));
152 e_gonl(); /* Return to orig pos */
158 ed_delete(savdot
, e_dot());
166 curind
= indtion (savdot
= e_dot ());
167 /* get current dot and indentation */
168 while (1) /* find a prev line that extends rightward */
169 { morebuf
= e_gopl ();
171 if ((newind
= d_curind()) > curind
) break;
172 if (morebuf
== 0) /* hit beginning of buffer */
180 e_igoff (inindex (e_dot (), curind
));
181 if (d_curind() > curind
)
182 e_rgetc (); /* pushed ahead by tab */
184 while (c_wsp (e_getc ()) == 0) ;
195 f_insself(TAB
); /* Do mode-based tabbing */
199 #endif /*-ICONOGRAPHICS*/
204 /* Paren matching stuff. Note that this stuff will be very painful unless
205 ** tinwait() works properly.
208 /* EFUN: "Self-Insert and Match" (intended to be bound to brackets) */
209 /* (KLH: Evidently this was never finished)
218 /* Should change this to Matching Paren */
220 /* EFUN: "Match Bracket" (not EMACS) - from IMAGEN config
221 * Show the matching bracket for the character right before dot
226 register int i
, mc
, secs
;
232 savdot
= cur_dot
; /* Save our location */
233 mc
= e_rgetc(); /* Pick up character before dot */
234 if (mc
!= ')' && mc
!= ']' && mc
!= '}')
235 { e_getc(); /* Nothing, try at dot instead */
238 if (mc
!= ')' && mc
!= ']' && mc
!= '}')
239 { ding("What bracket?");
244 if (! matchonelevel(mc
))
248 if (d_line(cur_dot
) < 0)
249 secs
= 10; /* Wait longer if off-screen */
250 redisplay(); /* Wish it were simple upd_wind() */
251 for (i
= 1; i
<= secs
; ++i
)
257 e_gosetcur(savdot
); /* Back to origin */
258 redp(RD_MOVE
); /* Cursor has moved */
262 /* Try to match 'mc', return true iff found it */
268 while ((c
= e_rgetc()) != EOF
)
269 { if (c
== /*[*/ ']' || c
== /*(*/ ')' || c
== /*{*/ '}')
270 { if (! matchonelevel(c
))
273 else if (c
== '(' /*)*/)
274 return(mc
== /*(*/ ')');
275 else if (c
== '[' /*]*/)
276 return(mc
== /*[*/ ']');
277 else if (c
== '{' /*}*/)
278 return(mc
== /*{*/ '}');
282 #endif /*FX_MATCHBRACK*/