UNIXv1ã«ãããå¶å¾¡æåãç¨ããclearã³ãã³ãã®ä½ãæ¹
ã¯ããã«
æ¬è¨äºã¯ãæ¥æ¬é°ãã£åä¼ Advent Calendar 2022ãã«ããã12æ¥ç®ã®è¨äºã«ãªãã¾ãã
ç®æ¬¡
- ã¯ããã«
- ç®æ¬¡
- åä½ç¢ºèªã«é¢ãã¦
- UNIXv1ã¨ã¯
- å¶å¾¡æåã¨ã¯ï¼
- clearã³ãã³ãã¨ã¯ï¼
- å¦çã®æµã
- last1120cãç¨ããå®è£
- 使ã£ã¦ã¿ã
- ã¾ã¨ã
- åèæç®
åä½ç¢ºèªã«é¢ãã¦
ä»åã®æ¹æ³ã¯ManjaroLinuxã«ãããkonsoleã«ã¦åä½ç¢ºèªãè¡ãã¾ãããã¾ããå¶å¾¡æåã«ä¾åãã¦ãããããå ¨ã¦ã®ç«¯æ«ã§åä½ããã¨ã¯éãã¾ããã
UNIXv1ã¨ã¯
UNIXv1ã¨ã¯1971å¹´ã«å ¬éãããUNIXã®1st Editionã¨ãªãã¾ããã¾ããç¹å¾´ã¨ãã¦ãã«ãã¿ã¹ãã³ã°ããã«ãã¦ã¼ã¶ã¼ãé層åãã¡ã¤ã«ã·ã¹ãã æã£ã¦ãããç¾ä»£ã®OSã«ã¤ãªããè¦ç´ ãæã£ã¦ãã¾ãã
å¶å¾¡æåã¨ã¯ï¼
å¶å¾¡æåã¨ã¯ãæåã³ã¼ãã§æ±ºããããå¨è¾ºæ©å¨ã®å¶å¾¡ãªã©ã«ç¨ããç¹æ®ãªæåã®ãã¨ã§ããä»åå©ç¨ããã®ã¯ãã¿ã¼ããã«ãå¶å¾¡ããã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã¨ãªãã¾ãã
clearã³ãã³ãã¨ã¯ï¼
端æ«ã®ç»é¢ãã¯ãªã¢ã«ããã³ãã³ãã«ãªãã¾ãã
å¦çã®æµã
å¦çã®æµãã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
last1120cãç¨ããå®è£
ä¸è¨ã³ã¼ããå ¨ä½ã®ã½ã¼ã¹ã³ã¼ãã«ãªãã¾ãã
/* clear command */ main(){ extern clear, rcur; clear(); rcur(); return; } /* clear:screen clear */ clear(){ extern esc; esc("2J"); } /* rcursor: reset curosor */ rcur(){ extern esc; esc("H"); } /* esc */ /* code:escape sequences code */ esc(code) char code[]; { extern printf; printf("%c[%s", 033, code); }
escé¢æ°
ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãçºè¡ããå¦çãè¡ãé¢æ°ã§ãã033ãï¼ãã¤ãã®8é²æ°ã¨ãã¦è¡¨ç¤ºãããæååã¨ãã¦ç¶ãcodeãåºåãã¾ãã
/* esc */ /* code:escape sequences code */ esc(code) char code[]; { extern printf; printf("%c[%s", 033, code); }
clearé¢æ°
ç»é¢ãã¯ãªã¢ããã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãåºåããå¦çãè¡ãé¢æ°ã§ãã"\033[2J"ãåºåããã¾ãã
/* clear:screen clear */ clear(){ extern esc; esc("2J"); }
rcuré¢æ°
ã«ã¼ã½ã«ä½ç½®ã0è¡ç®ã®0æåç®ã«ç§»åããå¦çãè¡ãé¢æ°ã§ãã "\033[H"ãåºåããã¾ãã
/* rcursor: reset curosor */ rcur(){ extern esc; esc("H"); }
使ã£ã¦ã¿ã
ãããªã«ãã®æ¨ã...ã
è¦ã¦ããã¨å¿ãå·ãã§ããã®ã§æ¶ãã¦ããã¾ãããã
ããã§å¿ã®å®å¯§ã¯ä¿ããã¾ããã
ã¾ã¨ã
ã¯ãªã¹ãã¹ã¯æ¶ãã¾ããï¼ï¼ï¼
PS)
æ¶ããããã人ã¯ãã¯ãªã¹ãã¹ï¼ãªã«ããç¾å³ããã®ï¼ããèããªããå½æ¥ãéããã¾ãããã
åèæç®
The Restoration of Early UNIX Artifacts
https://www.usenix.org/legacy/event/usenix09/tech/full_papers/toomey/toomey.pdf:
FreeBSD Manual Pages - clear
https://www.freebsd.org/cgi/man.cgi?query=clear&apropos=0&sektion=0&manpath=FreeBSD+13.1-RELEASE+and+Ports&arch=default&format=html
ããã°ã©ãã³ã°è²ã
http://7ujm.net/etc/esc.html