diff options
| author | 2024-09-02 21:30:22 -0400 | |
|---|---|---|
| committer | 2024-09-02 21:30:22 -0400 | |
| commit | 8ddcd6bdc678538c507c3012abe9346186cc20d0 (patch) | |
| tree | b5b49fb6e3ff3dce27c57ee7872b1c0718f7e3d5 | |
| parent | updated help and fixed SIGINT (diff) | |
added arrow key movement
| -rw-r--r-- | src/help.h | 24 | ||||
| -rw-r--r-- | src/lush.c | 156 |
2 files changed, 122 insertions, 58 deletions
@@ -2,29 +2,7 @@ #define HELP_H char *lush_get_help_text() { - return "[0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m[38;2;3;0;4m [0m[38;2;69;8;105m.[0m[38;2;118;14;176m.[0m[38;2;146;17;212m,[0m[38;2;165;19;235m;[0m[38;2;177;21;247m;[0m[38;2;181;21;247m;[0m[38;2;185;22;247m;[0m[38;2;189;23;247m;[0m[38;2;193;23;247m:[0m[38;2;196;24;247m:[0m[38;2;200;24;246m:[0m[38;2;204;25;247m:[0m[38;2;208;25;246m:[0m[38;2;212;26;246m:[0m[38;2;216;27;246m:[0m[38;2;220;27;246m:[0m[38;2;223;28;246mc[0m[38;2;227;28;246mc[0m[38;2;231;29;246mc[0m[38;2;235;30;246mc[0m[38;2;238;31;246mc[0m[38;2;238;36;245mc[0m[38;2;238;40;244ml[0m[38;2;239;45;243ml[0m[38;2;239;49;242ml[0m[38;2;239;54;241ml[0m[38;2;239;58;240ml[0m[38;2;240;63;239mo[0m[38;2;240;67;238mo[0m[38;2;240;72;238mo[0m[38;2;240;76;237mo[0m[38;2;241;81;236md[0m[38;2;241;85;235md[0m[38;2;241;90;234md[0m[38;2;241;94;233md[0m[38;2;242;99;232mx[0m[38;2;242;103;231mx[0m[38;2;242;108;230mx[0m[38;2;230;107;218md[0m[38;2;208;100;196mo[0m[38;2;172;86;161mc[0m[38;2;109;57;102m,[0m[38;2;8;4;7m [0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m\n" -"[0m[38;2;0;0;0m [0m[38;2;11;1;18m [0m[38;2;91;10;143m.[0m[38;2;147;17;227m,[0m[38;2;164;19;247m;[0m[38;2;161;20;238m;[0m[38;2;147;20;210m,[0m[38;2;140;20;196m,[0m[38;2;138;21;189m'[0m[38;2;139;21;186m'[0m[38;2;140;21;184m,[0m[38;2;143;22;184m,[0m[38;2;146;22;184m,[0m[38;2;149;23;184m,[0m[38;2;152;23;184m,[0m[38;2;154;23;184m,[0m[38;2;157;24;184m,[0m[38;2;160;24;184m,[0m[38;2;163;25;184m,[0m[38;2;166;25;184m,[0m[38;2;168;26;184m,[0m[38;2;171;26;184m;[0m[38;2;174;26;184m;[0m[38;2;177;27;184m;[0m[38;2;178;29;183m;[0m[38;2;178;32;182m;[0m[38;2;178;36;182m;[0m[38;2;178;39;181m;[0m[38;2;179;42;180m:[0m[38;2;179;45;180m:[0m[38;2;179;49;179m:[0m[38;2;179;52;178m:[0m[38;2;179;55;178m:[0m[38;2;179;58;177m:[0m[38;2;180;62;176m:[0m[38;2;180;65;176mc[0m[38;2;180;68;175mc[0m[38;2;180;71;175mc[0m[38;2;180;75;174mc[0m[38;2;181;78;173mc[0m[38;2;182;82;174ml[0m[38;2;185;86;176ml[0m[38;2;192;93;181ml[0m[38;2;205;102;193mo[0m[38;2;232;118;217mx[0m[38;2;243;128;226mk[0m[38;2;230;125;213mx[0m[38;2;154;87;142mc[0m[38;2;21;12;19m [0m[38;2;0;0;0m [0m\n" -"[0m[38;2;18;2;28m [0m[38;2;143;16;228m,[0m[38;2;159;18;247m,[0m[38;2;137;19;206m,[0m[38;2;66;19;92m.[0m[38;2;24;19;27m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;26;22;26m [0m[38;2;86;52;80m'[0m[38;2;191;108;177mo[0m[38;2;244;140;224mO[0m[38;2;232;137;212mk[0m[38;2;44;27;40m.[0m\n" -"[0m[38;2;107;12;168m.[0m[38;2;160;18;247m,[0m[38;2;148;19;223m,[0m[38;2;26;19;31m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;28;29;29m [0m[38;2;30;31;32m.[0m[38;2;30;31;32m.[0m[38;2;30;31;32m.[0m[38;2;30;31;32m.[0m[38;2;30;31;32m.[0m[38;2;30;31;32m.[0m[38;2;20;20;20m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;24;22;23m [0m[38;2;202;120;185md[0m[38;2;244;148;222mO[0m[38;2;211;131;191mx[0m\n" -"[0m[38;2;159;18;243m,[0m[38;2;165;19;247m;[0m[38;2;118;19;171m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;38;39;40m.[0m[38;2;100;102;105m:[0m[38;2;109;111;114mc[0m[38;2;45;45;46m.[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;87;94;99m;[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;27;27;28m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;145;90;132mc[0m[38;2;245;151;222mO[0m[38;2;245;156;221mO[0m\n" -"[0m[38;2;167;19;247m;[0m[38;2;170;20;247m;[0m[38;2;114;20;159m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;20;20;20m [0m[38;2;101;103;106m:[0m[38;2;224;229;236mN[0m[38;2;130;133;137ml[0m[38;2;20;20;20m [0m[38;2;19;19;19m [0m[38;2;87;94;99m;[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;27;27;28m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;133;86;121m:[0m[38;2;245;155;221mO[0m[38;2;245;159;220m0[0m\n" -"[0m[38;2;172;20;247m;[0m[38;2;175;21;247m;[0m[38;2;116;20;158m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;201;206;212mK[0m[38;2;231;236;243mN[0m[38;2;98;100;103m:[0m[38;2;19;19;19m [0m[38;2;87;94;99m;[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;27;27;28m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;87;120m:[0m[38;2;245;158;220m0[0m[38;2;245;163;220m0[0m\n" -"[0m[38;2;178;21;247m;[0m[38;2;181;21;247m;[0m[38;2;120;21;158m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;98;100;102m:[0m[38;2;230;235;242mN[0m[38;2;231;236;243mN[0m[38;2;121;123;126ml[0m[38;2;19;19;19m [0m[38;2;87;94;99m;[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;27;27;28m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;89;120m:[0m[38;2;245;162;220m0[0m[38;2;246;167;219m0[0m\n" -"[0m[38;2;184;22;247m;[0m[38;2;187;23;247m;[0m[38;2;123;21;158m'[0m[38;2;26;27;27m [0m[38;2;121;123;127ml[0m[38;2;99;101;103m:[0m[38;2;54;54;56m.[0m[38;2;32;32;33m.[0m[38;2;32;32;32m.[0m[38;2;53;54;55m.[0m[38;2;96;98;100m;[0m[38;2;170;173;178mk[0m[38;2;230;235;242mN[0m[38;2;231;236;243mN[0m[38;2;175;179;184mk[0m[38;2;32;32;33m.[0m[38;2;19;19;19m [0m[38;2;87;94;99m;[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;27;27;28m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;91;119m:[0m[38;2;246;166;219m0[0m[38;2;246;170;218m0[0m\n" -"[0m[38;2;191;23;247m:[0m[38;2;193;23;247m:[0m[38;2;127;22;158m'[0m[38;2;19;19;19m [0m[38;2;22;22;23m [0m[38;2;92;94;96m;[0m[38;2;160;163;168mx[0m[38;2;199;203;209m0[0m[38;2;221;226;232mX[0m[38;2;228;233;240mN[0m[38;2;217;222;229mX[0m[38;2;191;195;200m0[0m[38;2;146;149;154md[0m[38;2;82;84;86m,[0m[38;2;21;21;21m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;87;94;99m;[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;96;103;109m:[0m[38;2;27;27;28m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;93;119m:[0m[38;2;246;170;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;197;24;246m:[0m[38;2;199;24;247m:[0m[38;2;131;22;158m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;23;23;23m [0m[38;2;27;28;28m [0m[38;2;20;20;20m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;63;67;70m'[0m[38;2;69;74;77m'[0m[38;2;69;74;77m'[0m[38;2;69;74;77m'[0m[38;2;69;74;77m'[0m[38;2;69;74;77m'[0m[38;2;69;73;77m'[0m[38;2;23;24;24m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;95;118m:[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;203;25;246m:[0m[38;2;206;25;246m:[0m[38;2;134;23;158m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;95;118m:[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;209;26;246m:[0m[38;2;212;26;246m:[0m[38;2;138;23;158m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;95;118m:[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;216;27;246m:[0m[38;2;218;27;246m:[0m[38;2;142;24;158m'[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;95;118m:[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;222;27;246mc[0m[38;2;225;28;246mc[0m[38;2;146;25;158m,[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;95;118m:[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;229;28;246mc[0m[38;2;231;29;246mc[0m[38;2;150;25;158m,[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;132;95;118m:[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;235;29;246mc[0m[38;2;237;30;246mc[0m[38;2;154;27;159m,[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;134;96;120m:[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;207;29;213m:[0m[38;2;238;36;245mc[0m[38;2;167;32;171m;[0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;147;105;131mc[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m\n" -"[0m[38;2;100;17;102m.[0m[38;2;239;44;243ml[0m[38;2;219;44;222mc[0m[38;2;34;21;34m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;27;24;26m [0m[38;2;208;145;185mk[0m[38;2;246;171;218m0[0m[38;2;114;79;101m;[0m\n" -"[0m[38;2;23;23;23m [0m[38;2;107;23;108m.[0m[38;2;239;54;241ml[0m[38;2;207;52;208mc[0m[38;2;100;35;100m.[0m[38;2;35;22;35m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;19;19;19m [0m[38;2;34;29;32m.[0m[38;2;98;72;88m,[0m[38;2;202;142;180mx[0m[38;2;246;171;218m0[0m[38;2;114;79;101m;[0m[38;2;47;47;47m [0\n" -"[0m[38;2;0;0;0m [0m[38;2;12;12;12m [0m[38;2;71;71;71m [0m[38;2;23;6;23m [0m[38;2;240;67;239mo[0m[38;2;237;69;235mo[0m[38;2;216;67;213ml[0m[38;2;202;66;199ml[0m[38;2;195;66;192mc[0m[38;2;193;68;188mc[0m[38;2;191;70;186mc[0m[38;2;191;72;186mc[0m[38;2;191;75;185ml[0m[38;2;191;77;185ml[0m[38;2;192;80;184ml[0m[38;2;192;82;184ml[0m[38;2;192;85;183ml[0m[38;2;192;87;183ml[0m[38;2;192;90;182ml[0m[38;2;192;93;182ml[0m[38;2;192;95;181mo[0m[38;2;193;98;181mo[0m[38;2;193;101;180mo[0m[38;2;193;104;180mo[0m[38;2;193;107;179mo[0m[38;2;193;110;178mo[0m[38;2;193;112;178mo[0m[38;2;194;115;177md[0m[38;2;194;118;177md[0m[38;2;194;121;176md[0m[38;2;194;124;176md[0m[38;2;194;127;175md[0m[38;2;194;130;174md[0m[38;2;194;133;174md[0m[38;2;195;136;173mx[0m[38;2;195;137;173mx[0m[38;2;195;137;173mx[0m[38;2;195;137;173mx[0m[38;2;195;137;173mx[0m[38;2;195;137;173mx[0m[38;2;196;138;174mx[0m[38;2;199;140;177mx[0m[38;2;206;144;183mx[0m[38;2;219;153;194mk[0m[38;2;242;168;214m0[0m[38;2;246;171;218m0[0m[38;2;50;34;44m.[0m[38;2;113;113;113m [0m[38;2;20;20;20m [0m[38;2;0;0;0m [0m\n" -"[0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m[38;2;2;2;2m [0m[38;2;52;52;52m [0m[38;2;97;97;97m [0m[38;2;121;121;121m [0m[38;2;76;25;74m.[0m[38;2;241;83;235md[0m[38;2;241;86;235md[0m[38;2;241;89;234md[0m[38;2;241;92;234md[0m[38;2;242;95;233md[0m[38;2;242;98;232mx[0m[38;2;242;102;232mx[0m[38;2;242;105;231mx[0m[38;2;242;108;230mx[0m[38;2;242;111;230mx[0m[38;2;243;115;229mx[0m[38;2;243;118;228mk[0m[38;2;243;122;228mk[0m[38;2;243;125;227mk[0m[38;2;244;129;226mk[0m[38;2;244;132;225mk[0m[38;2;244;136;225mk[0m[38;2;244;140;224mO[0m[38;2;244;143;223mO[0m[38;2;245;147;223mO[0m[38;2;245;151;222mO[0m[38;2;245;154;221mO[0m[38;2;245;158;220mO[0m[38;2;245;162;220m0[0m[38;2;246;166;219m0[0m[38;2;246;169;218m0[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m[38;2;246;171;218m0[0m[38;2;188;188;188m [0m[38;2;168;168;168m [0m[38;2;134;134;134m [0m[38;2;78;78;78m [0m[38;2;6;6;6m [0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m[38;2;0;0;0m [0m\n" -".____ _________.__ .__ .__ \n" + return ".____ _________.__ .__ .__ \n" "| | __ __ ____ _____ _______ / _____/| |__ ____ | | | | \n" "| | | | \\/ \\\\__ \\\\_ __ \\ \\_____ \\ | | \\_/ __ \\| | | | \n" "| |___| | / | \\/ __ \\| | \\/ / \\| Y \\ ___/| |_| |__\n" @@ -27,9 +27,12 @@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include <string.h> #include <sys/types.h> #include <sys/wait.h> +#include <termios.h> #include <time.h> #include <unistd.h> +#define BUFFER_SIZE 1024 + // -- builtin functions -- char *builtin_strs[] = {"cd", "help", "exit", "time"}; @@ -116,18 +119,115 @@ int lush_time(char ***args) { } // -- shell utility -- + +// -- static helpers for input -- + +static void set_raw_mode(struct termios *orig_termios) { + struct termios raw; + tcgetattr(STDIN_FILENO, orig_termios); + raw = *orig_termios; + raw.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &raw); +} + +static void reset_terminal_mode(struct termios *orig_termios) { + tcsetattr(STDIN_FILENO, TCSANOW, orig_termios); +} + +static void print_prompt() { + char *username = getenv("USER"); + char device_name[256]; + gethostname(device_name, sizeof(device_name)); + char *cwd = getcwd(NULL, 0); + + // Replace /home/<user> with ~ + char *home_prefix = "/home/"; + size_t home_len = strlen(home_prefix) + strlen(username); + char *prompt_cwd; + if (strncmp(cwd, home_prefix, strlen(home_prefix)) == 0 && + strncmp(cwd + strlen(home_prefix), username, strlen(username)) == 0) { + prompt_cwd = malloc(strlen(cwd) - home_len + + 2); // 1 for ~ and 1 for null terminator + snprintf(prompt_cwd, strlen(cwd) - home_len + 2, "~%s", cwd + home_len); + } else { + prompt_cwd = strdup(cwd); + } + + // Print the prompt + printf("[%s@%s:%s] ", username, device_name, prompt_cwd); + free(cwd); +} + +static void reprint_buffer(const char *buffer, int pos) { + printf("\r\033[K"); + print_prompt(); + printf("%s ", buffer); + printf("\033[%ldD", strlen(buffer) - pos + 1); +} + char *lush_read_line() { - char *line = NULL; - size_t bufsize = 0; - if (getline(&line, &bufsize, stdin) == -1) { - if (feof(stdin)) { - exit(EXIT_SUCCESS); + struct termios orig_termios; + char *buffer = (char *)calloc(BUFFER_SIZE, sizeof(char)); + int pos = 0; + int c; + + // init buffer and make raw mode + set_raw_mode(&orig_termios); + + while (true) { + c = getchar(); + + if (c == '\033') { // escape sequence + getchar(); // skip [ + switch (getchar()) { + case 'C': // right arrow + if (pos < strlen(buffer)) { + pos++; + reprint_buffer(buffer, pos); + } + break; + case 'D': // left arrow + if (pos > 0) { + pos--; + reprint_buffer(buffer, pos); + } + break; + case '3': // delete + if (getchar() == '~') { + if (pos < strlen(buffer)) { + memmove(&buffer[pos], &buffer[pos + 1], + strlen(&buffer[pos + 1]) + 1); + reprint_buffer(buffer, pos); + } + } + break; + default: + break; + } + } else if (c == '\177') { // backspace + if (pos > 0) { + memmove(&buffer[pos - 1], &buffer[pos], + strlen(&buffer[pos]) + 1); + pos--; + reprint_buffer(buffer, pos); + } + } else if (c == '\n') { + break; // submit the command } else { - perror("readline"); - exit(EXIT_FAILURE); + if (pos < BUFFER_SIZE - 1) { + // insert text into buffer + memmove(&buffer[pos + 1], &buffer[pos], + strlen(&buffer[pos]) + 1); + buffer[pos] = c; + pos++; + + reprint_buffer(buffer, pos); + } } } - return line; + + reset_terminal_mode(&orig_termios); + return buffer; } char **lush_split_pipes(char *line) { @@ -286,10 +386,7 @@ void lush_execute_command(char **args, int input_fd, int output_fd) { pid_t pid; int status; - // ignore SIGINT in the parent process struct sigaction sa; - sa.sa_handler = SIG_IGN; - sigaction(SIGINT, &sa, NULL); if ((pid = fork()) == 0) { // child process content @@ -343,33 +440,23 @@ int lush_run(char ***commands, int num_commands) { } int main() { + // eat ^C in main + struct sigaction sa; + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGINT, &sa, NULL); + int status = 0; while (true) { // Prompt - char *username = getenv("USER"); - char device_name[256]; - gethostname(device_name, sizeof(device_name)); - char *cwd = getcwd(NULL, 0); - - // Replace /home/<user> with ~ - char *home_prefix = "/home/"; - size_t home_len = strlen(home_prefix) + strlen(username); - char *prompt_cwd; - if (strncmp(cwd, home_prefix, strlen(home_prefix)) == 0 && - strncmp(cwd + strlen(home_prefix), username, strlen(username)) == - 0) { - prompt_cwd = malloc(strlen(cwd) - home_len + - 2); // 1 for ~ and 1 for null terminator - snprintf(prompt_cwd, strlen(cwd) - home_len + 2, "~%s", - cwd + home_len); - } else { - prompt_cwd = strdup(cwd); - } - - // Print the prompt - printf("[%s@%s:%s] ", username, device_name, prompt_cwd); - + print_prompt(); char *line = lush_read_line(); + if (line == NULL || strlen(line) == 0) { + free(line); + continue; + } + printf("\n"); char **commands = lush_split_pipes(line); char ***args = lush_split_args(commands, &status); if (status == -1) { @@ -384,6 +471,5 @@ int main() { free(args); free(commands); free(line); - free(cwd); } } |
