From owner-freebsd-questions Sat Sep 30 13: 7:18 2000 Delivered-To: freebsd-questions@freebsd.org Received: from osiris.ipform.ru (osiris.ipform.ru [212.158.165.98]) by hub.freebsd.org (Postfix) with ESMTP id EBF2F37B502; Sat, 30 Sep 2000 13:07:04 -0700 (PDT) Received: from wp2 (wp2 [192.168.0.12]) by osiris.ipform.ru (8.11.0/8.11.0) with SMTP id e8UK72R99549; Sun, 1 Oct 2000 00:07:03 +0400 (MSD) (envelope-from matrix@ipform.ru) Message-ID: <021301c02b19$ffebe3c0$0c00a8c0@ipform.ru> From: "Artem Koutchine" To: Cc: Subject: Patch for ee (multi line cut/paste) Date: Sun, 1 Oct 2000 00:06:58 +0400 Organization: IP Form MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_020F_01C02B3B.841AFD40" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. ------=_NextPart_000_020F_01C02B3B.841AFD40 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit I have made a light patch for ee which enables it to support cutting and pasting blocks of text. It is a bit like emacs cut and paste, when you cut a line it is added to a lifo buffer and when you paste full content of the buffer is pasted into the text. The buffer is not cleared ever, so there is a key shortcut for clearing the buffer. I have also left the old mode as it is and added an option to the setting menu which turns new mode on/off. Strings are added also (only for english file). I also, attached ctrl-s to SAVE_FILE and ctrl-q to clear_clipboard, modified help texts. Diff for ee.c and diff for english messages are attached to this message. I really would like you to make it official, since it really make like easier when editing file where a lot fo copy-paste needed. I don't know who to contact, so i sent this message to questions, author of ee and the person who last time edited ee in FreeBSD distribution. diff against: ee.c FreeBSD: /src/usr.bin/ee/ee.c,v 1.16.2.1 2000/07/20 10:35:16 en_US.ISO_8859-1/ee.msg FreeBSD: src/usr.bin/ee/nls/en_US.USO_8859-1/ee.msg,v 1.6 1999/10/18 16:30:35 Regards, Artem ------=_NextPart_000_020F_01C02B3B.841AFD40 Content-Type: application/octet-stream; name="ee.c.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ee.c.diff" 186a187=0A= > int cut_mode =3D FALSE; /* line cut mode: 0 - classical, 1 - = clipboard */=0A= 198a200,202=0A= > struct text **clipboard =3D NULL; /* clipboard for deleted = lines */=0A= > int clip_size =3D0; /* current clopboard size = */=0A= > =0A= 337a342,344=0A= > void cut_into_clipboard P_((void));=0A= > void paste_from_clipboard P_((void));=0A= > void clear_clipboard P_((void));=0A= 353a361=0A= > {"", NULL, NULL, NULL, NULL, -1}, =0A= 358c366=0A= < char *mode_strings[10]; =0A= ---=0A= > char *mode_strings[11]; =0A= 360c368=0A= < #define NUM_MODES_ITEMS 9=0A= ---=0A= > #define NUM_MODES_ITEMS 10=0A= 431c439=0A= < char *init_strings[20];=0A= ---=0A= > char *init_strings[22];=0A= 521a530,531=0A= > char *LIFOB_string;=0A= > char *NOLIFOB_string;=0A= 528a539,544=0A= > char *clipboard_cut;=0A= > char *clipboard_paste;=0A= > char *clipboard_clear;=0A= > char *clipboard_nocut;=0A= > char *clipboard_empty;=0A= > =0A= 1177,1178c1193,1197=0A= < else if (in =3D=3D 17) /* control q */=0A= < ;=0A= ---=0A= > else if (in =3D=3D 17){ /* control q */=0A= > /* file_op(SAVE_FILE); */=0A= > /* quit(0); */=0A= > clear_clipboard(); =0A= > }=0A= 1182c1201=0A= < ;=0A= ---=0A= > file_op(SAVE_FILE);=0A= 1194c1213,1216=0A= < del_line();=0A= ---=0A= > if (!cut_mode)=0A= > del_line();=0A= > else=0A= > cut_into_clipboard();=0A= 1196c1218,1221=0A= < undel_line();=0A= ---=0A= > if (!cut_mode)=0A= > undel_line();=0A= > else=0A= > paste_from_clipboard();=0A= 1235c1260,1263=0A= < del_line();=0A= ---=0A= > if (!cut_mode)=0A= > del_line();=0A= > else=0A= > cut_into_clipboard();=0A= 1237c1265,1269=0A= < undel_line();=0A= ---=0A= > if (!cut_mode)=0A= > undel_line();=0A= > else=0A= > paste_from_clipboard();=0A= > =0A= 1477c1509,1513=0A= < del_line();=0A= ---=0A= > if (!cut_mode)=0A= > del_line();=0A= > else=0A= > cut_into_clipboard();=0A= > =0A= 1494c1530,1533=0A= < undel_line();=0A= ---=0A= > if (!cut_mode)=0A= > undel_line();=0A= > else=0A= > paste_from_clipboard();=0A= 2777a2817,2945=0A= > /*=0A= > Added by Artem Koutchine matrix@chat.ru 2000/09/30=0A= > Cuts text from cursor to the end of line and add it to the=0A= > internal clipboard as new line, so the whole clipboard can be inserted=0A= > later. It works a bit different from emacs is that way that the=0A= > clipboard must be cleared manually=0A= > */=0A= > =0A= > void=0A= > cut_into_clipboard()=0A= > {=0A= > char *dl1;=0A= > char *dl2;=0A= > int tposit;=0A= > =0A= > /* do not cut this line if length is 0 and no next line */=0A= > if (!curr_line->line[0] && !curr_line->next_line){=0A= > wmove(com_win, 0, 0);=0A= > werase(com_win);=0A= > wprintw(com_win, clipboard_nocut);=0A= > wrefresh(com_win);=0A= > return;=0A= > }=0A= > =0A= > /* allocate array item for pointer to deleted line */=0A= > clip_size++;=0A= > clipboard =3D realloc(clipboard,clip_size*sizeof(int));=0A= > /* allocate space for the deleted line info*/=0A= > clipboard[clip_size-1]=3Dmalloc(sizeof(struct text));=0A= > /* allocate space for the line itself */=0A= > clipboard[clip_size-1]->line=3Dmalloc(curr_line->line_length);=0A= > dl1 =3D clipboard[clip_size-1]->line;=0A= > dl2 =3D point;=0A= > tposit =3D position;=0A= > while (tposit < curr_line->line_length)=0A= > {=0A= > *dl1 =3D *dl2;=0A= > dl1++;=0A= > dl2++;=0A= > tposit++;=0A= > }=0A= > clipboard[clip_size-1]->line_length =3D 1 + tposit - position;=0A= > *dl1 =3D (char) NULL;=0A= > *point =3D (char) NULL;=0A= > curr_line->line_length =3D position;=0A= > wclrtoeol(text_win);=0A= > if (curr_line->next_line !=3D NULL)=0A= > {=0A= > right(FALSE);=0A= > delete(FALSE);=0A= > }=0A= > =0A= > wmove(com_win, 0, 0);=0A= > werase(com_win);=0A= > wprintw(com_win, clipboard_cut, clip_size);=0A= > wrefresh(com_win);=0A= > text_changes =3D TRUE;=0A= > }=0A= > =0A= > =0A= > /*=0A= > Added by Artem Koutchine matrix@chat.ru 2000/09/30=0A= > Paste all lines stored in clipboard. Leave clipboard as it is.=0A= > */=0A= > void =0A= > paste_from_clipboard()=0A= > {=0A= > char *ud1;=0A= > char *ud2;=0A= > int tposit;=0A= > int i;=0A= > if (clip_size<1){=0A= > wmove(com_win, 0, 0);=0A= > werase(com_win);=0A= > wprintw(com_win, clipboard_empty, clip_size);=0A= > wrefresh(com_win);=0A= > text_changes =3D TRUE;=0A= > return;=0A= > }=0A= > =0A= > for (i=3Dclip_size-1;i>-1;i--){=0A= > insert_line(TRUE);=0A= > left(TRUE);=0A= > point =3D resiz_line(clipboard[i]->line_length, curr_line, position);=0A= > curr_line->line_length +=3D clipboard[i]->line_length - 1;=0A= > ud1 =3D point;=0A= > ud2 =3D clipboard[i]->line;=0A= > tposit =3D 1;=0A= > while (tposit < clipboard[i]->line_length)=0A= > {=0A= > tposit++;=0A= > *ud1 =3D *ud2;=0A= > ud1++;=0A= > ud2++;=0A= > }=0A= > *ud1 =3D (char) NULL;=0A= > draw_line(scr_vert, scr_horz,point,position,curr_line->line_length);=0A= > }=0A= > wmove(com_win, 0, 0);=0A= > werase(com_win);=0A= > wprintw(com_win, clipboard_paste, clip_size);=0A= > wrefresh(com_win);=0A= > text_changes =3D TRUE;=0A= > }=0A= > =0A= > void=0A= > clear_clipboard()=0A= > {=0A= > int i;=0A= > if (clip_size>0){=0A= > for (i=3D0;i if (clipboard[i] !=3D NULL && clipboard[i]->line !=3D NULL)=0A= > free(clipboard[i]->line);=0A= > if (clipboard[i] !=3D NULL)=0A= > free(clipboard[i]);=0A= > }=0A= > if (clipboard !=3D NULL){=0A= > free(clipboard);=0A= > clipboard=3DNULL;=0A= > }=0A= > =0A= > clip_size=3D0;=0A= > }=0A= > wmove(com_win, 0, 0);=0A= > werase(com_win);=0A= > wprintw(com_win, clipboard_clear, clip_size);=0A= > wrefresh(com_win);=0A= > }=0A= > =0A= 4064a4233,4236=0A= > else if (compare(str1, LIFOB_string, FALSE))=0A= > cut_mode =3D TRUE;=0A= > else if (compare(str1, NOLIFOB_string, FALSE))=0A= > cut_mode =3D FALSE;=0A= 4163a4336=0A= > fprintf(init_file, "%s\n", cut_mode ? LIFOB_string : NOLIFOB_string );=0A= 4587c4760,4762=0A= < right_margin);=0A= ---=0A= > right_margin);=0A= > sprintf(modes_menu[9].item_string, "%s %s", mode_strings[9], =0A= > (cut_mode ? ON : OFF));=0A= 4623c4798=0A= < case 8:=0A= ---=0A= > case 8:=0A= 4632a4808,4811=0A= > case 9:=0A= > cut_mode =3D !cut_mode;=0A= > break;=0A= > =0A= 4915c5094=0A= < help_text[9] =3D catgetlocal( 44, "^[ (escape) menu ESC-Enter: = exit ee ");=0A= ---=0A= > help_text[9] =3D catgetlocal( 44, "^[ (escape) menu ^q clear = lifo buffer ESC-Enter: exit ee ");=0A= 5052c5231=0A= < modes_menu[9].item_string =3D catgetlocal( 164, "save editor = configuration");=0A= ---=0A= > modes_menu[10].item_string =3D catgetlocal( 164, "save editor = configuration");=0A= 5062a5242,5250=0A= > clipboard_cut =3D catgetlocal( 183, "Clipboard size: %d line(s)");=0A= > clipboard_paste =3D catgetlocal ( 184, "%d line(s) inserted from = clipboard");=0A= > clipboard_clear =3D catgetlocal ( 185, "Clipboard cleared");=0A= > clipboard_nocut =3D catgetlocal ( 186, "Nothing to cut (maybe lf on = the last line?)");=0A= > mode_strings[9] =3D catgetlocal( 187, "lifo clipboard "); =0A= > LIFOB_string =3D catgetlocal( 188, "LIFOBUFFER");=0A= > NOLIFOB_string =3D catgetlocal( 189, "NOLIFOBUFFER");=0A= > clipboard_empty =3D catgetlocal ( 190, "Clipboard is empty");=0A= > =0A= 5112c5300,5302=0A= < init_strings[19] =3D NULL;=0A= ---=0A= > init_strings[19] =3D LIFOB_string;=0A= > init_strings[20] =3D NOLIFOB_string;=0A= > init_strings[21] =3D NULL;=0A= ------=_NextPart_000_020F_01C02B3B.841AFD40 Content-Type: application/octet-stream; name="ee.msg.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ee.msg.diff" 53c53=0A= < 44 "^[ (escape) menu ESC-Enter: exit ee = "=0A= ---=0A= > 44 "^[ (escape) menu ^q clear lifp buffer ESC-Enter: exit ee = "=0A= 182a183,190=0A= > 183 "Clipboard size: %d line(s)"=0A= > 184 "%d line(s) inserted from clipboard"=0A= > 185 "Clipboard cleared"=0A= > 186 "Nothing to cut (maybe lf on the last line?)"=0A= > 187 "lifo clipboard "=0A= > 188 "LIFOBUFFER"=0A= > 189 "NOLIFOBUFFER"=0A= > 190 "Clipboard is empty"=0A= ------=_NextPart_000_020F_01C02B3B.841AFD40-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message