Changeset 10b866d for editwin.c


Ignore:
Timestamp:
Jul 8, 2002, 10:37:21 PM (22 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
e1c4636
Parents:
8df36cc
Message:
* Fixed preservation of e->dotsend across owl_editwin_clear().

* Added history for multiline edit windows (eg, for zephyr composition).
  The M-n and M-p keys will cycle through the history ring.
  In particular, it is now possible to edit the command line
  of a zephyr being composed:  C-c it and restart it
  and then M-p to get the aborted composition back.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    r217a43e r10b866d  
    33#include <unistd.h>
    44#include <string.h>
     5#include <ctype.h>
    56
    67static const char fileIdent[] = "$Id$";
     
    89#define INCR 5000
    910
    10 void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style) {
     11void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style, owl_history *hist) {
    1112  /* initialize the editwin e.
    1213   * 'win' is an already initialzed curses window that will be used by editwin
    1314   */
    14   e->buff=owl_malloc(INCR);
     15  e->buff=owl_malloc(INCR); 
    1516  e->buff[0]='\0';
    1617  e->bufflen=0;
     18  e->hist=hist;
    1719  e->allocated=INCR;
    1820  e->buffx=0;
     
    5052}
    5153
     54void owl_editwin_set_history(owl_editwin *e, owl_history *h) {
     55  e->hist = h;
     56}
     57
     58owl_history *owl_editwin_get_history(owl_editwin *e) {
     59  return e->hist;
     60}
     61
    5262void owl_editwin_set_dotsend(owl_editwin *e) {
    5363  e->dotsend=1;
     
    8595}
    8696
    87 void owl_editwin_new_style(owl_editwin *e, int newstyle) {
     97void owl_editwin_new_style(owl_editwin *e, int newstyle, owl_history *h) {
    8898  char *ptr;
    89  
     99
     100  owl_editwin_set_history(e, h);
    90101  if (e->style==newstyle) return;
    91102
     
    111122  /* completly reinitialize the buffer */
    112123  owl_free(e->buff);
    113   owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style);
     124  owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
    114125}
    115126
     
    117128  /* clear all text except for locktext and put the cursor at the beginning */
    118129  int lock;
     130  int dotsend=e->dotsend;
    119131  char *locktext=NULL;
    120  
     132
    121133  lock=0;
    122134  if (e->lock > 0) {
     
    129141
    130142  owl_free(e->buff);
    131   owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style);
     143  owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
    132144
    133145  if (lock > 0) {
    134146    owl_editwin_set_locktext(e, locktext);
     147  }
     148  if (dotsend) {
     149    owl_editwin_set_dotsend(e);
    135150  }
    136151
     
    742757/* returns if only whitespace remains */
    743758int owl_editwin_is_at_end(owl_editwin *e) {
    744   int i, cur; 
    745   cur=_owl_editwin_get_index_from_xy(e);
    746   if (cur >= e->bufflen) return(1);
    747   for (i=e->bufflen-1; i>cur; i--) {
    748     if (e->buff[i] != '\r'
    749         && e->buff[i] != '\n'
    750         && e->buff[i] != ' ') {
    751       return(0);
    752     }
    753   }
    754   if (cur==i) return(1);
    755   else return(0);
     759  int cur=_owl_editwin_get_index_from_xy(e);
     760  return only_whitespace(e->buff+cur);
    756761}
    757762
     
    768773      return(1);
    769774    }
    770     if (e->buff[i] != '\r'
    771         && e->buff[i] != '\n'
    772         && e->buff[i] != ' ') {
     775    if (!isspace(e->buff[i])) {
    773776      return(0);
    774777    }
Note: See TracChangeset for help on using the changeset viewer.