[how] Scrollable area
-
How to make fast a small area (let's say in the middle of the screen) with a "scrollbar" on the right hand side, using ANSI C only? Lines should scroll when user pushes arrow keys (up & down).
+-----------------------/\+
+ line3 +
+ line4 []+
+ line5 +
+ line6 +
+-----------------------\/+PS. I wrote this post in English, 'cause my German isn't as good as yours. Of course answer in German if you like
-
in ansi nicht schön.
warum?
du brauchst getch. die steht in der conio, und ist nicht standard.
zum anderen brauchst du irgendeine methode zum clear the screen. auch die ist nicht standard.
hmm ohne clear screen zerfetzt es die console, aber so könnte der down als rudimentärer ansatz gehen, der up ist etwas komplexer, geht aber auch
#include<stdio.h> #include<conio.h> //leider NICHT standard int global=0; int main(){ unsigned char chr; int lines[100]; int i, j, temp; do{ for (i=0; i<100; i++) lines[i]=i; chr=getch(); if ((chr==224) || (chr==0)){ chr=getch(); switch(chr){ case 80: { if (global <100-23){ temp=global; for (i=0;i<24; i++){ if(i<10 || i>20) printf("\n"); else printf("line %d\n", lines[temp] ); temp++; } global+=1; }else printf("ende"); break; } case 72: { printf("scroll up"); break; } } } }while(true); }
-
Thx (Viellen Dank) !!!