Mercurial > hg > nnchat
comparison ui.c @ 506:8734a02a86ec
Improve prompt function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 02 Jun 2012 23:33:06 +0300 |
parents | 60e04709ce0f |
children | e644d373afb9 |
comparison
equal
deleted
inserted
replaced
505:12939e665e49 | 506:8734a02a86ec |
---|---|
283 } | 283 } |
284 | 284 |
285 | 285 |
286 char *nnwin_prompt_requester(const char *info, BOOL allowEmpty) | 286 char *nnwin_prompt_requester(const char *info, BOOL allowEmpty) |
287 { | 287 { |
288 char tmpBuf[512], *ptr; | 288 char buf[512], *ptr; |
289 int curSave = curs_set(1); | |
290 | 289 |
291 echo(); | 290 echo(); |
291 wattrset(stdscr, A_NORMAL); | |
292 wbkgdset(stdscr, COLOR_PAIR(0)); | |
292 waddstr(stdscr, info); | 293 waddstr(stdscr, info); |
293 wgetnstr(stdscr, tmpBuf, sizeof(tmpBuf) - 1); | 294 wgetnstr(stdscr, buf, sizeof(buf) - 1); |
294 noecho(); | 295 noecho(); |
295 | 296 |
296 if (curSave != ERR) | 297 str_trim_right(buf); |
297 curs_set(curSave); | 298 ptr = str_trim_left(buf); |
298 | |
299 str_trim_right(tmpBuf); | |
300 ptr = str_trim_left(tmpBuf); | |
301 | 299 |
302 if (allowEmpty || ptr[0]) | 300 if (allowEmpty || ptr[0]) |
303 return th_strdup(ptr); | 301 return th_strdup(ptr); |
304 else | 302 else |
305 return NULL; | 303 return NULL; |