|
84 | 84 | // C-f |
85 | 85 | 70: moveForward, |
86 | 86 | // C-k |
87 | | - 75: deleteUntilEnd |
| 87 | + 75: deleteUntilEnd, |
| 88 | + // C-u |
| 89 | + 85 : clearCurrentPrompt |
88 | 90 | }; |
89 | 91 | if(config.ctrlCodes) { |
90 | 92 | $.extend(ctrlCodes, config.ctrlCodes); |
|
161 | 163 | extern.typer = typer; |
162 | 164 | extern.scrollToBottom = scrollToBottom; |
163 | 165 | extern.report = report; |
| 166 | + extern.showCompletion = showCompletion; |
164 | 167 | })(); |
165 | 168 |
|
166 | 169 | //////////////////////////////////////////////////////////////////////// |
|
420 | 423 | updatePromptDisplay(); |
421 | 424 | } |
422 | 425 | }; |
| 426 | + |
| 427 | + function clearCurrentPrompt() { |
| 428 | + extern.promptText(""); |
| 429 | + }; |
423 | 430 |
|
424 | 431 | function deleteNextWord() { |
425 | 432 | // A word is defined within this context as a series of alphanumeric |
|
667 | 674 | }; |
668 | 675 |
|
669 | 676 | function doComplete() { |
| 677 | + if(typeof config.completeHandle == 'function') { |
| 678 | + doCompleteDirectly(); |
| 679 | + } else { |
| 680 | + issueComplete(); |
| 681 | + } |
| 682 | + }; |
| 683 | + |
| 684 | + function doCompleteDirectly() { |
670 | 685 | if(typeof config.completeHandle == 'function') { |
671 | 686 | var completions = config.completeHandle(promptText); |
672 | 687 | var len = completions.length; |
|
699 | 714 | } |
700 | 715 | } |
701 | 716 | }; |
| 717 | + |
| 718 | + function issueComplete() { |
| 719 | + if (typeof config.completeIssuer == 'function') { |
| 720 | + config.completeIssuer(promptText); |
| 721 | + } |
| 722 | + }; |
| 723 | + |
| 724 | + function showCompletion(promptText, completions) { |
| 725 | + |
| 726 | + var len = completions.length; |
| 727 | + if (len === 1) { |
| 728 | + extern.promptText(promptText + completions[0]); |
| 729 | + } else if (len > 1 && config.cols) { |
| 730 | + var prompt = promptText; |
| 731 | + // Compute the number of rows that will fit in the width |
| 732 | + var max = 0; |
| 733 | + for (var i = 0; i < len; i++) { |
| 734 | + max = Math.max(max, completions[i].length); |
| 735 | + } |
| 736 | + max += 2; |
| 737 | + var n = Math.floor(config.cols / max); |
| 738 | + var buffer = ""; |
| 739 | + var col = 0; |
| 740 | + for (i = 0; i < len; i++) { |
| 741 | + var completion = completions[i]; |
| 742 | + buffer += completions[i]; |
| 743 | + for (var j = completion.length; j < max; j++) { |
| 744 | + buffer += " "; |
| 745 | + } |
| 746 | + if (++col >= n) { |
| 747 | + buffer += "\n"; |
| 748 | + col = 0; |
| 749 | + } |
| 750 | + } |
| 751 | + commandResult(buffer, "jquery-console-message-value"); |
| 752 | + extern.promptText(prompt); |
| 753 | + } |
| 754 | + }; |
702 | 755 |
|
703 | 756 | function doNothing() {}; |
704 | 757 |
|
|
0 commit comments