File: keyb.c

package info (click to toggle)
cabber 0.4.0-test5-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 172 kB
  • ctags: 100
  • sloc: ansic: 1,421; makefile: 82
file content (45 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <string.h>
#include <ncurses.h>
#include "keyb.h"

int
processinput (char *inputline, int key)
{
  switch (key)
    {
    case KEY_UP:
      return KEY_UP;

    case KEY_DOWN:
      return KEY_DOWN;

    case KEY_LEFT:
    case KEY_RIGHT:
      return ESUCCESS;

    case ESC:
      {
	return EEXIT;
      }
    case RETURN:
      {
	return ERETURN;
      }
    case BACKSPACE:
      {
	if (strlen (inputline) != 0)
	  {
	    inputline[strlen (inputline) - 1] = '\0';
	    return EBACK;
	  }
	return -EBACK;
      }
    default:
      {
	if (strlen (inputline) > 254)
	  return EMAXLEN;
	inputline[strlen (inputline)] = key;
      }
    }
  return ESUCCESS;
}