aboutsummaryrefslogtreecommitdiff
path: root/util.c
blob: 5e22489b4b74337c1c2f14a0e2bb7991f1e3c9f8 (plain)
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
46
47
48
49
#include "strings.h"
#include "util.h"
#include <ctype.h>
#include <curses.h>
#include <string.h>
#include <unistd.h>


void allLower(char* str)
{
  for(int i=0;str[i];++i)
    {
      str[i]=tolower(str[i]);
    }
}
void print_string(const char* str) /* print string, slowly */
{
  int window_height;
  int junk;
  getmaxyx(stdscr, window_height, junk);
  int i=0;
  while(str[i])
    {
      addch(str[i]);
      int cursx, cursy;
      getyx(stdscr, cursy, cursx);
      if(cursy==window_height)
	{
	  scroll(stdscr);
	}
      usleep(SLEEP_TIME);
      refresh();
      ++i;
    }
}
void remove_punct(char* buf)
{
  for(int i=0;buf[i];++i)
    {
      for(int j=0;j<sizeof(punctuation_marks)/sizeof(char);++j)
        {
          if(buf[i]==punctuation_marks[j])
            {
              memmove(&buf[i], &buf[i+1], strlen(buf)-i);
            }
        }
    }
}