scroll in dos
- Posted by DonCole Mar 03, 2013
- 1467 views
Hello everyone,
This is my code, which works, however I have seen a simpler way of doing this.
But I can't find it.
Does anybody know a simpler way?
include graphics.e include get.e --with trace------------------------ -----------------------------------------------------------set up------------------------------------ constant data={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen", "fifteen","sixteen","seventeen","eighteen","nineteen","twenty"} sequence line integer i,pos,dp,start constant scrLen=10 constant dbLen=20 line=repeat(0,dbLen) start=1 for x=1 to dbLen do line[x]=sprintf("%2d %s\n",{x,data[x]}) end for for x=1 to scrLen do--lines puts(1,line[x] ) end for procedure color_rev() text_color(0) bk_color(7) end procedure procedure color_norm() text_color(7) bk_color(0) end procedure procedure color_red() text_color(12) bk_color(8) end procedure procedure color_test() text_color(11) bk_color(6) end procedure position(start,1) color_rev() puts(1,line[start] ) color_norm() --pause() dp=start pos=start ----------------------------------------------------------------- procedure print_move_all_down_one_info() position(20,40) printf(1,"pos=%d dp=%d n",{pos,dp}) end procedure procedure print_info(integer pos,integer dp) position(10,20) puts(1, " \n") position(10,20) printf(1,"pos=%d dp=%d \n",{pos,dp}) end procedure procedure print_dp() position(20,60) printf(1,"dp=%d \n",{dp}) end procedure procedure print_line(integer p,integer dp) print_info(p,dp) position(p,1) puts(1, " \n") position(p,1) puts(1,line[dp] &"\n") end procedure procedure move_all_up_one() color_norm() for x=1 to 9 do position(x,1) puts(1, " ") position(x,1) puts(1,line[dp+x-scrLen] &"\n") end for end procedure procedure move_all_down_one() color_norm() for x=2 to scrLen do print_line(x,dp+x-1) end for end procedure procedure move_up_one() if pos=1 and dp=1 then return end if color_norm() print_line(pos,dp) color_rev() pos-=1 dp-=1 if dp<=scrLen and dp!=pos then pos=1 move_all_down_one() pos=1 end if if pos<1 then pos=1 dp=1 end if if dp<1 then return end if color_rev() print_line(pos,dp) end procedure procedure move_down_one() color_norm() print_line(pos,dp) color_rev() pos+=1 dp+=1 if pos>scrLen and dp<dbLen+1 then pos=scrLen move_all_up_one() color_rev() print_line(pos,dp) elsif pos>scrLen and dp>dbLen then pos=scrLen dp=dbLen end if print_line(pos,dp) end procedure cursor(NO_CURSOR) while 1 do i=wait_key() if i=27 then exit elsif i=328 then move_up_one() elsif i=336 then move_down_one() end if end while
Thanks Don Cole