/* Copyright 1990 Business Management Systems, Inc. Author: Stuart D. Gathman */ #include #include #include #define MARK '>' int expandtabs(const char *in,char *out,int len) { int pos = 0,i; while (*in && pos < len) { if (*in == '\t') do out[pos++] = ' '; while (pos % 8 && pos < len); else out[pos++] = *in; ++in; } for (i = pos; i < len; ++i) out[i] = ' '; return pos; } void PromptLine::draw(const Rect &r) { for (int i = r.r1; list[i] && i <= r.r2; ++i) { char buf[132]; expandtabs(list[i],buf + 1,sizeof buf - 1); buf[0] = ' '; if (i == row) { if (cur) buf[0] = cur; write(i,0,sizeof buf,buf,A_REVERSE); } else write(i,0,sizeof buf,buf,A_NORMAL); } } TextWindow::TextWindow(const char **txt,const char *title): PromptLine(txt), FramedWin(title,"") { } PromptLine::PromptLine(const char **txt) { list = txt; cur = 0; row = 0; curtype(0); } void PromptLine::setpos(Point p) { int maxw = 0; int i; for (i = 0; list[i]; ++i) { char buf[132]; int w = expandtabs(list[i],buf,sizeof buf); if (w > maxw) maxw = w; } setphys(Rect(p,maxw + 1,i)); }