diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/Makefile.in readline-4.1-hacked/Makefile.in --- readline-4.1-orig/Makefile.in Wed Dec 29 22:02:40 1999 +++ readline-4.1-hacked/Makefile.in Sun Dec 17 18:36:20 2000 @@ -85,7 +85,8 @@ $(srcdir)/callback.c $(srcdir)/terminal.c $(srcdir)/xmalloc.c \ $(srcdir)/history.c $(srcdir)/histsearch.c $(srcdir)/histexpand.c \ $(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \ - $(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c + $(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \ + $(srcdir)/formatregion.c # The header files for this library. HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \ @@ -97,7 +98,7 @@ OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \ rltty.o complete.o bind.o isearch.o display.o signals.o \ util.o kill.o undo.o macro.o input.o callback.o terminal.o \ - nls.o xmalloc.o $(HISTOBJ) $(TILDEOBJ) + nls.o xmalloc.o formatregion.o $(HISTOBJ) $(TILDEOBJ) # The texinfo files which document this library. DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/complete.c readline-4.1-hacked/complete.c --- readline-4.1-orig/complete.c Tue Feb 22 18:50:05 2000 +++ readline-4.1-hacked/complete.c Mon Dec 18 22:22:34 2000 @@ -546,8 +546,8 @@ quote, or backslash) anywhere in the string. DP, if non-null, is set to the value of the delimiter character that caused a word break. */ -static char -find_completion_word (fp, dp) +char +_rl_find_completion_word (fp, dp) int *fp, *dp; { int scan, end, found_quote, delimiter, pass_next, isbrk; @@ -842,7 +842,9 @@ int nmatch, i; matches = *matchesp; - + if(!matches) + return 0; + /* It seems to me that in all the cases we handle we would like to ignore duplicate possiblilities. Scan for the text to insert being identical to the other completions. */ @@ -1209,17 +1211,50 @@ rl_end_undo_group (); } -static void -free_match_list (matches) +void +_rl_free_match_list (matches) char **matches; { register int i; - + if(!matches) + return; + for (i = 0; matches[i]; i++) free (matches[i]); free (matches); } +char** +_rl_available_completions(start,end,found_quote,quote_char) + int start; + int end; + int found_quote; + char quote_char; +{ + Function *our_func; + char *text; + char**matches; + + our_func = rl_completion_entry_function + ? rl_completion_entry_function + : (Function *)filename_completion_function; + text = rl_copy_text (start, end); + matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char); + free (text); + + /* If we are matching filenames, the attempted completion function will + have set rl_filename_completion_desired to a non-zero value. The basic + filename_completion_function does this. */ + if(!matches) + return 0; + + if(!postprocess_matches (&matches, rl_filename_completion_desired)) + return 0; /* matches is freed by this function on error */ + + return matches; +} + + /* Complete the word at or before point. WHAT_TO_DO says what to do with the completion. `?' means list the possible completions. @@ -1232,9 +1267,8 @@ int what_to_do; { char **matches; - Function *our_func; - int start, end, delimiter, found_quote, i; - char *text, *saved_line_buffer; + int start, end, delimiter, found_quote; + char *saved_line_buffer; char quote_char; /* Only the completion entry function can change these. */ @@ -1243,9 +1277,6 @@ rl_completion_type = what_to_do; saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL; - our_func = rl_completion_entry_function - ? rl_completion_entry_function - : (Function *)filename_completion_function; /* We now look backwards for the start of a filename/variable word. */ end = rl_point; @@ -1255,37 +1286,16 @@ if (rl_point) /* This (possibly) changes rl_point. If it returns a non-zero char, we know we have an open quote. */ - quote_char = find_completion_word (&found_quote, &delimiter); + quote_char = _rl_find_completion_word (&found_quote, &delimiter); start = rl_point; rl_point = end; - text = rl_copy_text (start, end); - matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char); - free (text); - + matches = _rl_available_completions(start,end,found_quote,quote_char); if (matches == 0) { ding (); FREE (saved_line_buffer); - return (0); - } - -#if 0 - /* If we are matching filenames, our_func will have been set to - filename_completion_function */ - i = our_func == (Function *)filename_completion_function; -#else - /* If we are matching filenames, the attempted completion function will - have set rl_filename_completion_desired to a non-zero value. The basic - filename_completion_function does this. */ - i = rl_filename_completion_desired; -#endif - - if (postprocess_matches (&matches, i) == 0) - { - ding (); - FREE (saved_line_buffer); completion_changed_buffer = 0; return (0); } @@ -1336,7 +1346,7 @@ return 1; } - free_match_list (matches); + _rl_free_match_list (matches); /* Check to see if the line has changed through all of this manipulation. */ if (saved_line_buffer) @@ -1685,7 +1695,7 @@ /* Clean up from previous call, if any. */ FREE (orig_text); if (matches) - free_match_list (matches); + _rl_free_match_list (matches); match_list_index = match_list_size = 0; matches = (char **)NULL; @@ -1707,7 +1717,7 @@ if (rl_point) /* This (possibly) changes rl_point. If it returns a non-zero char, we know we have an open quote. */ - quote_char = find_completion_word (&found_quote, &delimiter); + quote_char = _rl_find_completion_word (&found_quote, &delimiter); orig_start = rl_point; rl_point = orig_end; diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/display.c readline-4.1-hacked/display.c --- readline-4.1-orig/display.c Thu Sep 16 16:19:40 1999 +++ readline-4.1-hacked/display.c Sun Feb 11 14:37:27 2001 @@ -52,6 +52,7 @@ #include "history.h" #include "rlprivate.h" +#include "formatregion.h" #include "xmalloc.h" #if !defined (strchr) && !defined (__STDC__) @@ -1067,6 +1068,7 @@ { if (visible_line) visible_line[0] = '\0'; + rl_fr_clear(); _rl_last_c_pos = _rl_last_v_pos = 0; _rl_vis_botlin = last_lmargin = 0; @@ -1084,6 +1086,8 @@ { int prompt_size, i, l, real_screenwidth, newlines; char *prompt_last_line; + + rl_fr_clear(); /* Initialize visible_line and invisible_line to ensure that they can hold the already-displayed prompt. */ diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/examples/Makefile.in readline-4.1-hacked/examples/Makefile.in --- readline-4.1-orig/examples/Makefile.in Tue Sep 21 21:45:37 1999 +++ readline-4.1-hacked/examples/Makefile.in Sun Dec 17 18:36:20 2000 @@ -50,13 +50,13 @@ all: $(EXECUTABLES) -rl: rl.o +rl: rl.o $(READLINE_LIB) $(CC) $(LDFLAGS) -o $@ rl.o -lreadline $(TERMCAP_LIB) -fileman: fileman.o +fileman: fileman.o $(READLINE_LIB) $(CC) $(LDFLAGS) -o $@ fileman.o -lreadline $(TERMCAP_LIB) -rltest: rltest.o +rltest: rltest.o $(READLINE_LIB) $(CC) $(LDFLAGS) -o $@ rltest.o -lreadline $(TERMCAP_LIB) rlversion: rlversion.o $(READLINE_LIB) diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/formatregion.c readline-4.1-hacked/formatregion.c --- readline-4.1-orig/formatregion.c Thu Jan 1 01:00:00 1970 +++ readline-4.1-hacked/formatregion.c Mon Dec 18 22:42:57 2000 @@ -0,0 +1,588 @@ +#define READLINE_LIBRARY + +#if defined (HAVE_CONFIG_H) +# include +#endif + +#include + +#include "readline.h" +#include "rlprivate.h" +#include "rldefs.h" +#include "xmalloc.h" + +#include "formatregion.h" + +#define DEBUG_FORMATREGION + +#ifdef DEBUG_FORMATREGION +static FILE*debout = 0; +#define debug(x...) do { if(debout) {fprintf(debout,x);fflush(debout);} } while(0) +#else +static inline void debug(format) + char*format; + { } +#endif + +static struct rl_fr_region* fr_regions = 0; + +#define fr_tail_completer(fr) ((struct rl_fr_region*)(fr)->private[0]) +#define fr_completer_tail(fr) ((struct rl_fr_region*)(fr)->private[0]) +#define fr_completer_generator(fr) ((rl_fr_completer_generator)(fr)->private[1]) +#define fr_completer_matcher(fr) ((rl_fr_completer_matcher)(fr)->private[2]) +#define fr_completer_user(fr) ((fr)->private[3]) + +static inline void fr_add_tail __P((struct rl_fr_region*)); + +static char* minimal_suffix(start,end,suffix) + char*start; + char*end; + char*suffix; +{ + char*p,*b,*s; + + for(p=start;p=end) + return s; + + if((*b!=*s) || (!*s)) + break; + } + } + } + + return s; +} + +static inline void safeappend(char **buffer, unsigned*len, unsigned* pos, char*str, unsigned slen) +{ + if(!str || !slen) + return; + *len+=slen; + (*buffer)=(char*)xrealloc(*buffer,*len); + + { + char*i=(*buffer+*pos); + char*end=(*buffer+*pos+slen); + *pos += slen; + + while(i!=end)*i++=*str++; + } +} + +static inline void expand_append(char **buffer, unsigned*len, unsigned* pos, char*str, int*new_point) +{ + unsigned slen; + + if(!str || !str[0]) return; + + slen = strlen(str); + + if(*new_point>*pos) + (*new_point)+=slen; + + safeappend(buffer,len,pos,str,slen); +} + +static void inline debug_dump_regions() +{ + struct rl_fr_region* fr; + debug("dumping state; line is \"%s\"\n",rl_line_buffer); + for(fr=fr_regions;fr;fr=fr->next) + { + debug("format at %x (start %d, end %d)\n",(unsigned)fr,fr->start,fr->end); + } +} + +static inline short fr_holds_insertwise(fr,point) + struct rl_fr_region* fr; + int point; +{ + if(fr->end==0 && point==0)return 1; + return (point > fr->start && point <= fr->end); + /* Unexpectedly different in/exclusive rules apply: something + inserted at the end belongs to *this* region */ +} +static inline void fr_shr(fr,step) + struct rl_fr_region* fr; + int step; +{ + fr->start += step; + fr->end += step; +} + +static inline void fr_shl(fr,step) + struct rl_fr_region* fr; + int step; +{ + fr_shr(fr,-step); +} + + +inline void rl_fr_remove(fr) + struct rl_fr_region* fr; +{ + if(fr->next) + fr->next->prev = fr->prev; + if(fr->prev) + fr->prev->next = fr->next; + if(fr==fr_regions) + fr_regions=fr->next; + + fr->dtor(fr); + + xfree(fr); +} + +static inline short fr_remove_empty(fr) + struct rl_fr_region* fr; +{ + if(fr->end <= fr->start) + { + debug("removing %x from %d - %d\n",(unsigned)fr,fr->start,fr->end); + rl_fr_remove(fr); + return 1; + } + else return 0; +} + +static inline void fr_add(fr) + struct rl_fr_region* fr; +{ + fr->prev = 0; + fr->next = fr_regions; + + debug("adding %x\n",(unsigned)fr); + + if(fr_regions) + fr_regions->prev = fr; + + fr_regions = fr; + debug_dump_regions(); +} + +static inline void fr_start(fr,start) + struct rl_fr_region* fr; + int start; +{ + fr->start = start; +} + +static inline void fr_end(fr,end) + struct rl_fr_region* fr; + int end; +{ + fr->end = end; +} + +static void fr_std_ins(fr,start,length) + struct rl_fr_region* fr; + int start; + int length; +{ +} + +static void fr_std_del(fr,start,length) + struct rl_fr_region* fr; + int start; + int length; +{ +} + +static void fr_std_ponder(fr,buffer) + struct rl_fr_region*fr; + const char*buffer; +{ +} + +char** rl_fr_tail_matcher(fr) + struct rl_fr_region* fr; +{ + if(fr->start >= fr->end) + return 0; + + return + fr_completer_generator(fr) ? + fr_completer_generator(fr)(fr,fr->start,fr->end) : 0; +} + +char** rl_fr_word_matcher(fr) + struct rl_fr_region* fr; +{ + int start = fr->start; + int end = fr->end; + + if(end) + { + int saved = rl_point; + + rl_point = end; + + debug("completing word finding in %s from %d to %d\n",rl_line_buffer,start,end); + _rl_find_completion_word (0,0); + start = rl_point; /* (semantics) should it be checked that this is *after* fr->start? */ + debug("completing word found %d to %d: \"",start,end); + for(rl_point = start; rl_point < end; rl_point++){ + debug("%c",rl_line_buffer[rl_point]); + } + debug("\"\n"); + rl_point = saved; + } + if(start>=end||!rl_line_buffer[start])return 0; + return + fr_completer_generator(fr) ? + fr_completer_generator(fr)(fr,start,end) : 0; +} + + +static void fr_tail_complete(fr) + struct rl_fr_region* fr; +{ + struct rl_fr_region* completer = fr_tail_completer(fr); + int os=fr->start,oe=fr->end,op=rl_point; + int ocs=completer->start, oce=completer->end; + char**matches= fr_completer_matcher(completer) ? + fr_completer_matcher(completer)(completer) : 0; + char*match; + + debug("--- avoiding insert and delete events\n"); + + completer->start = fr->start = -2; + completer->end = fr->end = -1; + + if(oe>0) + rl_delete_text(oce,oce + (oe-os)); + + if(matches && (match=*matches)) { + debug("match selected was \"%s\"\n",match); + match = minimal_suffix(rl_line_buffer+ocs,rl_line_buffer+oce,match); + debug("the minimal suffix was \"%s\"\n", match); + + rl_point = oce; + rl_insert_text(match); + fr->end = oce+strlen(match); + + if(oe > 0 && op > oe) + rl_point = op-oe + fr->end; + else + rl_point = op; + } + else + fr->end = oce; + + _rl_free_match_list (matches); + + completer->start = ocs; + completer->end = oce; + fr->start = oce; + + debug("+++ no longer avoiding insert and delete events\n"); + debug_dump_regions(); +} + +static void fr_tail_ins(fr,start,length) + struct rl_fr_region* fr; + int start; + int length; +{ + struct rl_fr_region* completer = fr_tail_completer(fr); + fr_end(completer,start); /* length will be added on by rl_fr_inserted */ +} + +static void fr_tail_del(fr,start,length) + struct rl_fr_region* fr; + int start; + int length; +{ + struct rl_fr_region* completer = fr_tail_completer(fr); + + if(start >= completer->end) + completer->end = start; /* for future syntax coloring, otherwise a NOP */ +} + + +static void fr_tail_dtor(fr) + struct rl_fr_region* fr; +{ + if(fr_tail_completer(fr)) + fr_completer_tail(fr_tail_completer(fr)) = 0; +} + + +static void fr_completer_ins(fr,start,length) + struct rl_fr_region* fr; + int start; + int length; +{ + fr_std_ins(fr,start,length); + if(!fr_completer_tail(fr))fr_add_tail(fr); + + fr_tail_complete(fr_completer_tail(fr)); +} + +static void fr_completer_del(fr,start,length) + struct rl_fr_region* fr; + int start; + int length; +{ + fr_std_del(fr,start,length); + if(!fr_completer_tail(fr))fr_add_tail(fr); + + if(start + length <= fr->end) + fr_tail_complete(fr_completer_tail(fr)); +} + +static void fr_std_clear(fr) + struct rl_fr_region* fr; +{ + rl_fr_remove(fr); +} + +static void fr_std_dtor(fr) + struct rl_fr_region* fr; +{ +} + +static void fr_completer_dtor(fr) + struct rl_fr_region* fr; +{ + if(fr_completer_tail(fr)) + fr_tail_completer(fr_completer_tail(fr)) = 0; +} + +static void fr_persist_clear(fr) + struct rl_fr_region* fr; +{ + fr->start = 0; + fr->end = rl_end; +} + +void rl_fr_inserted(start,length) + int start; + int length; +{ + struct rl_fr_region* fr; + + debug("inserted at %d length %d\n",start,length); + debug_dump_regions(); + + for(fr=fr_regions;fr;fr=fr->next){ + if((fr->start || start) && fr->start >= start){ + fr_shr(fr,length); + continue; + } + if(fr->end < start) + continue; + fr->end+=length; + debug("->ins to %x\n",(unsigned)fr); + fr->ins(fr,start,length); + } + + debug("post insert\n"); + debug_dump_regions(); +} + +void rl_fr_deleted(start,length) + int start; + int length; +{ + struct rl_fr_region* fr; + + debug("deleted from %d length %d\n",start,length); + debug_dump_regions(); + if(!length) return; + + for(fr=fr_regions;fr;fr=fr->next) + { + if(fr->end <= start) + continue; + + if(fr->start >= start+length) + { + fr_shl(fr,length); + continue; + } + + if(fr->start <= start) /* fr->end > start */ + { + if(start+length < fr->end) + { + fr->end -= length; + } + else + { + fr->end = start; + } + } + else /* fr->start > start */ + { + if(start+length < fr->end) + { + fr->end -= length - (fr->start - start); + fr->start = start; + } + else /* start+length >= fr-> end && fr->start < start*/ + { + fr->start = start; + fr->end = start; + } + } + debug("->del to %x\n",(unsigned)fr); + fr->del(fr,start,length); + } + debug("post delete\n"); + debug_dump_regions(); +} + + +inline static void fr_std_init(fr) + struct rl_fr_region*fr; +{ + fr->on = 0; + fr->off = 0; + fr->start = 0; + fr->end = 0; + fr->ponder = fr_std_ponder; + fr->ins = fr_std_ins; + fr->del = fr_std_del; + fr->dtor = fr_std_dtor; + fr->clear = fr_std_clear; + + fr->next = fr->prev = 0; +} + +inline static void fr_tail_init(fr,completer) + struct rl_fr_region*fr; + struct rl_fr_region*completer; +{ + fr_std_init(fr); + fr->ins = fr_tail_ins; + fr->del = fr_tail_del; + fr->dtor = fr_tail_dtor; + + fr_tail_completer(fr) = completer; + fr_completer_tail(completer) = fr; +} + +inline static void fr_add_tail(completer) + struct rl_fr_region*completer; +{ + struct rl_fr_region*fr=(struct rl_fr_region*)xmalloc(sizeof(struct rl_fr_region)); + + fr_tail_init(fr,completer); + fr_start(fr,-1); + fr_end(fr,-1); + + fr_add(fr); +} + +inline static void fr_completer_init(fr,matcher,generator,userhook) + struct rl_fr_region*fr; + rl_fr_completer_matcher matcher; + rl_fr_completer_generator generator; + void* userhook; +{ + fr_std_init(fr); + + fr->ins = fr_completer_ins; + fr->del = fr_completer_del; + + fr_completer_matcher(fr) = matcher; + fr_completer_generator(fr) = generator; + fr_completer_user(fr) = userhook; + fr_completer_tail(fr) = 0; + + fr->dtor = fr_completer_dtor; +} + +void rl_fr_add_completer(start,end,matcher,generator,userhook) + int start; + int end; + rl_fr_completer_matcher matcher; + rl_fr_completer_generator generator; + void* userhook; +{ + struct rl_fr_region*fr=(struct rl_fr_region*)xmalloc(sizeof(struct rl_fr_region)); + + fr_completer_init(fr,matcher,generator,userhook); + fr_start(fr,start); + fr_end(fr,end); + + fr_add(fr); +} + +static void init_fr() +{ +#ifdef DEBUG_FORMATREGION + if(!debout){ + debout = fopen("/tmp/debout","w"); + } +#endif + if(!fr_regions){ + rl_fr_add_completer(0,0, + rl_fr_word_matcher, + rl_fr_cppfunction_generator, + rl_fr_default_matches); + rl_fr_persist(fr_regions); + } +} + + +void rl_fr_clear() + /* called when a new line appears */ +{ + struct rl_fr_region *fr, *next; + init_fr(); + + debug("clearing\n"); + debug_dump_regions(); + for(fr=fr_regions;fr;fr=next) + { + debug("clearing format at %x (start %d, end %d)\n",(unsigned)fr,fr->start,fr->end); + next=fr->next; + fr->clear(fr); /* most probably will delete the poor thing */ + } +} + +void rl_fr_persist(fr) + struct rl_fr_region*fr; +{ + fr->clear = fr_persist_clear; +} + +char** rl_fr_cpfunction_generator(fr,start,end) + struct rl_fr_region* fr; + int start; + int end; +{ + char*text = rl_copy_text(start,end); + char**matches = completion_matches (text,(CPFunction*)fr_completer_user(fr)); + debug("cpfunction generator\n"); + xfree(text); + return matches; +} + +char** rl_fr_cppfunction_generator(fr,start,end) + struct rl_fr_region* fr; + int start; + int end; +{ + debug("cppfunction generator\n"); + + return ((CPPFunction*)fr_completer_user(fr))(rl_line_buffer,start,end); +} + + +char** rl_fr_default_matches(text,start,end) + char*text; + int start; + int end; +{ + if(text != rl_line_buffer)abort(); + + return _rl_available_completions(start,end,0,0); +} diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/formatregion.h readline-4.1-hacked/formatregion.h --- readline-4.1-orig/formatregion.h Thu Jan 1 01:00:00 1970 +++ readline-4.1-hacked/formatregion.h Sun Dec 17 18:36:20 2000 @@ -0,0 +1,71 @@ +#ifndef _FORMATREGION_H_ +#define _FORMATREGION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + /* **************************************************************** */ + /* */ + /* Special format region support */ + /* */ + /* **************************************************************** */ + + struct rl_fr_region; + + typedef void (*rl_fr_ponder) __P((struct rl_fr_region*,const char*)); + typedef void (*rl_fr_ins_handler) __P((struct rl_fr_region*,int,int)); + typedef void (*rl_fr_del_handler) __P((struct rl_fr_region*,int,int)); + typedef void (*rl_fr_clear_handler) __P((struct rl_fr_region*)); + typedef void (*rl_fr_dtor) __P((struct rl_fr_region*)); + + struct rl_fr_region { + int start; /* inclusive */ + int end; /* exclusive */ + + /* terminal commands */ + char* on; + char* off; + + rl_fr_ponder ponder; + rl_fr_ins_handler ins; + rl_fr_del_handler del; + rl_fr_dtor dtor; + rl_fr_clear_handler clear; + + struct rl_fr_region* next; + struct rl_fr_region* prev; + + void*private[8]; + }; + + typedef char** (*rl_fr_completer_matcher) __P((struct rl_fr_region*)); + typedef char** (*rl_fr_completer_generator) __P((struct rl_fr_region*,int,int)); + + extern void rl_fr_add_completer __P((int,int,rl_fr_completer_matcher,rl_fr_completer_generator,void*)); + + /* A selection of rl_fr_completer_matchers: */ + extern char** rl_fr_tail_matcher __P((struct rl_fr_region*)); + extern char** rl_fr_word_matcher __P((struct rl_fr_region*)); + + /* A selection of rl_fr_completer_generators: */ + extern char** rl_fr_cpfunction_generator __P((struct rl_fr_region*,int,int)); + extern char** rl_fr_cppfunction_generator __P((struct rl_fr_region*,int,int)); + + extern void rl_fr_persist __P((struct rl_fr_region*)); + + extern void rl_fr_remove __P((struct rl_fr_region*)); + extern void rl_fr_inserted __P((int,int)); + extern void rl_fr_deleted __P((int,int)); + extern void rl_fr_clear __P((void)); + + extern char** rl_fr_default_matches __P((char*,int,int)); + + /* extern void rl_fr_expand __P((char**,int*,int*));*/ + +#ifdef __cplusplus +} +#endif + +#endif /* !_FORMATREGION_H_ */ diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/readline.c readline-4.1-hacked/readline.c --- readline-4.1-orig/readline.c Thu Aug 5 13:10:46 1999 +++ readline-4.1-hacked/readline.c Sun Feb 11 14:37:29 2001 @@ -65,6 +65,7 @@ #include "rlprivate.h" #include "rlshell.h" #include "xmalloc.h" +#include "formatregion.h" #ifndef RL_LIBRARY_VERSION # define RL_LIBRARY_VERSION "4.1" @@ -930,9 +931,12 @@ else rl_add_undo (UNDO_INSERT, rl_point, rl_point + l, (char *)NULL); } - rl_point += l; rl_end += l; the_line[rl_end] = '\0'; + + rl_fr_inserted(rl_point,l); + rl_point += l; + return l; } @@ -954,7 +958,7 @@ { to = rl_end; if (from > to) - from = to; + return 0; } text = rl_copy_text (from, to); @@ -972,6 +976,9 @@ rl_end -= diff; the_line[rl_end] = '\0'; + + rl_fr_deleted(from,diff); + return (diff); } @@ -1914,13 +1921,37 @@ return 0; } +void +rl_become_history(temp) + HIST_ENTRY* temp; +{ + int line_len; + + line_len = strlen (temp->line); + + if (line_len >= rl_line_buffer_len) + rl_extend_line_buffer (line_len); + + strcpy (the_line, temp->line); + rl_undo_list = (UNDO_LIST *)temp->data; + rl_end = rl_point = line_len; + + rl_fr_clear(); + +#if defined (VI_MODE) + if (rl_editing_mode == vi_mode) + rl_point = 0; +#endif /* VI_MODE */ + +} + + /* Move down to the next history line. */ int rl_get_next_history (count, key) int count, key; { HIST_ENTRY *temp; - int line_len; if (count < 0) return (rl_get_previous_history (-count, key)); @@ -1942,20 +1973,7 @@ if (temp == 0) maybe_unsave_line (); else - { - line_len = strlen (temp->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strcpy (the_line, temp->line); - rl_undo_list = (UNDO_LIST *)temp->data; - rl_end = rl_point = strlen (the_line); -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_point = 0; -#endif /* VI_MODE */ - } + rl_become_history(temp); return 0; } @@ -1966,7 +1984,6 @@ int count, key; { HIST_ENTRY *old_temp, *temp; - int line_len; if (count < 0) return (rl_get_next_history (-count, key)); @@ -1999,21 +2016,7 @@ if (temp == 0) ding (); else - { - line_len = strlen (temp->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strcpy (the_line, temp->line); - rl_undo_list = (UNDO_LIST *)temp->data; - rl_end = rl_point = line_len; - -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_point = 0; -#endif /* VI_MODE */ - } + rl_become_history(temp); return 0; } diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/rlprivate.h readline-4.1-hacked/rlprivate.h --- readline-4.1-orig/rlprivate.h Mon Jan 24 15:40:34 2000 +++ readline-4.1-hacked/rlprivate.h Mon Dec 18 22:23:44 2000 @@ -34,6 +34,11 @@ * * *************************************************************************/ +/* complete.c */ +extern char** _rl_available_completions __P((int,int,int,char)); +extern char _rl_find_completion_word __P((int*, int*)); +extern void _rl_free_match_list __P((char**)); + /* terminal.c */ extern char *rl_get_termcap __P((char *)); diff --new-file -u --exclude *~ --exclude *.gcov --exclude gmon.out --recursive readline-4.1-orig/shlib/Makefile.in readline-4.1-hacked/shlib/Makefile.in --- readline-4.1-orig/shlib/Makefile.in Thu Aug 5 15:56:46 1999 +++ readline-4.1-hacked/shlib/Makefile.in Sun Dec 17 18:36:20 2000 @@ -108,7 +108,8 @@ $(topdir)/callback.c $(topdir)/terminal.c $(topdir)/xmalloc.c \ $(topdir)/history.c $(topdir)/histsearch.c $(topdir)/histexpand.c \ $(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \ - $(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c + $(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \ + $(topdir)/formatregion.c # The header files for this library. HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \ @@ -120,7 +121,7 @@ SHARED_OBJ = readline.so vi_mode.so funmap.so keymaps.so parens.so search.so \ rltty.so complete.so bind.so isearch.so display.so signals.so \ util.so kill.so undo.so macro.so input.so callback.so terminal.so \ - nls.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) + nls.so xmalloc.so formatregion.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) ##########################################################################