diff --git a/ChangeLog b/ChangeLog index f1b3a305..fb589e18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,11 @@ CVS code - - Added call to real_name_from tilde, oops. read_file() - Added check for fileptr == NULL. +- nano.c: + do_justify() + - Wrote unjustify code. Borrows cutbuffer and stores the unjustified text there, + then grabs the next keystroke and, if the unjustify key, gets rid of the + justified text and calls do_uncut_text. Added macro NANO_UNJUSTIFY_KEY. - es.po: - Traditional Spanish strings updates. diff --git a/nano.c b/nano.c index c1c6244c..10b3789a 100644 --- a/nano.c +++ b/nano.c @@ -1669,8 +1669,8 @@ int do_justify(void) { #ifndef NANO_SMALL int slen = 0; /* length of combined lines on one line. */ - int initial_y; - filestruct *initial = NULL; + int initial_y, kbinput; + filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot; if (empty_line(current->data)) { /* Justify starting at first non-empty line. */ @@ -1708,6 +1708,12 @@ int do_justify(void) initial_y = current_y; set_modified(); + cutbak = cutbuffer; /* Got to like cutbak ;) */ + cutbuffer = NULL; + + tmptop = current; + tmpjust = copy_node(current); + add_to_cutbuffer(tmpjust); /* Put the whole paragraph into one big line. */ while (current->next && !isspace((int) current->next->data[0]) && current->next->data[0]) { @@ -1715,6 +1721,11 @@ int do_justify(void) int len = strlen(current->data); int len2 = strlen(current->next->data); + tmpjust = NULL; + fprintf(stderr, "I see no X here\n"); + tmpjust = copy_node(current->next); + add_to_cutbuffer(tmpjust); + /* length of both strings plus space between strings and ending \0. */ current->data = nrealloc(current->data, len + len2 + 2); current->data[len++] = ' '; @@ -1779,6 +1790,7 @@ int do_justify(void) } while ((strlenpt(current->data) > (fill)) && !no_spaces(current->data)); } + tmpbot = current; if (current->next) current = current->next; @@ -1801,7 +1813,27 @@ int do_justify(void) } edit_refresh(); - statusbar(_("Justify Complete")); + statusbar(_("Can now UnJustify!")); + reset_cursor(); + + /* Now get a keystroke and see if it's unjustify, if not unget the keytreoke + and return */ + if ((kbinput = wgetch(edit)) != NANO_UNJUSTIFY_KEY) + ungetch(kbinput); + else { + /* Else restore the justify we just did (ungrateful user!) */ + if (tmptop->prev != NULL) + tmptop->prev->next = tmpbot->next; + tmpbot->next->prev = tmptop->prev; + current = tmpbot->next; + tmpbot->next = NULL; + do_uncut_text(); + free_filestruct(tmptop); + blank_statusbar_refresh(); + } + free_filestruct(cutbuffer); + cutbuffer = cutbak; + return 1; #else nano_small_msg(); diff --git a/nano.h b/nano.h index 72bbf395..378c7024 100644 --- a/nano.h +++ b/nano.h @@ -212,6 +212,7 @@ know what you're doing */ #define NANO_REFRESH_KEY NANO_CONTROL_L #define NANO_JUSTIFY_KEY NANO_CONTROL_J #define NANO_JUSTIFY_FKEY KEY_F(4) +#define NANO_UNJUSTIFY_KEY NANO_CONTROL_U #define NANO_UP_KEY NANO_CONTROL_P #define NANO_DOWN_KEY NANO_CONTROL_N #define NANO_FORWARD_KEY NANO_CONTROL_F diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c index 8c5dc149..c3f58406 100644 --- a/po/cat-id-tbl.c +++ b/po/cat-id-tbl.c @@ -189,7 +189,7 @@ Usage: nano [option] +LINE \n\ {"Cannot move edit win", 154}, {"Cannot resize bottom win", 155}, {"Cannot move bottom win", 156}, - {"Justify Complete", 157}, + {"Can now UnJustify!", 157}, {"%s enable/disable", 158}, {"enabled", 159}, {"disabled", 160}, diff --git a/po/nano.pot b/po/nano.pot index a4389ee6..02c087ab 100644 --- a/po/nano.pot +++ b/po/nano.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-11-25 21:08-0500\n" +"POT-Creation-Date: 2000-11-26 19:23-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -679,56 +679,56 @@ msgstr "" msgid "Cannot move bottom win" msgstr "" -#: nano.c:1804 -msgid "Justify Complete" +#: nano.c:1816 +msgid "Can now UnJustify!" msgstr "" -#: nano.c:1872 +#: nano.c:1904 #, c-format msgid "%s enable/disable" msgstr "" -#: nano.c:1884 +#: nano.c:1916 msgid "enabled" msgstr "" -#: nano.c:1885 +#: nano.c:1917 msgid "disabled" msgstr "" -#: nano.c:2115 +#: nano.c:2147 msgid "Main: set up windows\n" msgstr "" -#: nano.c:2128 +#: nano.c:2160 msgid "Main: bottom win\n" msgstr "" -#: nano.c:2134 +#: nano.c:2166 msgid "Main: open file\n" msgstr "" -#: nano.c:2171 +#: nano.c:2203 #, c-format msgid "I got Alt-O-%c! (%d)\n" msgstr "" -#: nano.c:2193 +#: nano.c:2225 #, c-format msgid "I got Alt-[-1-%c! (%d)\n" msgstr "" -#: nano.c:2226 +#: nano.c:2258 #, c-format msgid "I got Alt-[-2-%c! (%d)\n" msgstr "" -#: nano.c:2274 +#: nano.c:2306 #, c-format msgid "I got Alt-[-%c! (%d)\n" msgstr "" -#: nano.c:2300 +#: nano.c:2332 #, c-format msgid "I got Alt-%c! (%d)\n" msgstr "" diff --git a/proto.h b/proto.h index 921505d9..cb35492d 100644 --- a/proto.h +++ b/proto.h @@ -131,6 +131,7 @@ void page_up_center(void); void blank_edit(void); void search_init_globals(void); void replace_abort(void); +void add_to_cutbuffer(filestruct * inptr); #ifdef NANO_EXTRA void do_credits(void); #endif