12 #define printf(...) rz_cons_win_printf(false, __VA_ARGS__)
14 static int rz_line_readchar_win(
ut8 *
s,
int slen);
16 #include <sys/ioctl.h>
46 if (
I.buffer.index <= 0) {
60 if (
I.buffer.index >
I.buffer.length) {
61 I.buffer.length =
I.buffer.index;
63 len =
I.buffer.index -
i;
67 memmove(
I.buffer.data +
i,
I.buffer.data +
I.buffer.index,
68 I.buffer.length -
I.buffer.index + 1);
69 I.buffer.length = strlen(
I.buffer.data);
81 len =
i -
I.buffer.index;
85 memmove(
I.buffer.data +
I.buffer.index,
I.buffer.data +
i,
I.buffer.length -
i + 1);
86 I.buffer.length -=
len;
89 static void paste(
bool *enable_yank_pop) {
91 char *cursor =
I.buffer.data +
I.buffer.index;
92 int dist = (
I.buffer.data +
I.buffer.length) - cursor;
93 int len = strlen(
I.clipboard);
94 I.buffer.length +=
len;
95 memmove(cursor +
len, cursor, dist);
97 I.buffer.index +=
len;
98 *enable_yank_pop =
true;
104 if (
I.buffer.index > 0) {
105 for (
i =
I.buffer.index - 1;
i > 0 &&
I.buffer.data[
i] ==
' ';
i--) {
109 for (;
i > 0 &&
I.buffer.data[
i] !=
' ';
i--) {
118 if (
I.buffer.index >
I.buffer.length) {
119 I.buffer.length =
I.buffer.index;
121 len =
I.buffer.index -
i + 1;
125 memmove(
I.buffer.data +
i,
126 I.buffer.data +
I.buffer.index,
127 I.buffer.length -
I.buffer.index + 1);
128 I.buffer.length = strlen(
I.buffer.data);
135 if ((
I.history.size + 1024) *
sizeof(
char *) <
I.history.size) {
138 I.history.data = (
char **)
calloc((
I.history.size + 1024),
sizeof(
char *));
139 if (!
I.history.data) {
160 return rz_line_readchar_win(
s, slen);
173 if ((t =
read (0,
s, 1)) != 1) {
180 }
else if ((
s[0] & 0xe0) == 0xc0) {
182 }
else if ((
s[0] & 0xf0) == 0xe0) {
184 }
else if ((
s[0] & 0xf8) == 0xf0) {
192 for (
i = 1;
i <
len;
i++) {
197 if ((
s[
i] & 0xc0) != 0x80) {
207 static int rz_line_readchar_win(
ut8 *
s,
int slen) {
217 INPUT_RECORD irInBuf = { 0 };
218 BOOL ret, bCtrl =
FALSE;
224 h = GetStdHandle(STD_INPUT_HANDLE);
226 GetConsoleMode(
h, &
mode);
227 SetConsoleMode(
h, new_mode);
231 BOOL ret = ReadFile(
h,
s, 1, &rsz,
NULL);
233 SetConsoleMode(
h,
mode);
234 if (!ret || rsz != 1) {
244 ret = ReadConsoleInputW(
h, &irInBuf, 1, &
out);
250 if (irInBuf.EventType == KEY_EVENT) {
251 if (irInBuf.Event.KeyEvent.bKeyDown) {
252 if (irInBuf.Event.KeyEvent.uChar.UnicodeChar) {
253 char *
tmp = rz_utf16_to_utf8_l(&irInBuf.Event.KeyEvent.uChar.UnicodeChar, 1);
263 bCtrl = irInBuf.Event.KeyEvent.dwControlKeyState & 8;
267 switch (irInBuf.Event.KeyEvent.wVirtualKeyCode) {
268 case VK_UP:
buf[
idx++] =
'A';
break;
269 case VK_DOWN:
buf[
idx++] =
'B';
break;
270 case VK_RIGHT:
buf[
idx++] =
'C';
break;
271 case VK_LEFT:
buf[
idx++] =
'D';
break;
272 case VK_PRIOR:
buf[
idx++] =
'5';
break;
273 case VK_NEXT:
buf[
idx++] =
'6';
break;
274 case VK_DELETE:
buf[
idx++] =
'3';
break;
275 case VK_HOME:
buf[
idx++] =
'H';
break;
276 case VK_END:
buf[
idx++] =
'F';
break;
277 default:
buf[0] = 0;
break;
285 strncpy_s((
char *)
s, slen,
buf,
sizeof(
buf));
286 SetConsoleMode(
h,
mode);
287 return strlen((
char *)
s);
293 line->cb_history_up = up;
294 line->cb_history_down = down;
295 line->offset_hist_index = 0;
296 line->file_hist_index = 0;
297 line->sdbshell_hist_iter = rz_list_head(
line->sdbshell_hist);
307 if (
line->history.do_setup_match) {
309 if (*
line->buffer.data) {
313 line->history.do_setup_match =
false;
320 if (!
line->history.data) {
323 if (
line->history.index > 0 &&
line->history.data) {
325 if (
line->history.match) {
327 for (
i =
line->history.index - 1;
i >= 0;
i--) {
329 line->history.index =
i;
337 line->history.index--;
340 line->buffer.index =
line->buffer.length = strlen(
line->buffer.data);
347 if (
line->hist_down) {
350 if (!
line->history.data) {
354 if (
line->history.match) {
356 for (
i =
line->history.index + 1; i < line->history.top;
i++) {
361 line->history.index =
i;
363 line->history.index++;
365 if (
line->history.index >=
line->history.top) {
366 line->history.index =
line->history.top;
367 if (
line->history.match) {
370 line->buffer.data[0] =
'\0';
372 line->buffer.index =
line->buffer.length = strlen(
line->buffer.data);
375 if (
line->history.data &&
line->history.data[
line->history.index]) {
377 line->buffer.index =
line->buffer.length = strlen(
line->buffer.data);
386 if (!
I.history.data) {
390 if (
I.history.top > 0) {
391 const char *data =
I.history.data[
I.history.top - 1];
392 if (data && !strcmp(
line, data)) {
393 I.history.index =
I.history.top;
397 if (
I.history.top ==
I.history.size) {
399 free(
I.history.data[0]);
400 for (
i = 0;
i <=
I.history.size - 2;
i++) {
401 I.history.data[
i] =
I.history.data[
i + 1];
406 I.history.index =
I.history.top;
411 if (!
I.cb_history_up) {
414 return I.cb_history_up(&
I);
418 if (!
I.cb_history_down) {
421 return I.cb_history_down(&
I);
426 if (!
I.history.data) {
430 if (
I.history.data) {
431 for (
i = 0;
i <
I.history.size &&
I.history.data[
i];
i++) {
433 return I.history.data[
i];
442 if (!
I.history.data) {
445 if (
I.history.data) {
446 for (
i = 0;
i <
I.history.size &&
I.history.data[
i];
i++) {
457 if (
I.history.data) {
458 for (
i = 0;
i <
I.history.size;
i++) {
514 if (
I.history.data) {
515 for (
i = 0;
i <
I.history.index;
i++) {
516 fputs(
I.history.data[
i],
fd);
545 if (pos_y + sel_widget->
h > cons->
rows) {
547 pos_y = cons->
rows - sel_widget->
h - 1;
555 int scrollbar_y = 0, scrollbar_l = 0;
561 for (y = 0; y < sel_widget->
h; y++) {
571 if (scrollbar &&
RZ_BETWEEN(scrollbar_y, y, scrollbar_y + scrollbar_l)) {
655 char *
sp = strchr(
I.buffer.data,
' ');
660 I.buffer.index =
I.buffer.length;
665 I.buffer.data[
I.buffer.length] =
'\0';
666 I.buffer.index =
I.buffer.length;
674 if (argc == 0 || (argc == 1 &&
I.buffer.length >= strlen(
argv[0]))) {
680 I.sel_widget = sel_widget;
682 I.sel_widget->scroll = 0;
683 I.sel_widget->selection = 0;
684 I.sel_widget->options_len = argc;
685 I.sel_widget->options =
argv;
686 I.sel_widget->h =
RZ_MAX(
I.sel_widget->h,
I.sel_widget->options_len);
712 size_t s_len = strlen(
s);
721 buf->length += s_len - diff;
722 buf->index += s_len - diff;
723 buf->data[
buf->length] =
'\0';
728 size_t min_common_len = strlen(ref);
736 char *
s = *(
char **)it;
738 for (j = 0;
s[j] && ref[j] &&
s[j] == ref[j]; j++)
740 if (j < min_common_len) {
753 for (
i = 0;
i < argc &&
argv[
i];
i++) {
754 int l = strlen(
argv[
i]);
758 if (col > (cols >> 1)) {
764 if (
len + col > cols) {
769 slen = strlen(
argv[
i]);
770 len += (slen > col) ? (slen + sep) : (col + sep);
778 int argc = 0,
i, j, plen;
782 if (
I.ns_completion.run) {
788 bool is_at_end =
I.buffer.length ==
I.buffer.index;
797 free(max_common_pfx);
808 if (
I.completion.run) {
809 I.completion.opt =
false;
810 I.completion.run(&
I.completion, &
I.buffer,
I.prompt_type,
I.completion.run_user);
813 opt =
I.completion.opt;
815 if (
I.sel_widget && !
I.sel_widget->complete_common) {
830 plen =
sizeof(
I.buffer.data) - (
int)(
size_t)(
p -
I.buffer.data);
833 plen =
sizeof(
I.buffer.data);
838 I.buffer.index, strlen(
I.buffer.data),
' ');
839 const char *t = end_word !=
NULL ? end_word :
I.buffer.data +
I.buffer.index;
840 int largv0 = strlen(
argv[0] ?
argv[0] :
"");
841 size_t len_t = strlen(t);
844 if ((
p -
I.buffer.data) + largv0 + 1 + len_t < plen) {
850 memmove(
p + tt, t, len_t);
857 p[largv0 + 1] =
'\0';
860 I.buffer.length = strlen(
I.buffer.data);
861 I.buffer.index =
I.buffer.length;
863 }
else if (argc > 0) {
866 const char *t =
I.buffer.data +
I.buffer.index;
868 int min_common_len = strlen(
root);
869 size_t len_t = strlen(t);
872 for (
i = 0;
i < argc;
i++) {
879 if (j < min_common_len) {
885 int tt = min_common_len;
886 memmove(
p + tt, t, len_t);
887 p[tt + len_t] =
'\0';
889 memmove(
p,
root, min_common_len);
891 p[min_common_len] =
'\0';
893 I.buffer.length = strlen(
I.buffer.data);
894 I.buffer.index = (
p -
I.buffer.data) + min_common_len;
901 I.sel_widget->complete_common =
false;
907 if (argc > 1 &&
I.echo) {
918 if (!*enable_yank_pop) {
922 I.buffer.data[
I.buffer.index] = 0;
923 I.kill_ring_ptr -= 1;
924 if (
I.kill_ring_ptr < 0) {
925 I.kill_ring_ptr =
I.kill_ring->length - 1;
928 paste(enable_yank_pop);
932 if (
I.buffer.index <
I.buffer.length) {
934 memmove(
I.buffer.data +
I.buffer.index,
935 I.buffer.data +
I.buffer.index +
len,
936 strlen(
I.buffer.data +
I.buffer.index + 1) + 1);
937 I.buffer.length -=
len;
942 if (
I.buffer.index <
I.buffer.length) {
943 if (
I.buffer.index > 0) {
945 I.buffer.index -=
len;
946 memmove(
I.buffer.data +
I.buffer.index,
947 I.buffer.data +
I.buffer.index +
len,
948 strlen(
I.buffer.data +
I.buffer.index));
949 I.buffer.length -=
len;
953 I.buffer.index =
I.buffer.length;
954 if (
I.buffer.length < 0) {
958 I.buffer.data[
I.buffer.length] =
'\0';
959 if (
I.buffer.index < 0) {
965 I.buffer.data[
I.buffer.index] =
'\0';
966 I.buffer.length =
I.buffer.index;
967 I.buffer.index =
I.buffer.index > 0 ?
I.buffer.index - 1 : 0;
973 int chars = strlen(
I.buffer.data);
985 fwrite(
I.buffer.data, 1,
RZ_MIN(cols, chars), stdout);
987 if (
I.buffer.index > cols) {
989 i =
I.buffer.index - cols;
990 if (
i >
sizeof(
I.buffer.data)) {
991 i =
sizeof(
I.buffer.data) - 1;
996 len =
I.buffer.index -
i;
997 if (
len > 0 && (
i +
len) <=
I.buffer.length) {
998 fwrite(
I.buffer.data +
i, 1,
len, stdout);
1004 I.buffer.index =
I.buffer.index <
I.buffer.length
1010 I.buffer.index =
I.buffer.index
1017 for (
i =
I.buffer.index - 2;
i >= 0;
i--) {
1030 for (
i =
I.buffer.index - 2;
i >= 0;
i--) {
1043 for (
i =
I.buffer.index + 1;
i <
I.buffer.length;
i++) {
1049 if (
i >=
I.buffer.length) {
1050 I.buffer.index =
I.buffer.length - 1;
1056 for (
i =
I.buffer.index + 1;
i <
I.buffer.length;
i++) {
1062 if (
i >=
I.buffer.length) {
1063 I.buffer.index =
I.buffer.length - 1;
1069 for (
i =
I.buffer.index + 1;
i <
I.buffer.length;
i++) {
1075 if (
i >=
I.buffer.length) {
1076 I.buffer.index =
I.buffer.length - 1;
1082 for (
i =
I.buffer.index + 1;
i <
I.buffer.length;
i++) {
1088 if (
i >=
I.buffer.length) {
1089 I.buffer.index =
I.buffer.length - 1;
1095 const char *BEGIN =
"", *END =
"";
1097 if (
I.prompt_mode) {
1098 switch (
I.vi_mode) {
1122 const char *gcomp_line =
"";
1123 static int gcomp = 0;
1133 bool o_do_setup_match =
I.history.do_setup_match;
1134 I.history.do_setup_match =
true;
1137 if (ch ==
'0' && rep == 0) {
1141 rep = (rep * 10) +
tmp;
1144 rep = rep > 0 ? rep : 1;
1149 I.hud->activate =
false;
1150 I.hud->current_entry_n = -1;
1155 I.buffer.index =
I.buffer.length = 0;
1156 *
I.buffer.data =
'\0';
1164 I.buffer.data[
I.buffer.index] =
c;
1183 }
else if (t ==
'W') {
1214 strncpy(
I.buffer.data,
I.buffer.data +
I.buffer.index,
I.buffer.length);
1215 I.buffer.length -=
I.buffer.index;
1231 strcpy(
I.buffer.data, gcomp_line);
1232 I.buffer.length = strlen(
I.buffer.data);
1243 strcpy(
I.buffer.data, gcomp_line);
1244 I.buffer.index = strlen(
I.buffer.data);
1245 I.buffer.length =
I.buffer.index;
1248 I.buffer.index =
I.buffer.length;
1253 paste(enable_yank_pop);
1309 I.history.do_setup_match = o_do_setup_match;
1313 I.history.do_setup_match = o_do_setup_match;
1333 const char *gcomp_line =
"";
1334 static int gcomp_idx = 0;
1335 static bool yank_flag = 0;
1336 static int gcomp = 0;
1337 static int gcomp_is_rev =
true;
1342 int ch = 0,
key,
i = 0;
1343 char *tmp_ed_cmd, prev = 0;
1344 int prev_buflen = -1;
1345 bool enable_yank_pop =
false;
1349 if (!
I.hud || (
I.hud && !
I.hud->activate)) {
1350 I.buffer.index =
I.buffer.length = 0;
1351 I.buffer.data[0] =
'\0';
1353 I.hud->activate =
true;
1356 int mouse_status = cons->
mouse;
1357 if (
I.hud &&
I.hud->vi) {
1362 memmove(
I.buffer.data,
I.contents,
1365 I.buffer.index =
I.buffer.length = strlen(
I.contents);
1387 I.buffer.data[
I.buffer.length] =
'\0';
1389 int cbret =
cb(user,
I.buffer.data);
1391 I.buffer.data[0] = 0;
1392 I.buffer.length = 0;
1405 int len = rz_line_readchar_win((
ut8 *)
buf,
sizeof(
buf));
1421 bool o_do_setup_match =
I.history.do_setup_match;
1422 I.history.do_setup_match =
true;
1433 strcpy(
I.buffer.data, gcomp_line);
1434 I.buffer.length = strlen(
I.buffer.data);
1445 strcpy(
I.buffer.data, gcomp_line);
1446 I.buffer.index = strlen(
I.buffer.data);
1447 I.buffer.length =
I.buffer.index;
1449 }
else if (prev == 24) {
1450 I.buffer.data[
I.buffer.length] = 0;
1451 tmp_ed_cmd =
I.cb_editor(
I.user,
I.buffer.data);
1454 I.buffer.length = strlen(tmp_ed_cmd);
1456 I.buffer.index =
I.buffer.length;
1460 I.buffer.length -= strlen(tmp_ed_cmd);
1465 I.buffer.index =
I.buffer.length;
1470 I.hud->activate =
false;
1471 I.hud->current_entry_n = -1;
1476 I.buffer.index =
I.buffer.length = 0;
1477 *
I.buffer.data =
'\0';
1481 if (!
I.buffer.data[0]) {
1490 if (
I.buffer.index <
I.buffer.length) {
1495 I.buffer.data[
I.buffer.index] =
'\0';
1496 I.buffer.length =
I.buffer.index;
1512 gcomp_is_rev =
true;
1517 if (gcomp_idx > 0) {
1520 gcomp_is_rev =
false;
1527 I.clipboard =
strdup(
I.buffer.data);
1529 I.buffer.data[0] =
'\0';
1530 I.buffer.length = 0;
1538 if (OpenClipboard(
NULL)) {
1539 hClipBoard = GetClipboardData(CF_UNICODETEXT);
1541 clipText = GlobalLock(hClipBoard);
1543 char *txt = rz_utf16_to_utf8(clipText);
1548 int len = strlen(txt);
1549 I.buffer.length +=
len;
1551 I.buffer.index =
I.buffer.length;
1552 strcat(
I.buffer.data, txt);
1554 I.buffer.length -=
len;
1558 GlobalUnlock(hClipBoard);
1568 if (
I.buffer.index > 0) {
1569 strncpy(
I.buffer.data,
I.buffer.data +
I.buffer.index,
I.buffer.length);
1570 I.buffer.length -=
I.buffer.index;
1575 paste(&enable_yank_pop);
1580 yank_flag = enable_yank_pop ? 1 : 0;
1590 if (
I.hud->top_entry_n + 1 <
I.hud->current_entry_n) {
1591 I.hud->top_entry_n++;
1593 }
else if (
I.sel_widget) {
1597 if (gcomp_idx > 0) {
1601 I.history.do_setup_match = o_do_setup_match;
1607 if (
I.hud->top_entry_n >= 0) {
1608 I.hud->top_entry_n--;
1610 }
else if (
I.sel_widget) {
1616 I.history.do_setup_match = o_do_setup_match;
1638 if (
I.enable_vi_mode) {
1652 I.buffer.index =
I.buffer.length;
1656 for (
i =
I.buffer.index - 2;
i >= 0;
i--) {
1658 I.buffer.index =
i + 1;
1673 for (
i =
I.buffer.index + 1;
i <
I.buffer.length;
i++) {
1679 if (
i >=
I.buffer.length) {
1680 I.buffer.index =
I.buffer.length;
1692 if (
buf[0] == 0x5b) {
1709 I.hud->top_entry_n -= (rows - 1);
1710 if (
I.hud->top_entry_n < 0) {
1711 I.hud->top_entry_n = 0;
1724 I.hud->top_entry_n += (rows - 1);
1725 if (
I.hud->top_entry_n >=
I.hud->current_entry_n) {
1726 I.hud->top_entry_n =
I.hud->current_entry_n - 1;
1738 if (
I.hud &&
I.hud->top_entry_n + 1 <
I.hud->current_entry_n) {
1739 I.hud->top_entry_n--;
1741 }
else if (
key ==
'7') {
1742 if (
I.hud &&
I.hud->top_entry_n >= 0) {
1743 I.hud->top_entry_n++;
1752 if (
I.hud->top_entry_n > 0) {
1753 I.hud->top_entry_n--;
1755 }
else if (
I.sel_widget) {
1761 I.history.do_setup_match = o_do_setup_match;
1770 if (
I.hud->top_entry_n + 1 <
I.hud->current_entry_n) {
1771 I.hud->top_entry_n++;
1773 }
else if (
I.sel_widget) {
1777 if (gcomp_idx > 0) {
1781 I.history.do_setup_match = o_do_setup_match;
1810 int fkey = ch -
'0';
1818 for (
i =
I.buffer.index;
i > 0;
i--) {
1819 if (
I.buffer.data[
i] ==
' ') {
1820 I.buffer.index =
i - 1;
1824 if (
I.buffer.data[
i] !=
' ') {
1830 I.buffer.index =
I.buffer.length;
1834 for (
i =
I.buffer.index;
i <
I.buffer.length;
i++) {
1835 if (
I.buffer.data[
i] ==
' ') {
1836 I.buffer.index =
i + 1;
1840 if (
I.buffer.data[
i] !=
' ') {
1841 I.buffer.index =
I.buffer.length;
1847 I.cb_fkey(
I.user, fkey);
1875 I.buffer.index =
I.buffer.length;
1883 if (
I.hud && (
I.buffer.index == 0)) {
1884 I.hud->activate =
false;
1885 I.hud->current_entry_n = -1;
1892 I.sel_widget->complete_common =
true;
1896 if (
I.hud->top_entry_n + 1 <
I.hud->current_entry_n) {
1897 I.hud->top_entry_n++;
1899 I.hud->top_entry_n = 0;
1909 I.hud->activate =
false;
1916 if (gcomp &&
I.buffer.length > 0) {
1919 I.buffer.length = strlen(gcomp_line);
1921 gcomp_idx = gcomp = 0;
1937 if (
I.buffer.index <
I.buffer.length) {
1939 if ((
I.buffer.length + utflen) <
sizeof(
I.buffer.data)) {
1940 I.buffer.length += utflen;
1941 for (
i =
I.buffer.length;
i >
I.buffer.index;
i--) {
1942 I.buffer.data[
i] =
I.buffer.data[
i - utflen];
1944 memcpy(
I.buffer.data +
I.buffer.index,
buf, utflen);
1947 for (
i = ++
I.buffer.length;
i >
I.buffer.index;
i--) {
1948 I.buffer.data[
i] =
I.buffer.data[
i - 1];
1950 I.buffer.data[
I.buffer.index] =
buf[0];
1954 if ((
I.buffer.length + utflen) <
sizeof(
I.buffer.data)) {
1955 memcpy(
I.buffer.data +
I.buffer.length,
buf, utflen);
1956 I.buffer.length += utflen;
1958 I.buffer.data[
I.buffer.length] =
'\0';
1960 I.buffer.data[
I.buffer.length] =
buf[0];
1965 I.buffer.data[
I.buffer.length] =
'\0';
1969 if ((
I.buffer.index + utflen) <=
I.buffer.length) {
1970 I.buffer.index += utflen;
1973 if (
I.buffer.index <
I.buffer.length) {
1979 if (
I.sel_widget &&
I.buffer.length != prev_buflen) {
1980 prev_buflen =
I.buffer.length;
1989 if (
I.history.data !=
NULL) {
1990 for (
i =
I.history.size - 1;
i >= 0;
i--) {
1991 if (!
I.history.data[
i]) {
1994 if (strstr(
I.history.data[
i],
I.buffer.data)) {
1995 gcomp_line =
I.history.data[
i];
2007 const char *
prompt = gcomp_is_rev ?
"reverse-i-search" :
"forward-i-search";
2008 printf(
"\r (%s (%s)): %s\r",
prompt,
I.buffer.data, gcomp_line);
2014 enable_yank_pop = yank_flag ? 1 : 0;
2024 printf(
"\r%s%s\n",
I.prompt,
I.buffer.data);
2031 if (!memcmp(
I.buffer.data,
"!history", 8)) {
const lzma_allocator const uint8_t size_t uint8_t * out
RZ_API void rz_cons_set_raw(bool is_raw)
RZ_API int rz_cons_get_size(int *rows)
RZ_API int rz_cons_memcat(const char *str, int len)
RZ_API bool rz_cons_enable_mouse(const bool enable)
RZ_API RzCons * rz_cons_singleton(void)
RZ_API void rz_cons_clear_line(int std_err)
RZ_API void * rz_cons_sleep_begin(void)
RZ_API void rz_cons_break_pop(void)
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API int rz_cons_get_cur_line(void)
RZ_API void rz_cons_flush(void)
RZ_API bool rz_cons_is_breaked(void)
RZ_API void rz_cons_sleep_end(void *user)
RZ_API void rz_cons_gotoxy(int x, int y)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static fork const void static count static fd const char const char static newpath const char static path const char path
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
RZ_API int rz_line_dietline_init(void)
static void selection_widget_select(void)
RZ_API int rz_line_hist_cmd_down(RzLine *line)
RZ_API const char * rz_line_readline(void)
RZ_API int rz_line_hist_cmd_up(RzLine *line)
static void kill_word(BreakMode mode)
static void __move_cursor_left(void)
static void selection_widget_down(int steps)
static void backward_kill_word(BreakMode mode)
static void selection_widget_erase(void)
RZ_API int rz_line_hist_list(void)
static char * rz_line_nullstr
static void delete_till_end(void)
static void print_rline_task(void *_core)
static void vi_cmd_w(void)
static void __delete_next_char(void)
static void __move_cursor_right(void)
static void selection_widget_update(void)
static bool is_valid_buffer_limits(RzLineBuffer *buf, size_t start, size_t end, size_t s_len)
RZ_API void rz_line_autocomplete(void)
static void print_options(int argc, const char **argv)
static void vi_cmd_E(void)
static void __update_prompt_color(void)
RZ_API void rz_line_hist_free(void)
static int rz_line_hist_down(void)
static void paste(bool *enable_yank_pop)
static void unix_word_rubout(void)
RZ_API int rz_line_hist_chop(const char *file, int limit)
static char * get_max_common_pfx(RzPVector *options)
static const char word_break_characters[]
static void __delete_prev_char(void)
static void vi_cmd_B(void)
static void selection_widget_draw(void)
RZ_API int rz_line_hist_load(RZ_NONNULL const char *path)
Load the history of commands from path.
static void vi_cmd_W(void)
static int rz_line_hist_up(void)
static int inithist(void)
static void __vi_mode(bool *enable_yank_pop)
RZ_API const char * rz_line_readline_cb(RzLineReadCallback cb, void *user)
static bool is_word_break_char(char ch, bool mode)
static void vi_cmd_b(void)
RZ_API int rz_line_set_hist_callback(RzLine *line, RzLineHistoryUpCb up, RzLineHistoryDownCb down)
static void selection_widget_up(int steps)
RZ_API const char * rz_line_hist_get(int n)
static void __print_prompt(void)
static bool match_hist_line(char *hist_line, char *cur_line)
static int rz_line_readchar_utf8(ut8 *s, int slen)
static void rotate_kill_ring(bool *enable_yank_pop)
RZ_API int rz_line_hist_add(const char *line)
RZ_API int rz_line_hist_save(RZ_NONNULL const char *path)
Save the history of commands executed until now to file path.
static void vi_cmd_e(void)
static void replace_buffer_text(RzLineBuffer *buf, size_t start, size_t end, const char *s)
static void setup_hist_match(RzLine *line)
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API RZ_BORROW void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
void * calloc(size_t number, size_t size)
RZ_API void rz_line_clipboard_push(const char *str)
RZ_API void rz_line_ns_completion_result_free(RzLineNSCompletionResult *res)
static static fork const void static count static fd const char const char static newpath char char argv
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static const char struct stat static buf struct stat static buf static vhangup int options
static uint32_t const uint8_t uint32_t uint32_t limit
#define rz_return_val_if_fail(expr, val)
int(* RzLineHistoryUpCb)(RzLine *line)
@ RZ_VIRT_TERM_MODE_COMPLETE
All the sequences goes through VT (Windows Terminal, mintty, all OSs)
#define RZ_SELWIDGET_DIR_UP
#define RZ_SELWIDGET_MAXW
#define RZ_SELWIDGET_DIR_DOWN
#define RZ_SELWIDGET_MAXH
#define Color_INVERT_RESET
int(* RzLineHistoryDownCb)(RzLine *line)
#define RZ_CONS_CLEAR_FROM_CURSOR_TO_END
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API size_t rz_str_utf8_charsize_prev(const char *str, int prev_len)
RZ_API size_t rz_str_utf8_charsize_last(const char *str)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_ndup(RZ_NULLABLE const char *ptr, int len)
Create new copy of string ptr limited to size len.
RZ_API RZ_OWN char * rz_str_escape(RZ_NONNULL const char *buf)
RZ_API RZ_BORROW char * rz_str_trim_tail(RZ_NONNULL char *str)
Removes whitespace characters (space, tab, newline etc.) from the end of a string and replaces them w...
RZ_API size_t rz_str_ansi_len(const char *str)
#define RZ_STR_ISEMPTY(x)
RZ_API const char * rz_sub_str_rchr(const char *str, int start, int end, char chr)
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
RZ_API const char * rz_str_pad(const char ch, int len)
RZ_API const char * rz_sub_str_lchr(const char *str, int start, int end, char chr)
RZ_API size_t rz_str_utf8_charsize(const char *str)
RZ_API const char * rz_str_lastbut(const char *s, char ch, const char *but)
RZ_API bool rz_sys_mkdirp(const char *dir)
RZ_API FILE * rz_sys_fopen(const char *path, const char *mode)
#define RZ_BETWEEN(x, y, z)
static void ** rz_pvector_data(RzPVector *vec)
static size_t rz_pvector_len(const RzPVector *vec)
static bool rz_pvector_empty(RzPVector *vec)
static void * rz_pvector_at(const RzPVector *vec, size_t index)
#define rz_pvector_foreach(vec, it)
RzConsPrintablePalette pal
bool show_autocomplete_widget
RzConsQueueTaskOneshot cb_task_oneshot
RzCoreTaskScheduler tasks
size_t start
First byte that was considered for autocompletion. Everything before this will be left intact.
const char * end_string
String to place after the only option available is autocompleted. By default a space is used.
size_t end
Last byte that was considered for autocompletion. Everything after this will be left intact.
RzPVector options
Vector of options that can be used for autocompletion.
RzLinePromptType prompt_type
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)