mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:45:50 +00:00
4nt's CTRL-D and CRTL-K support
svn path=/trunk/; revision=843
This commit is contained in:
parent
5d99e9003a
commit
dbf662da37
3 changed files with 83 additions and 8 deletions
|
@ -245,10 +245,11 @@ INT cmd_goto (LPTSTR, LPTSTR);
|
||||||
|
|
||||||
/* Prototypes for HISTORY.C */
|
/* Prototypes for HISTORY.C */
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
VOID History (INT, LPTSTR);
|
VOID History (INT, LPTSTR);/*add entries browse history*/
|
||||||
VOID History_move_to_bottom(VOID);
|
VOID History_move_to_bottom(VOID);/*F3*/
|
||||||
VOID InitHistory(VOID);
|
VOID InitHistory(VOID);
|
||||||
VOID CleanHistory(VOID);
|
VOID CleanHistory(VOID);
|
||||||
|
VOID History_del_current_entry(LPTSTR str);/*CTRL-D*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -131,11 +131,11 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
{
|
{
|
||||||
SHORT orgx; /* origin x/y */
|
SHORT orgx; /* origin x/y */
|
||||||
SHORT orgy;
|
SHORT orgy;
|
||||||
SHORT curx;
|
SHORT curx; /*current x/y cursor position*/
|
||||||
SHORT cury;
|
SHORT cury;
|
||||||
INT count;
|
INT count; /*used in some for loops*/
|
||||||
INT current = 0;
|
INT current = 0; /*the position of the cursor in the string (str)*/
|
||||||
INT charcount = 0;
|
INT charcount = 0;/*chars in the string (str)*/
|
||||||
INPUT_RECORD ir;
|
INPUT_RECORD ir;
|
||||||
WORD wLastKey = 0;
|
WORD wLastKey = 0;
|
||||||
TCHAR ch;
|
TCHAR ch;
|
||||||
|
@ -302,10 +302,13 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
ClearCommandLine (str, maxlen, orgx, orgy);
|
ClearCommandLine (str, maxlen, orgx, orgy);
|
||||||
current = charcount = 0;
|
current = charcount = 0;
|
||||||
break;
|
break;
|
||||||
#ifdef FEATURE_HISTORY
|
|
||||||
case VK_F3:
|
case VK_F3:
|
||||||
|
#ifdef FEATURE_HISTORY
|
||||||
History_move_to_bottom();
|
History_move_to_bottom();
|
||||||
|
#endif
|
||||||
case VK_UP:
|
case VK_UP:
|
||||||
|
#ifdef FEATURE_HISTORY
|
||||||
/* get previous command from buffer */
|
/* get previous command from buffer */
|
||||||
ClearCommandLine (str, maxlen, orgx, orgy);
|
ClearCommandLine (str, maxlen, orgx, orgy);
|
||||||
History (-1, str);
|
History (-1, str);
|
||||||
|
@ -356,6 +359,42 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef FEATURE_HISTORY
|
||||||
|
|
||||||
|
/*!!!WARNING!!!*/
|
||||||
|
/*this will only work as long as the two if statement
|
||||||
|
evaluates the same expression and a break is included
|
||||||
|
in each if statement.
|
||||||
|
This can be used for any combination using CTRL.
|
||||||
|
For other combinations is needed another system*/
|
||||||
|
|
||||||
|
//case VK_K:
|
||||||
|
case 'K':
|
||||||
|
/*add the current command line to the history*/
|
||||||
|
if (ir.Event.KeyEvent.dwControlKeyState &
|
||||||
|
(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (str[0])
|
||||||
|
History(0,str);
|
||||||
|
|
||||||
|
ClearCommandLine (str, maxlen, orgx, orgy);
|
||||||
|
current = charcount = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
if (ir.Event.KeyEvent.dwControlKeyState &
|
||||||
|
(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
|
||||||
|
{
|
||||||
|
ClearCommandLine (str, maxlen, orgx, orgy);
|
||||||
|
History_del_current_entry(str);
|
||||||
|
current = charcount = _tcslen (str);
|
||||||
|
ConOutPrintf (_T("%s"), str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
ch = ir.Event.KeyEvent.uChar.UnicodeChar;
|
ch = ir.Event.KeyEvent.uChar.UnicodeChar;
|
||||||
|
|
|
@ -78,6 +78,7 @@ VOID InitHistory(VOID);
|
||||||
VOID History_move_to_bottom(VOID);
|
VOID History_move_to_bottom(VOID);
|
||||||
VOID History (INT dir, LPTSTR commandline);
|
VOID History (INT dir, LPTSTR commandline);
|
||||||
VOID CleanHistory(VOID);
|
VOID CleanHistory(VOID);
|
||||||
|
VOID History_del_current_entry(LPTSTR str);
|
||||||
|
|
||||||
/*service functions*/
|
/*service functions*/
|
||||||
VOID del(LPHIST_ENTRY item);
|
VOID del(LPHIST_ENTRY item);
|
||||||
|
@ -121,12 +122,44 @@ VOID CleanHistory(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID History_del_current_entry(LPTSTR str)
|
||||||
|
{
|
||||||
|
LPHIST_ENTRY tmp;
|
||||||
|
|
||||||
|
if (size==0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(curr_ptr==Bottom)
|
||||||
|
curr_ptr=Bottom->next;
|
||||||
|
|
||||||
|
if(curr_ptr==Top)
|
||||||
|
curr_ptr=Top->prev;
|
||||||
|
|
||||||
|
|
||||||
|
tmp=curr_ptr;
|
||||||
|
curr_ptr=curr_ptr->prev;
|
||||||
|
del(tmp);
|
||||||
|
History(-1,str);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID del(LPHIST_ENTRY item)
|
VOID del(LPHIST_ENTRY item)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(item==NULL)
|
if( item==NULL || item==Top || item==Bottom )
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DebugPrintf("del in " __FILE__ ": retrning\n"
|
||||||
|
"item is 0x%08x (Bottom is0x%08x)\n",
|
||||||
|
item, Bottom);
|
||||||
|
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*free string's mem*/
|
/*free string's mem*/
|
||||||
if (item->string)
|
if (item->string)
|
||||||
|
@ -134,6 +167,8 @@ VOID del(LPHIST_ENTRY item)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*set links in prev and next item*/
|
/*set links in prev and next item*/
|
||||||
item->next->prev=item->prev;
|
item->next->prev=item->prev;
|
||||||
item->prev->next=item->next;
|
item->prev->next=item->next;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue