V_exit.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * \file V_exit.c
  3. *
  4. * \brief Interactive exit functions.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * \author GRASS GIS Development Team
  21. *
  22. * \date 1999-2006
  23. */
  24. #include <grass/config.h>
  25. #include <stdio.h>
  26. #include <grass/vask.h>
  27. /**
  28. * \fn int V_exit ()
  29. *
  30. * \brief Erases the current screen and flushes the current curses setup.
  31. *
  32. * \return always returns 0
  33. */
  34. void V_exit(void)
  35. {
  36. #ifdef HAVE_KEYPAD
  37. keypad(stdscr, 0);
  38. #endif
  39. clear();
  40. refresh();
  41. /* added for Mips' braindead implementation of curses
  42. * and the ordering is important
  43. */
  44. echo();
  45. nl();
  46. noraw();
  47. endwin();
  48. fflush(stdout);
  49. fflush(stderr);
  50. fflush(stdin);
  51. /* Added 17 Sep 1990 dpg. is a hack we have been using on Sys V
  52. * machines it is not the correct way, but it seems to do the job.
  53. * Fixes the problem with prompts not being displayed after
  54. * exitting curses. */
  55. #ifdef SYSV
  56. setvbuf(stderr, NULL, _IONBF, 0);
  57. setvbuf(stdout, NULL, _IONBF, 0);
  58. #endif
  59. }