Shell 0.7.4. Clipboard works. Ctrl+C copies the whole command line and Ctrl+V pastes it.

git-svn-id: svn://kolibrios.org@4516 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Albom 2014-01-23 07:41:40 +00:00
parent 10c974c8fc
commit 3e68853ae6
5 changed files with 99 additions and 14 deletions

View File

@ -1,3 +1,7 @@
Shell 0.7.4 // 23.01.2014 // Albom
* <20> ¡®â  á ¡ãä¥à®¬ ®¡¬¥­  (ª®¯¨à®¢ ­¨¥ Ctrl+C ¨ ¢áâ ¢ª  Ctrl+V áâப¨ 楫¨ª®¬)
Shell 0.7.3 // 28.11.2013 // Albom Shell 0.7.3 // 28.11.2013 // Albom
* ˆá¯à ¢«¥­  ®è¨¡ª  á ᨬ¢®«®¬ % ¢ ¨áâ®à¨¨ ª®¬ ­¤ * ˆá¯à ¢«¥­  ®è¨¡ª  á ᨬ¢®«®¬ % ¢ ¨áâ®à¨¨ ª®¬ ­¤

View File

@ -1,5 +1,5 @@
#define SHELL_VERSION "0.7.3" #define SHELL_VERSION "0.7.4"
extern char PATH[256]; extern char PATH[256];
extern char PARAM[256]; extern char PARAM[256];

View File

@ -35,6 +35,10 @@ unsigned cmdLen = 0;
unsigned cmdPos = 0; unsigned cmdPos = 0;
CMD[0] = '\0'; CMD[0] = '\0';
int clipNum; // number of clipboard slots
char* clipBuf; // clipboard buffer
char clipCopy[255+12];
for (;;) for (;;)
{ {
key = getch(); key = getch();
@ -87,6 +91,65 @@ for (;;)
break; break;
case 22: // Ctrl+V
clipNum = kol_clip_num();
if (clipNum > 0)
{
clipBuf = kol_clip_get(clipNum-1);
// printf("Length: %d, Type: %d, Encoding: %d\n", (int) *clipBuf, (int)*(clipBuf+4), (int)*(clipBuf+8));
if ( (int) *clipBuf > 0 ) // is clipboard empty?
{
if ((int)*(clipBuf+4)==0) // text?
{
if ((int)*(clipBuf+8)==1) // 866 encoding?
for (i = cmdPos; i < cmdLen; i++)
printf(" ");
for (i = cmdLen; i > 0; i--)
printf("%c %c", 8, 8);
cmdLen = 0;
cmdPos = 0;
CMD[0] = '\0';
// strcpy_n
for (i = 0; i < 255; i++)
{
CMD[i]=*(clipBuf+12+i);
if (CMD[i]=='\0')
break;
}
cmdPos = cmdLen = strlen(CMD);
/*
printf("Length: %d\n", cmdLen);
for (i = 0; i < cmdLen; i++)
printf("%d ", CMD[i]);
*/
printf("%s", CMD);
}
}
}
break;
case 3: // Ctrl+C
if ( cmdLen > 0 )
{
*clipCopy = 12 + cmdLen;
*(clipCopy+4)=0;
*(clipCopy+8)=1;
for (i = 0; i <= cmdLen; i++)
*(clipCopy+12+i) = CMD[i];
kol_clip_set(12+cmdLen, clipCopy);
}
break;
default: default:
if (cmdLen < 255) if (cmdLen < 255)
{ {
@ -96,31 +159,31 @@ for (;;)
else else
key = toupper(key); key = toupper(key);
for (i = cmdLen+1; i > cmdPos; i--) for (i = cmdLen+1; i > cmdPos; i--)
CMD[i] = CMD[i-1]; CMD[i] = CMD[i-1];
CMD[cmdPos] = key; CMD[cmdPos] = key;
for (i = cmdPos; i > 0; i--) for (i = cmdPos; i > 0; i--)
printf("%c %c", 8, 8); printf("%c %c", 8, 8);
printf("%s", CMD); printf("%s", CMD);
for (i = 0; i < cmdLen-cmdPos; i++) for (i = 0; i < cmdLen-cmdPos; i++)
printf("%c", 8); printf("%c", 8);
cmdPos++; cmdPos++;
cmdLen++; cmdLen++;
} }
break; break;
} }
} }
else else
{
key = (key>>8)&0xff;
switch (key)
{ {
key = (key>>8)&0xff;
switch (key)
{
case 83: // Del case 83: // Del
if (cmdPos < cmdLen) if (cmdPos < cmdLen)
{ {

View File

@ -421,3 +421,18 @@ void kol_buffer_close(char name[])
{ {
asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name));
} }
int kol_clip_num()
{
asm volatile ("int $0x40"::"a"(54), "b"(0));
}
char* kol_clip_get(int n)
{
asm volatile ("int $0x40"::"a"(54), "b"(1), "c"(n));
}
int kol_clip_set(int n, char buffer[])
{
asm volatile ("int $0x40"::"a"(54), "b"(2), "c"(n), "d"(buffer));
}

View File

@ -111,3 +111,6 @@ void kol_get_kernel_ver(char buff16b[]);
int kol_kill_process(unsigned process); int kol_kill_process(unsigned process);
int kol_buffer_open(char name[], int mode, int size, char **buf); int kol_buffer_open(char name[], int mode, int size, char **buf);
void kol_buffer_close(char name[]); void kol_buffer_close(char name[]);
int kol_clip_num();
char* kol_clip_get(int n);
int kol_clip_set(int n, char buffer[]);