Actually fix 2001/ctk

It became obvious when I actually looked at the code (though I suspected
from output that it was using ANSI) that it was just no longer valid
ANSI escape sequences. Yusuke Endoh made a patch which I used (I have
used ANSI before but it's been a long while). Yusuke guessed it was a
linux thing (reasonable guess) but this also works for macOS. Thank you
Yusuke for your assistance!
This commit is contained in:
Cody Boone Ferguson committed 2023-03-19 11:47:04 -07:00
1 parent 228f293b79
commit 509f72233c
2 files changed
+12 -5

No files matched your search

+11 -4
View File
@@ -17,16 +17,23 @@ make
./ctk
```
[Yusuke Endoh](/winners.html#Yusuke_Endoh) provided a patch to fix the ANSI
escape codes. It became apparent to [Cody Boone
Ferguson](/winners.html#Cody_Boone_Ferguson) (when he was looking at the source
code of this entry) that it was no longer valid ANSI escape sequences. He has
used them before but that was a long time ago and with Yusuke's patch it works.
Cody notes that this fix will not just for linux but macOS too. Thank you Yusuke
for your assistance!
### Try:
```sh
echo "Do or do not. There is no try."
```
NOTE: this does not show well on the default terminal macOS. It's untested
whether another terminal emulator will work. Make sure to hit 'q' to exit or
else your terminal will be messed up (to restore it you can try `stty sane` or
`reset`).
Make sure to hit 'q' to exit or else your terminal will be messed up (to restore
it you can try `stty sane` or `reset`).
## Judges' comments:
+1 -1
View File
@@ -10,7 +10,7 @@ char x[]="((((((((((((((((((((((",w[]=
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";char r[]={92,124,47},l[]={2,3,1
,0};char*T[]={" |"," |","%\\|/%"," %%%",""};char d=1,p=40,o=40,k=0,*a,y,z,g=
-1,G,X,**P=&T[4],f=0;unsigned int s=0;void u(int i){int n;printf(
"\233;%uH\233L%c\233;%uH%c\233;%uH%s\23322;%uH@\23323;%uH \n",*x-*w,r[d],*x+*w
"\x1b[H\x1b[L\x1b[;%uH%c\x1b[;%uH%c\x1b[;%uH%s\x1b[22;%uH@\x1b[23;%uH \n",*x-*w,r[d],*x+*w
,r[d],X,*P,p+=k,o);if(abs(p-x[21])>=w[21])exit(0);if(g!=G){struct itimerval t=
{0,0,0,0};g+=((g<G)<<1)-1;t.it_interval.tv_usec=t.it_value.tv_usec=72000/((g>>
3)+1);setitimer(0,&t,0);f&&printf("\e[10;%u]",g+24);}f&&putchar(7);s+=(9-w[21]