Row and column update on screen resize

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago
parent 083ff9db45
commit 0342289dac
  1. 2
      C/scripts/build.sh
  2. 2
      C/scripts/md5
  3. BIN
      main
  4. 28
      main.c
  5. 2
      utils/main.sh
  6. 2
      utils/md5

@ -2,6 +2,6 @@
#C
printf "Running program...\n\n\n"
if gcc $(find . -type f -name "*.c") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then
./${PROJECT_NAME}
./${PROJECT_NAME} "$@"
fi
printf "\n\n"

@ -1,2 +1,2 @@
build.sh:dbb1880f6b747ec208d6f277c0be61c2 -
build.sh:fcbd8c14fe2a608d11166cf5aa7dba02 -
commit.sh:89783d2e6a165aa9612c79cfbd804a35 -

BIN
main

Binary file not shown.

@ -1,18 +1,12 @@
#include <curses.h>
#include <stdlib.h>
#include <ncurses.h>
#include <time.h>
#include "project/extras.h"
#include "project/utils/utils.h"
struct data{
int val1;
int val2;
int val3;
};
int main(int argc,char**argv) {
int*keyLog=calloc(25,sizeof(int));
struct data*dataVals=calloc(3,sizeof(struct data));
unsigned short currentLogCounter=0;
unsigned int frameCount = 0;
int rows,cols;
@ -28,20 +22,6 @@ int main(int argc,char**argv) {
nodelay(stdscr,TRUE);
noecho();
dataVals[0].val1=14;
dataVals[0].val2=16;
dataVals[0].val3=22;
dataVals[1].val1=39;
dataVals[1].val2=7;
dataVals[1].val3=64;
dataVals[2].val1=42;
dataVals[2].val2=14;
dataVals[2].val3=69;
mvprintw(2,7,"%d %d %d",dataVals[0].val1,dataVals[0].val2,dataVals[0].val3);
mvprintw(3,7,"%d %d %d",dataVals[1].val1,dataVals[1].val2,dataVals[1].val3);
mvprintw(4,7,"%d %d %d",dataVals[2].val1,dataVals[2].val2,dataVals[2].val3);
refresh();
getmaxyx(stdscr,rows,cols);
int ch=ERR;
@ -49,9 +29,12 @@ int main(int argc,char**argv) {
if ((ch=getch())!=ERR) {
keyLog[currentLogCounter]=ch;
currentLogCounter=(currentLogCounter+1)%25;
if (ch==KEY_RESIZE) {
getmaxyx(stdscr,rows,cols);
}
}
if (clock()-lastTime>FRAMETIME) {
mvprintw(5,7,"There are %dx%d squares. (%d)",rows,cols,frameCount++);
mvprintw(5,7,"There are %dx%d squares. (%d)",cols,rows,frameCount++);
for (int i=0;i<25;i++) {
if (keyLog[i]>0) {
mvprintw(6+i,2,"Key %d was pressed.",keyLog[i]);
@ -62,7 +45,6 @@ int main(int argc,char**argv) {
}
}
free(keyLog);
free(dataVals);
endwin();
return 0;
}

@ -25,4 +25,4 @@ if [ -z "$1" ]
exit
fi
./$LANGUAGE/scripts/$1.sh "${*:2}"
./$LANGUAGE/scripts/$1.sh "${@:2}"

@ -1,4 +1,4 @@
define.sh:3ecab0dffe2adfb950f3eb7c7061b750 -
main.sh:d3d1bd0b56d8114eb7479964227f8576 -
main.sh:4e6e9f0650ec790ce2c4364db94f0caa -
search.sh:81d08f5ff48e8a44b5f68387d426da05 -
.updateDirectories:fa5e95db12be22ae8aed7ecbc560e38c -

Loading…
Cancel
Save