** Open BUGS **
-Informal note - when using marked write to file, if there's only one
-line of text hilighted, it writes the whole rest of the ifle to disk and
-goes bonkers. Delete this message when fixed.
+Informal note - when using marked write to file, the number of lines
+written is off by one. Delete this message when fixed.
$Id$
- If the line is empty when using -k and wasn't already added,
create a dummy line and add it to the cutbuffer (fixes bug #61)
- Reset marked_cut if we blow away the cutbuffer.
+ - Moved the case of current == mark_beginbuf into cut_marked
+ segment, so do_writeout could call it when writing selection to
+ file.
do_uncut_text()
- Reset cutbuffer even if we're uncutting marked or cut to end text!
- faq.html:
{
filestruct *tmp, *next, *botcopy;
char *tmpstr;
+ int newsize;
+
+ /* Special case for cutting part of one line */
+ if (top == bot) {
+ int swap;
+
+ tmp = copy_node(top);
+ newsize = abs(bot_x - top_x) + 1;
+ tmpstr = charalloc(newsize + 1);
+
+ /* Make top_x always be before bot_x */
+ if (top_x > bot_x) {
+ swap = top_x;
+ top_x = bot_x;
+ bot_x = swap;
+ }
+
+ strncpy(tmpstr, &top->data[top_x], newsize);
+
+ if (destructive) {
+ memmove(&top->data[top_x], &top->data[bot_x],
+ strlen(&top->data[bot_x]) + 1);
+ align(&top->data);
+ current_x = top_x;
+ update_cursor();
+ }
+ tmpstr[newsize - 1] = 0;
+ tmp->data = tmpstr;
+ add_to_cutbuffer(tmp);
+ dump_buffer(cutbuffer);
+
+ return;
+ }
/* Set up the beginning of the cutbuffer */
tmp = copy_node(top);
{
filestruct *tmp, *fileptr = current;
#ifndef NANO_SMALL
- char *tmpstr;
- int newsize, cuttingtoend = 0;
+ int cuttingtoend = 0;
#endif
}
}
if (ISSET(MARK_ISSET)) {
- if (current->lineno == mark_beginbuf->lineno) {
- tmp = copy_node(current);
- newsize = abs(mark_beginx - current_x) + 1;
-
- tmpstr = charalloc(newsize + 1);
- if (current_x < mark_beginx) {
- strncpy(tmpstr, ¤t->data[current_x], newsize);
- memmove(¤t->data[current_x],
- ¤t->data[mark_beginx],
- strlen(¤t->data[mark_beginx]) + 1);
- } else {
- strncpy(tmpstr, ¤t->data[mark_beginx], newsize);
- memmove(¤t->data[mark_beginx],
- ¤t->data[current_x],
- strlen(¤t->data[current_x]) + 1);
- current_x = mark_beginx;
- update_cursor();
- }
- tmpstr[newsize - 1] = 0;
- tmp->data = tmpstr;
- add_to_cutbuffer(tmp);
- dump_buffer(cutbuffer);
- align(¤t->data);
- } else if (current->lineno < mark_beginbuf->lineno)
+ if (current->lineno <= mark_beginbuf->lineno)
cut_marked_segment(current, current_x, mark_beginbuf,
mark_beginx, 1);
else
}
while (1) {
+#ifndef NANO_SMALL
if (ISSET(MARK_ISSET) && !exiting)
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
_("%s Selection to File"), append ? _("Append") : _("Write"));
else
+#endif
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
_("File Name to %s"), append ? _("Append") : _("Write"));
filestruct *filebotbak = filebot;
filestruct *cutback = cutbuffer;
int oldmod = 0;
+ cutbuffer = NULL;
/* Okay, since write_file changes the filename, back it up */
if (ISSET(MODIFIED))
/* Now, non-destructively add the marked text to the
cutbuffer, and write the file out using the cutbuffer ;) */
- if (current->lineno < mark_beginbuf->lineno)
+ if (current->lineno <= mark_beginbuf->lineno)
cut_marked_segment(current, current_x, mark_beginbuf,
mark_beginx, 0);
else