怎样在字符界面下进行复制和粘帖

怎样在字符界面下进行复制和粘帖

很多时候需要把一些命令的输出粘帖到论坛上来,请问怎样把字符终端的内容复制到图形界面中???
点一下右键
启动gpm服务
一般来说,你先highlight你要拷贝的,然后到这点鼠标中键, 也就是那个滚轮.
[quote:600f62f916="superbaby"]点一下右键[/quote]
[quote:600f62f916="wusong-2005"]一般来说,你先highlight你要拷贝的,然后到这点鼠标中键, 也就是那个滚轮.[/quote]

楼主说的是字符终端的内容,应该不是简单的用鼠标吧?
[quote:1badeb2ae6="cnhnln"]启动gpm服务[/quote]
这个看来还象一点,不过以前没有接触过,看下面:

gpm是Linux console下的滑鼠驱动程式,它主要提供文字模式下的滑鼠事件处理。Linux下文字界面的滑鼠几乎都是用gpm来处理。
gpm的文件在gpm原始码的doc目录中,详细的说明可参考该目录中的文件gpm programming guide,此处只提供给您KickStart的一些技巧及一些参考说明。

特别注意到以下的例,需在console下执行,不可在X Window的 Terminal下执行。



--------------------------------------------------------------------------------

例 : gpm_mouse.c
gpm原始码中有一个mev.c的程式,主要用来测试滑鼠状态。事实上,mev.c是个很好的例,本例便是取自mev.c,经过简化修改而来。[code:1]
#include  
#include  
#include  
#include  

void main(int argc,char **argv)
{
  fd_set readset;
  Gpm_Event event;
  Gpm_Connect conn;

  conn.eventMask   = ~0;
  conn.defaultMask = ~GPM_HARD;
  conn.maxMod      = 0;
  conn.minMod      = 0;

  if (Gpm_Open(&conn,0)==-1) {
    printf("Can not open mouse connection\n");
    exit(1);
  }

  while (1) {

    FD_ZERO(&readset);
    FD_SET(gpm_fd,&readset);
    select(gpm_fd+1,&readset,0,0,0);

    if (FD_ISSET(gpm_fd,&readset)) {
      if (Gpm_GetEvent(&event)>0) {
        printf("mouse: event 0x%02X, at %2i %2i (delta %2i %2i),"
               "button %i, modifiers 0x%02X\r\n",
               event.type,
               event.x,event.y,
               event.dx,event.dy,
               event.buttons,
               event.modifiers
              );
      }
    }
  }

  while (Gpm_Close());

}
[/code:1]
编译[code:1]
gcc -o gpm_mouse gpm_mouse.c -lgpm [/code:1]
检验结果[code:1]
mouse: event 0x01, at 15  1 (delta -2 -1),button 0, modifiers 0x00
mouse: event 0x01, at 14  1 (delta -1  0),button 0, modifiers 0x00
mouse: event 0x01, at 13  1 (delta -1  0),button 0, modifiers 0x00
[/code:1]
--------------------------------------------------------------------------------

资料结构[code:1]
typedef struct Gpm_Connect {
  unsigned short eventMask, defaultMask;
  unsigned short minMod, maxMod;
  int pid;
  int vc;
}              Gpm_Connect;
enum Gpm_Etype {
  GPM_MOVE=1,
  GPM_DRAG=2,   /* exactly one of the bare ones is active at a time */
  GPM_DOWN=4,
  GPM_UP=  8,

  GPM_SINGLE=16,            /* at most one in three is set */
  GPM_DOUBLE=32,
  GPM_TRIPLE=64,            /* WARNING: I depend on the values */

  GPM_MFLAG=128,            /* motion during click? */
  GPM_HARD=256,             /* if set in the defaultMask, force an already  used event to pass over to another handler */

  GPM_ENTER=512,            /* enter event, user in Roi's */
  GPM_LEAVE=1024            /* leave event, used in Roi's */
};

typedef struct Gpm_Event {
  unsigned char buttons, modifiers;  /* try to be a multiple of 4 */
  unsigned short vc;
  short dx, dy, x, y;
  enum Gpm_Etype type;
  int clicks;
  enum Gpm_Margin margin;
}              Gpm_Event;

typedef int Gpm_Handler(Gpm_Event *event, void *clientdata);
[/code:1]
函数宣告[code:1]
int Gpm_Open(Gpm_Connect * CONN, int FLAGS);
int Gpm_Close(void);
int Gpm_GetEvent(Gpm_Event * EVENT);
int Gpm_Getc(FILE * fp);
#define    Gpm_Getchar() Gpm_Getc(stdin)
int Gpm_Wgetch();
#define Gpm_Getch() (Gpm_Wgetch(NULL))
int Gpm_Repeat (int millisecs);
int Gpm_DrawPointer (int X, int Y, int FD);
int GPM_DRAWPOINTER (Gpm_Event *EPTR;)
int Gpm_FitValuesM (int *X, int *Y, int MARGIN);
int Gpm_FitValues (X,Y);
Gpm_FitEvent (EPTR);
char *Gpm_GetLibVersion (int *where);
char *Gpm_GetServerVersion (int *where);
int Gpm_GetSnapshot (Gpm_Event *ePtr);  [/code:1]