C clone of hackertyper.net

Registration and login script

How to indicate a cut out for a product window

Biological Blimps: Propulsion

How to explain what's wrong with this application of the chain rule?

Is there any references on the tensor product of presentable (1-)categories?

Did Swami Prabhupada reject Advaita?

Is aluminum electrical wire used on aircraft?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

Store Credit Card Information in Password Manager?

Why did the EU agree to delay the Brexit deadline?

The IT department bottlenecks progress. How should I handle this?

Why is it that I can sometimes guess the next note?

Does a 'pending' US visa application constitute a denial?

New brakes for 90s road bike

Why should universal income be universal?

What are the purposes of autoencoders?

Why electric field inside a cavity of a non-conducting sphere not zero?

How can "mimic phobia" be cured or prevented?

Loading commands from file

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

Can Legal Documents Be Siged In Non-Standard Pen Colors?

On a tidally locked planet, would time be quantized?

Multiplicative persistence

Not using 's' for he/she/it



C clone of hackertyper.net














0












$begingroup$


This is a simple c clone of the website hackertyper.net. The code can be found at github.com/Hurricane996/hackertyper. Here is a local copy



Makefile



PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
DATAROOTDIR=$(PREFIX)/share
DATADIR=$(DATAROOTDIR)
MAN1DIR=$(DATAROOTDIR)/man/man1

CFLAGS=-Wall -pedantic -std=c99
LDFLAGS=-lncurses

all: hackertyper

.PHONY: all clean install

hackertyper: hackertyper.o
cc -o $@ $^ $(LDFLAGS)
hackertyper.o: src/hackertyper.c
cc -c $(CFLAGS) -o $@ $^
src/hackertyper.c: src/hackertyper.h
src/hackertyper.h:src/hackertyper.h.in
sed "s@%datadir%@$(DATADIR)@g" src/hackertyper.h.in > src/hackertyper.h

clean:
rm -f hackertyper,.o src/hackertyper.h

install:
install -D -m644 data/hackertyper.txt $(DATADIR)/hackertyper.txt
install -D -m644 man/hackertyper.1 $(MAN1DIR)/hackertyper.1
install -D -m755 hackertyper $(BINDIR)/hackertyper


src/hackertyper.c



#include "hackertyper.h"

char* filename;
FILE* file;


char chars_per_nl = 1;

int main(int argc, char* argv[])
parse_args(argc, argv);

if(open_file(filename) == -1)

return -1;


init();

int clear_msg_flag = 0;

nc_color_green();

int running = 1;

while(running)
// buffer here so that buffering happens before clear_msg
int input_ch = getch();
// message was drawn last time and we need to clear it
if(clear_msg_flag)
clear_msg_flag = 0;
clear_msg();


switch(input_ch)
//C-c
case 3:
running = 0;
break;
//C-d
case 4:
clear();
nc_color_red();
draw_msg("ACCESS DENIED");
clear_msg_flag = 1;
break;
// C-g
case 7:
clear();
nc_color_green();
draw_msg("ACCESS GRANTED");

clear_msg_flag = 1;

break;
case KEY_BACKSPACE:
backspace();
break;
default:
for(int i = 0; i < 5; i++)
int output_ch = fgetc(file);

if(output_ch == EOF)
rewind(file);

output_ch = fgetc(file);


if(output_ch != 'r')
addch(output_ch);


refresh();
break;



end();


void parse_args(int argc, char* argv[])
if(argc > 1)
for(int i = 0; i < argc; i++)
if(strcmp(argv[i], "-h") == 0



int open_file(char* filename)
filename = filename ? filename : default_filename;
file = fopen(filename, "r");

return file == NULL ? -1 : 0;


void init()
initscr();
raw();
noecho();
scrollok(stdscr, true);
keypad(stdscr, true);

// check line endings
// TODO: expand this to work with endings besides n and rn

char ch;

while(ch !='n' && ch !='r')
ch = fgetc(file);


if (ch == 'r')
chars_per_nl = 2;


rewind(file);

if(has_colors())
start_color();
init_pair(1, COLOR_GREEN, COLOR_BLACK);
init_pair(2, COLOR_RED, COLOR_BLACK);



void nc_color_green()
if(has_colors())
attroff(COLOR_PAIR(2));
attron(COLOR_PAIR(1));



void nc_color_red()
if(has_colors())
attroff(COLOR_PAIR(1));
attron(COLOR_PAIR(2));



void nc_color_default()
if(has_colors())
attroff(COLOR_PAIR(1));
attroff(COLOR_PAIR(2));



void backspace()
fseek(file,-1 ,SEEK_CUR);

int x,y;
getyx(stdscr,y,x);

if(x == 0)

if( y == 0 )

return;


x = getmaxx(stdscr);
// set x to x minus 1
move(--y,--x);

char ch = ' ';

while(ch == ' ' && x != 0)
move(y,--x);
ch=inch();


fseek(file, -chars_per_nl, SEEK_CUR);
else
move(y,x-1);




delch();


// TODO: fix this shit
void draw_msg(char* msg)
int len = strlen(msg);
unsigned char hash = '#';
unsigned char space = ' ';

int w;
int h;

getmaxyx(stdscr, h, w);

move(h/2 - 2, w/2 - len/2 - 3);

for(int i = 0; i < len + 6; i ++)
addch(hash);

move(h/2 - 1, w/2 - len/2 - 3);

addch(hash);

for(int i = 0; i < len + 4; i ++)
addch(space);

addch(hash);

move(h/2, w/2 - len/2 - 3);
printw("# %s #", msg);

move(h/2 + 1, w/2 - len/2 - 3);
addch(hash);

for(int i = 0; i < len + 4; i ++)
addch(space);

addch(hash);

move(h/2 + 2, w/2 - len/2 - 3);

for(int i = 0; i < len + 6; i ++)
addch(hash);


void clear_msg()
nc_color_green();
clear();
move(0, 0);
// seek file to next line
int ch = 0;

while(ch != 'n')
ch = fgetc(file);



void end()
endwin();
fclose(file);



src/hackertyper.h.in



#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>
#include <string.h>

#define default_filename "%datadir%/hackertyper.txt"

#define HELP_TEXT "
Usage: hackertyper [-f file] [-h] [-v]n
Print text from file to stdout on pressing keys, similar to behavior of website https://www.hackertyper.org/n
n
Options:n
-f FILE, --filename FILE Print text from FILE rather than from default filen
-h, --help Print this help stringn
-v, --version Print version informationn
"

#define VERSION_TEXT "
hackertyper 2.1n
Copyright (C) 2019 Lani Willrichn
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>n
This is free software: you are free to change and redistribute it.n
There is NO WARRANTY, to the extent permitted by law.n
Written by Lani Willrichn
"

void parse_args(int argc,char* argv[]);

int open_file(char* filename);

void init();
void nc_color_red();
void nc_color_green();
void nc_color_default();

void backspace();

void draw_msg(char* msg);
void clear_msg();

void end();


Some irrelevant files have not been listed including an auto-generated manapge and the data files









share







New contributor




Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    0












    $begingroup$


    This is a simple c clone of the website hackertyper.net. The code can be found at github.com/Hurricane996/hackertyper. Here is a local copy



    Makefile



    PREFIX=/usr/local
    BINDIR=$(PREFIX)/bin
    DATAROOTDIR=$(PREFIX)/share
    DATADIR=$(DATAROOTDIR)
    MAN1DIR=$(DATAROOTDIR)/man/man1

    CFLAGS=-Wall -pedantic -std=c99
    LDFLAGS=-lncurses

    all: hackertyper

    .PHONY: all clean install

    hackertyper: hackertyper.o
    cc -o $@ $^ $(LDFLAGS)
    hackertyper.o: src/hackertyper.c
    cc -c $(CFLAGS) -o $@ $^
    src/hackertyper.c: src/hackertyper.h
    src/hackertyper.h:src/hackertyper.h.in
    sed "s@%datadir%@$(DATADIR)@g" src/hackertyper.h.in > src/hackertyper.h

    clean:
    rm -f hackertyper,.o src/hackertyper.h

    install:
    install -D -m644 data/hackertyper.txt $(DATADIR)/hackertyper.txt
    install -D -m644 man/hackertyper.1 $(MAN1DIR)/hackertyper.1
    install -D -m755 hackertyper $(BINDIR)/hackertyper


    src/hackertyper.c



    #include "hackertyper.h"

    char* filename;
    FILE* file;


    char chars_per_nl = 1;

    int main(int argc, char* argv[])
    parse_args(argc, argv);

    if(open_file(filename) == -1)

    return -1;


    init();

    int clear_msg_flag = 0;

    nc_color_green();

    int running = 1;

    while(running)
    // buffer here so that buffering happens before clear_msg
    int input_ch = getch();
    // message was drawn last time and we need to clear it
    if(clear_msg_flag)
    clear_msg_flag = 0;
    clear_msg();


    switch(input_ch)
    //C-c
    case 3:
    running = 0;
    break;
    //C-d
    case 4:
    clear();
    nc_color_red();
    draw_msg("ACCESS DENIED");
    clear_msg_flag = 1;
    break;
    // C-g
    case 7:
    clear();
    nc_color_green();
    draw_msg("ACCESS GRANTED");

    clear_msg_flag = 1;

    break;
    case KEY_BACKSPACE:
    backspace();
    break;
    default:
    for(int i = 0; i < 5; i++)
    int output_ch = fgetc(file);

    if(output_ch == EOF)
    rewind(file);

    output_ch = fgetc(file);


    if(output_ch != 'r')
    addch(output_ch);


    refresh();
    break;



    end();


    void parse_args(int argc, char* argv[])
    if(argc > 1)
    for(int i = 0; i < argc; i++)
    if(strcmp(argv[i], "-h") == 0



    int open_file(char* filename)
    filename = filename ? filename : default_filename;
    file = fopen(filename, "r");

    return file == NULL ? -1 : 0;


    void init()
    initscr();
    raw();
    noecho();
    scrollok(stdscr, true);
    keypad(stdscr, true);

    // check line endings
    // TODO: expand this to work with endings besides n and rn

    char ch;

    while(ch !='n' && ch !='r')
    ch = fgetc(file);


    if (ch == 'r')
    chars_per_nl = 2;


    rewind(file);

    if(has_colors())
    start_color();
    init_pair(1, COLOR_GREEN, COLOR_BLACK);
    init_pair(2, COLOR_RED, COLOR_BLACK);



    void nc_color_green()
    if(has_colors())
    attroff(COLOR_PAIR(2));
    attron(COLOR_PAIR(1));



    void nc_color_red()
    if(has_colors())
    attroff(COLOR_PAIR(1));
    attron(COLOR_PAIR(2));



    void nc_color_default()
    if(has_colors())
    attroff(COLOR_PAIR(1));
    attroff(COLOR_PAIR(2));



    void backspace()
    fseek(file,-1 ,SEEK_CUR);

    int x,y;
    getyx(stdscr,y,x);

    if(x == 0)

    if( y == 0 )

    return;


    x = getmaxx(stdscr);
    // set x to x minus 1
    move(--y,--x);

    char ch = ' ';

    while(ch == ' ' && x != 0)
    move(y,--x);
    ch=inch();


    fseek(file, -chars_per_nl, SEEK_CUR);
    else
    move(y,x-1);




    delch();


    // TODO: fix this shit
    void draw_msg(char* msg)
    int len = strlen(msg);
    unsigned char hash = '#';
    unsigned char space = ' ';

    int w;
    int h;

    getmaxyx(stdscr, h, w);

    move(h/2 - 2, w/2 - len/2 - 3);

    for(int i = 0; i < len + 6; i ++)
    addch(hash);

    move(h/2 - 1, w/2 - len/2 - 3);

    addch(hash);

    for(int i = 0; i < len + 4; i ++)
    addch(space);

    addch(hash);

    move(h/2, w/2 - len/2 - 3);
    printw("# %s #", msg);

    move(h/2 + 1, w/2 - len/2 - 3);
    addch(hash);

    for(int i = 0; i < len + 4; i ++)
    addch(space);

    addch(hash);

    move(h/2 + 2, w/2 - len/2 - 3);

    for(int i = 0; i < len + 6; i ++)
    addch(hash);


    void clear_msg()
    nc_color_green();
    clear();
    move(0, 0);
    // seek file to next line
    int ch = 0;

    while(ch != 'n')
    ch = fgetc(file);



    void end()
    endwin();
    fclose(file);



    src/hackertyper.h.in



    #include <stdio.h>
    #include <stdlib.h>
    #include <ncurses.h>
    #include <string.h>

    #define default_filename "%datadir%/hackertyper.txt"

    #define HELP_TEXT "
    Usage: hackertyper [-f file] [-h] [-v]n
    Print text from file to stdout on pressing keys, similar to behavior of website https://www.hackertyper.org/n
    n
    Options:n
    -f FILE, --filename FILE Print text from FILE rather than from default filen
    -h, --help Print this help stringn
    -v, --version Print version informationn
    "

    #define VERSION_TEXT "
    hackertyper 2.1n
    Copyright (C) 2019 Lani Willrichn
    License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>n
    This is free software: you are free to change and redistribute it.n
    There is NO WARRANTY, to the extent permitted by law.n
    Written by Lani Willrichn
    "

    void parse_args(int argc,char* argv[]);

    int open_file(char* filename);

    void init();
    void nc_color_red();
    void nc_color_green();
    void nc_color_default();

    void backspace();

    void draw_msg(char* msg);
    void clear_msg();

    void end();


    Some irrelevant files have not been listed including an auto-generated manapge and the data files









    share







    New contributor




    Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      0












      0








      0





      $begingroup$


      This is a simple c clone of the website hackertyper.net. The code can be found at github.com/Hurricane996/hackertyper. Here is a local copy



      Makefile



      PREFIX=/usr/local
      BINDIR=$(PREFIX)/bin
      DATAROOTDIR=$(PREFIX)/share
      DATADIR=$(DATAROOTDIR)
      MAN1DIR=$(DATAROOTDIR)/man/man1

      CFLAGS=-Wall -pedantic -std=c99
      LDFLAGS=-lncurses

      all: hackertyper

      .PHONY: all clean install

      hackertyper: hackertyper.o
      cc -o $@ $^ $(LDFLAGS)
      hackertyper.o: src/hackertyper.c
      cc -c $(CFLAGS) -o $@ $^
      src/hackertyper.c: src/hackertyper.h
      src/hackertyper.h:src/hackertyper.h.in
      sed "s@%datadir%@$(DATADIR)@g" src/hackertyper.h.in > src/hackertyper.h

      clean:
      rm -f hackertyper,.o src/hackertyper.h

      install:
      install -D -m644 data/hackertyper.txt $(DATADIR)/hackertyper.txt
      install -D -m644 man/hackertyper.1 $(MAN1DIR)/hackertyper.1
      install -D -m755 hackertyper $(BINDIR)/hackertyper


      src/hackertyper.c



      #include "hackertyper.h"

      char* filename;
      FILE* file;


      char chars_per_nl = 1;

      int main(int argc, char* argv[])
      parse_args(argc, argv);

      if(open_file(filename) == -1)

      return -1;


      init();

      int clear_msg_flag = 0;

      nc_color_green();

      int running = 1;

      while(running)
      // buffer here so that buffering happens before clear_msg
      int input_ch = getch();
      // message was drawn last time and we need to clear it
      if(clear_msg_flag)
      clear_msg_flag = 0;
      clear_msg();


      switch(input_ch)
      //C-c
      case 3:
      running = 0;
      break;
      //C-d
      case 4:
      clear();
      nc_color_red();
      draw_msg("ACCESS DENIED");
      clear_msg_flag = 1;
      break;
      // C-g
      case 7:
      clear();
      nc_color_green();
      draw_msg("ACCESS GRANTED");

      clear_msg_flag = 1;

      break;
      case KEY_BACKSPACE:
      backspace();
      break;
      default:
      for(int i = 0; i < 5; i++)
      int output_ch = fgetc(file);

      if(output_ch == EOF)
      rewind(file);

      output_ch = fgetc(file);


      if(output_ch != 'r')
      addch(output_ch);


      refresh();
      break;



      end();


      void parse_args(int argc, char* argv[])
      if(argc > 1)
      for(int i = 0; i < argc; i++)
      if(strcmp(argv[i], "-h") == 0



      int open_file(char* filename)
      filename = filename ? filename : default_filename;
      file = fopen(filename, "r");

      return file == NULL ? -1 : 0;


      void init()
      initscr();
      raw();
      noecho();
      scrollok(stdscr, true);
      keypad(stdscr, true);

      // check line endings
      // TODO: expand this to work with endings besides n and rn

      char ch;

      while(ch !='n' && ch !='r')
      ch = fgetc(file);


      if (ch == 'r')
      chars_per_nl = 2;


      rewind(file);

      if(has_colors())
      start_color();
      init_pair(1, COLOR_GREEN, COLOR_BLACK);
      init_pair(2, COLOR_RED, COLOR_BLACK);



      void nc_color_green()
      if(has_colors())
      attroff(COLOR_PAIR(2));
      attron(COLOR_PAIR(1));



      void nc_color_red()
      if(has_colors())
      attroff(COLOR_PAIR(1));
      attron(COLOR_PAIR(2));



      void nc_color_default()
      if(has_colors())
      attroff(COLOR_PAIR(1));
      attroff(COLOR_PAIR(2));



      void backspace()
      fseek(file,-1 ,SEEK_CUR);

      int x,y;
      getyx(stdscr,y,x);

      if(x == 0)

      if( y == 0 )

      return;


      x = getmaxx(stdscr);
      // set x to x minus 1
      move(--y,--x);

      char ch = ' ';

      while(ch == ' ' && x != 0)
      move(y,--x);
      ch=inch();


      fseek(file, -chars_per_nl, SEEK_CUR);
      else
      move(y,x-1);




      delch();


      // TODO: fix this shit
      void draw_msg(char* msg)
      int len = strlen(msg);
      unsigned char hash = '#';
      unsigned char space = ' ';

      int w;
      int h;

      getmaxyx(stdscr, h, w);

      move(h/2 - 2, w/2 - len/2 - 3);

      for(int i = 0; i < len + 6; i ++)
      addch(hash);

      move(h/2 - 1, w/2 - len/2 - 3);

      addch(hash);

      for(int i = 0; i < len + 4; i ++)
      addch(space);

      addch(hash);

      move(h/2, w/2 - len/2 - 3);
      printw("# %s #", msg);

      move(h/2 + 1, w/2 - len/2 - 3);
      addch(hash);

      for(int i = 0; i < len + 4; i ++)
      addch(space);

      addch(hash);

      move(h/2 + 2, w/2 - len/2 - 3);

      for(int i = 0; i < len + 6; i ++)
      addch(hash);


      void clear_msg()
      nc_color_green();
      clear();
      move(0, 0);
      // seek file to next line
      int ch = 0;

      while(ch != 'n')
      ch = fgetc(file);



      void end()
      endwin();
      fclose(file);



      src/hackertyper.h.in



      #include <stdio.h>
      #include <stdlib.h>
      #include <ncurses.h>
      #include <string.h>

      #define default_filename "%datadir%/hackertyper.txt"

      #define HELP_TEXT "
      Usage: hackertyper [-f file] [-h] [-v]n
      Print text from file to stdout on pressing keys, similar to behavior of website https://www.hackertyper.org/n
      n
      Options:n
      -f FILE, --filename FILE Print text from FILE rather than from default filen
      -h, --help Print this help stringn
      -v, --version Print version informationn
      "

      #define VERSION_TEXT "
      hackertyper 2.1n
      Copyright (C) 2019 Lani Willrichn
      License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>n
      This is free software: you are free to change and redistribute it.n
      There is NO WARRANTY, to the extent permitted by law.n
      Written by Lani Willrichn
      "

      void parse_args(int argc,char* argv[]);

      int open_file(char* filename);

      void init();
      void nc_color_red();
      void nc_color_green();
      void nc_color_default();

      void backspace();

      void draw_msg(char* msg);
      void clear_msg();

      void end();


      Some irrelevant files have not been listed including an auto-generated manapge and the data files









      share







      New contributor




      Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      This is a simple c clone of the website hackertyper.net. The code can be found at github.com/Hurricane996/hackertyper. Here is a local copy



      Makefile



      PREFIX=/usr/local
      BINDIR=$(PREFIX)/bin
      DATAROOTDIR=$(PREFIX)/share
      DATADIR=$(DATAROOTDIR)
      MAN1DIR=$(DATAROOTDIR)/man/man1

      CFLAGS=-Wall -pedantic -std=c99
      LDFLAGS=-lncurses

      all: hackertyper

      .PHONY: all clean install

      hackertyper: hackertyper.o
      cc -o $@ $^ $(LDFLAGS)
      hackertyper.o: src/hackertyper.c
      cc -c $(CFLAGS) -o $@ $^
      src/hackertyper.c: src/hackertyper.h
      src/hackertyper.h:src/hackertyper.h.in
      sed "s@%datadir%@$(DATADIR)@g" src/hackertyper.h.in > src/hackertyper.h

      clean:
      rm -f hackertyper,.o src/hackertyper.h

      install:
      install -D -m644 data/hackertyper.txt $(DATADIR)/hackertyper.txt
      install -D -m644 man/hackertyper.1 $(MAN1DIR)/hackertyper.1
      install -D -m755 hackertyper $(BINDIR)/hackertyper


      src/hackertyper.c



      #include "hackertyper.h"

      char* filename;
      FILE* file;


      char chars_per_nl = 1;

      int main(int argc, char* argv[])
      parse_args(argc, argv);

      if(open_file(filename) == -1)

      return -1;


      init();

      int clear_msg_flag = 0;

      nc_color_green();

      int running = 1;

      while(running)
      // buffer here so that buffering happens before clear_msg
      int input_ch = getch();
      // message was drawn last time and we need to clear it
      if(clear_msg_flag)
      clear_msg_flag = 0;
      clear_msg();


      switch(input_ch)
      //C-c
      case 3:
      running = 0;
      break;
      //C-d
      case 4:
      clear();
      nc_color_red();
      draw_msg("ACCESS DENIED");
      clear_msg_flag = 1;
      break;
      // C-g
      case 7:
      clear();
      nc_color_green();
      draw_msg("ACCESS GRANTED");

      clear_msg_flag = 1;

      break;
      case KEY_BACKSPACE:
      backspace();
      break;
      default:
      for(int i = 0; i < 5; i++)
      int output_ch = fgetc(file);

      if(output_ch == EOF)
      rewind(file);

      output_ch = fgetc(file);


      if(output_ch != 'r')
      addch(output_ch);


      refresh();
      break;



      end();


      void parse_args(int argc, char* argv[])
      if(argc > 1)
      for(int i = 0; i < argc; i++)
      if(strcmp(argv[i], "-h") == 0



      int open_file(char* filename)
      filename = filename ? filename : default_filename;
      file = fopen(filename, "r");

      return file == NULL ? -1 : 0;


      void init()
      initscr();
      raw();
      noecho();
      scrollok(stdscr, true);
      keypad(stdscr, true);

      // check line endings
      // TODO: expand this to work with endings besides n and rn

      char ch;

      while(ch !='n' && ch !='r')
      ch = fgetc(file);


      if (ch == 'r')
      chars_per_nl = 2;


      rewind(file);

      if(has_colors())
      start_color();
      init_pair(1, COLOR_GREEN, COLOR_BLACK);
      init_pair(2, COLOR_RED, COLOR_BLACK);



      void nc_color_green()
      if(has_colors())
      attroff(COLOR_PAIR(2));
      attron(COLOR_PAIR(1));



      void nc_color_red()
      if(has_colors())
      attroff(COLOR_PAIR(1));
      attron(COLOR_PAIR(2));



      void nc_color_default()
      if(has_colors())
      attroff(COLOR_PAIR(1));
      attroff(COLOR_PAIR(2));



      void backspace()
      fseek(file,-1 ,SEEK_CUR);

      int x,y;
      getyx(stdscr,y,x);

      if(x == 0)

      if( y == 0 )

      return;


      x = getmaxx(stdscr);
      // set x to x minus 1
      move(--y,--x);

      char ch = ' ';

      while(ch == ' ' && x != 0)
      move(y,--x);
      ch=inch();


      fseek(file, -chars_per_nl, SEEK_CUR);
      else
      move(y,x-1);




      delch();


      // TODO: fix this shit
      void draw_msg(char* msg)
      int len = strlen(msg);
      unsigned char hash = '#';
      unsigned char space = ' ';

      int w;
      int h;

      getmaxyx(stdscr, h, w);

      move(h/2 - 2, w/2 - len/2 - 3);

      for(int i = 0; i < len + 6; i ++)
      addch(hash);

      move(h/2 - 1, w/2 - len/2 - 3);

      addch(hash);

      for(int i = 0; i < len + 4; i ++)
      addch(space);

      addch(hash);

      move(h/2, w/2 - len/2 - 3);
      printw("# %s #", msg);

      move(h/2 + 1, w/2 - len/2 - 3);
      addch(hash);

      for(int i = 0; i < len + 4; i ++)
      addch(space);

      addch(hash);

      move(h/2 + 2, w/2 - len/2 - 3);

      for(int i = 0; i < len + 6; i ++)
      addch(hash);


      void clear_msg()
      nc_color_green();
      clear();
      move(0, 0);
      // seek file to next line
      int ch = 0;

      while(ch != 'n')
      ch = fgetc(file);



      void end()
      endwin();
      fclose(file);



      src/hackertyper.h.in



      #include <stdio.h>
      #include <stdlib.h>
      #include <ncurses.h>
      #include <string.h>

      #define default_filename "%datadir%/hackertyper.txt"

      #define HELP_TEXT "
      Usage: hackertyper [-f file] [-h] [-v]n
      Print text from file to stdout on pressing keys, similar to behavior of website https://www.hackertyper.org/n
      n
      Options:n
      -f FILE, --filename FILE Print text from FILE rather than from default filen
      -h, --help Print this help stringn
      -v, --version Print version informationn
      "

      #define VERSION_TEXT "
      hackertyper 2.1n
      Copyright (C) 2019 Lani Willrichn
      License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>n
      This is free software: you are free to change and redistribute it.n
      There is NO WARRANTY, to the extent permitted by law.n
      Written by Lani Willrichn
      "

      void parse_args(int argc,char* argv[]);

      int open_file(char* filename);

      void init();
      void nc_color_red();
      void nc_color_green();
      void nc_color_default();

      void backspace();

      void draw_msg(char* msg);
      void clear_msg();

      void end();


      Some irrelevant files have not been listed including an auto-generated manapge and the data files







      c





      share







      New contributor




      Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 mins ago









      Tornado547Tornado547

      1011




      1011




      New contributor




      Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Tornado547 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Tornado547 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216082%2fc-clone-of-hackertyper-net%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Tornado547 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Tornado547 is a new contributor. Be nice, and check out our Code of Conduct.












          Tornado547 is a new contributor. Be nice, and check out our Code of Conduct.











          Tornado547 is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216082%2fc-clone-of-hackertyper-net%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          格濟夫卡 參考資料 导航菜单51°3′40″N 34°2′21″E / 51.06111°N 34.03917°E / 51.06111; 34.03917ГезівкаПогода в селі 编辑或修订