home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / git-4.3 / git-4 / git-4.3.7 / src / window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-08  |  2.0 KB  |  105 lines

  1. /* window.c -- a *very* simple window management. */
  2.  
  3. /* Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* Written by Tudor Hulubei and Andrei Pitis.  */
  20.  
  21.  
  22. #ifdef HAVE_CONFIG_H
  23. #include <config.h>
  24. #endif
  25.  
  26. #include <stdio.h>
  27.  
  28. #ifdef HAVE_STDLIB_H
  29. #include <stdlib.h>
  30. #else /* !HAVE_STDLIB_H */
  31. #include "ansi_stdlib.h"
  32. #endif /* !HAVE_STDLIB_H */
  33.  
  34. #include "window.h"
  35. #include "xmalloc.h"
  36. #include "tty.h"
  37.  
  38.  
  39. window_t *
  40. window_init(x, y, lines, columns)
  41.     size_t x, y, lines, columns;
  42. {
  43.     window_t *this  = (window_t *)xmalloc(sizeof(window_t));
  44.  
  45.     window_resize(this, x, y, lines, columns);
  46.     this->cursorx = this->cursory = 0; 
  47.     return this;   
  48. }
  49.  
  50.  
  51. void
  52. window_end(win)
  53.     window_t *win;
  54. {
  55.     if (win)
  56.         xfree(win);
  57. }
  58.  
  59.  
  60. void
  61. window_resize(this, x, y, lines, columns)
  62.     window_t *this;
  63.     size_t x, y, lines, columns;
  64. {
  65.     this->x       = x;
  66.     this->y       = y;
  67.     this->lines   = lines;
  68.     this->columns = columns;
  69. }
  70.  
  71.  
  72. size_t
  73. window_write(str, length)
  74.     char *str;
  75.     size_t length;
  76. {
  77.     return tty_write(str, length);
  78. }
  79.  
  80.  
  81. size_t
  82. window_putch(c)
  83.     char c;
  84. {
  85.     return tty_put_char(c);
  86. }
  87.  
  88.  
  89. void
  90. window_cursormove_notify(this, y, x)
  91.     window_t *this;
  92.     size_t y, x;
  93. {
  94.     tty_cursormove_notify(y + this->y, x + this->x);
  95. }
  96.  
  97.  
  98. void
  99. window_cursormove(this, y, x)
  100.     window_t *this;
  101.     size_t y, x;
  102. {
  103.     tty_cursormove(y + this->y, x + this->x);
  104. }
  105.