MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / linenoiseReadEscapeSequence

Function linenoiseReadEscapeSequence

tools/shell/linenoise.cpp:1089–1124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087}
1088
1089uint64_t linenoiseReadEscapeSequence(int ifd, char seq[]) {
1090 if (read(ifd, seq, 1) == -1) {
1091 return 0;
1092 }
1093 switch (seq[0]) {
1094 case 'O':
1095 case '[':
1096 // these characters have multiple bytes following them
1097 break;
1098 default:
1099 return 1;
1100 }
1101 if (read(ifd, seq + 1, 1) == -1) {
1102 return 0;
1103 }
1104
1105 if (seq[0] != '[') {
1106 return 2;
1107 }
1108 if (seq[1] < '0' || seq[1] > '9') {
1109 return 2;
1110 }
1111 /* Extended escape, read additional byte. */
1112 if (read(ifd, seq + 2, 1) == -1) {
1113 return 0;
1114 }
1115 if (seq[2] == ';') {
1116 // read 2 extra bytes
1117 if (read(ifd, seq + 3, 2) == -1) {
1118 return 0;
1119 }
1120 return 5;
1121 } else {
1122 return 3;
1123 }
1124}
1125
1126EscapeSequence linenoiseReadEscapeSequence(int ifd) {
1127 char seq[5];

Callers 2

completeLineFunction · 0.85
linenoiseEditFunction · 0.85

Calls 2

readFunction · 0.85
EscapeSequenceEnum · 0.85

Tested by

no test coverage detected