MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / if

Function if

components/finsh/shell.c:649–681  ·  view source on GitHub ↗

Add Ctrl+Left/Right handling */

Source from the content-addressed store, hash-verified

647#if defined(FINSH_USING_WORD_OPERATION)
648 /* Add Ctrl+Left/Right handling */
649 else if (ch == '1')
650 {
651 /* Read modifier sequence [1;5D/C] */
652 int next_ch = finsh_getchar();
653 if (next_ch == ';')
654 {
655 next_ch = finsh_getchar();
656 if (next_ch == '5')
657 {
658 next_ch = finsh_getchar();
659 if (next_ch == 'D') /* Ctrl+Left */
660 {
661 int new_pos = find_prev_word_start(shell->line, shell->line_curpos);
662 if (new_pos != shell->line_curpos)
663 {
664 rt_kprintf("\033[%dD", shell->line_curpos - new_pos);
665 shell->line_curpos = new_pos;
666 }
667 continue;
668 }
669 else if (next_ch == 'C') /* Ctrl+Right */
670 {
671 int new_pos = find_next_word_end(shell->line, shell->line_curpos, shell->line_position);
672 if (new_pos != shell->line_curpos)
673 {
674 rt_kprintf("\033[%dC", new_pos - shell->line_curpos);
675 shell->line_curpos = new_pos;
676 }
677 continue;
678 }
679 }
680 }
681 }
682#endif /*defined(FINSH_USING_WORD_OPERATION) */
683#if defined(FINSH_USING_FUNC_EXT)
684 else if (ch >= 0x31 && ch <= 0x34) /* home(0x31), insert(0x32), del(0x33), end(0x34) */

Callers

nothing calls this directly

Calls 6

finsh_getcharFunction · 0.85
find_prev_word_startFunction · 0.85
rt_kprintfFunction · 0.85
find_next_word_endFunction · 0.85
rt_memmoveFunction · 0.85
rt_memsetFunction · 0.85

Tested by

no test coverage detected