From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 31 Jul 2001 08:48:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 31 Jul 2001 08:48:03 -0400 Received: from lila.inti.gov.ar ([200.10.161.32]:9096 "EHLO lila.inti.gov.ar") by vger.kernel.org with ESMTP id ; Tue, 31 Jul 2001 08:47:54 -0400 Message-ID: <3B66A90D.789A90A8@inti.gov.ar> Date: Tue, 31 Jul 2001 09:48:13 -0300 From: salvador Reply-To: salvador@inti.gov.ar Organization: INTI X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i686) X-Accept-Language: es-AR, en, es MIME-Version: 1.0 To: linux-kernel@vger.kernel.org, alan@lxorguk.ukuu.org.uk Subject: [RFC] Get selection to buffer addition Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Original-Recipient: rfc822;linux-kernel-outgoing Hi all: What I'm looking for: I'm looking for comments and approval for a small addition to the console driver (drivers/char/console.c). Small description: The included patches adds a couple of new services to the TIOCLINUX ioctl call, they are: 13 (get selection into a buffer): It copies the contents of the selection buffer (maintained in kernel space) into a user space provided buffer. Is something like "paste to a buffer" instead of just paste to the current console. 14 (get selection length): Returns the length of the selection buffer (0 if none selected). ----------- The included file (compressed and uuencoded) contains diffs that apply without offsets into 2.4.7 kernel, they are valid for 2.2.18 too (with offset). I also include a simple test program that calls the new services. The test program is really simple and assumes you can open /dev/tty1 (you are there or you are root ;-) Additional question: Why the switch uses numbers? Shouldn't these values be defined as something like TIOCLINUX_GET_SELECTION in a header? What's the purpose? Just allow pasting in text editors using menues or without the mouse middle button and avoiding to missinterpret the pasted text as keystrokes. SET begin 664 patchConsole-2.4.7.txt.gz M'XL("/K,83L"`W!A=&-H0V]N'0`E57?C]HX$'Z&OV*D MOA!"0F!9V++M'JM3M^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,LN'&3I?*Z/(D<5+WSCE(\D.-_G[[YF5<)```` ` end ------------------------------------------- Test program: #include #include #include #include #include int main(int argc, char *argv[]) { int i,res,fd,largo; char buffer[sizeof(unsigned int)+2],*s; unsigned int *lg=(unsigned int *)(buffer+1); fd=open("/dev/tty1",O_RDWR); printf("Finding the length of the selection:\n"); buffer[0]=14; res=ioctl(fd,TIOCLINUX,&buffer); printf("The iotcl returns %d\n",res); printf("Length: %u\n",*lg); largo=*lg; if (*lg==0) return 0; printf("Asking for the selection:\n"); s=(char *)malloc(largo+sizeof(unsigned int)+2); s[0]=13; lg=(unsigned int *)(s+1); *lg=largo; res=ioctl(fd,TIOCLINUX,s); printf("The iotcl returns %d\n",res); largo=*lg; printf("Length returned: %d\n",largo); s+=1+sizeof(unsigned int); s[largo]=0; for (i=0; s[i]; i++) if (s[i]==13) s[i]=10; printf("Selection: '%s' (%d)\n",s,s[0]); return 0; } -- Salvador Eduardo Tropea (SET). (Electronics Engineer) Visit my home page: http://welcome.to/SetSoft or http://www.geocities.com/SiliconValley/Vista/6552/ Alternative e-mail: set-soft@bigfoot.com set@computer.org set@ieee.org Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013