Implemented Unjustify, HAHAHA

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@329 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2000-11-27 00:23:41 +00:00
parent 24946bd77a
commit 9149e610b3
6 changed files with 57 additions and 18 deletions

View File

@ -15,6 +15,11 @@ CVS code -
- Added call to real_name_from tilde, oops. - Added call to real_name_from tilde, oops.
read_file() read_file()
- Added check for fileptr == NULL. - 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: - es.po:
- Traditional Spanish strings updates. - Traditional Spanish strings updates.

38
nano.c
View File

@ -1669,8 +1669,8 @@ int do_justify(void)
{ {
#ifndef NANO_SMALL #ifndef NANO_SMALL
int slen = 0; /* length of combined lines on one line. */ int slen = 0; /* length of combined lines on one line. */
int initial_y; int initial_y, kbinput;
filestruct *initial = NULL; filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot;
if (empty_line(current->data)) { if (empty_line(current->data)) {
/* Justify starting at first non-empty line. */ /* Justify starting at first non-empty line. */
@ -1708,6 +1708,12 @@ int do_justify(void)
initial_y = current_y; initial_y = current_y;
set_modified(); 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. */ /* Put the whole paragraph into one big line. */
while (current->next && !isspace((int) current->next->data[0]) while (current->next && !isspace((int) current->next->data[0])
&& current->next->data[0]) { && current->next->data[0]) {
@ -1715,6 +1721,11 @@ int do_justify(void)
int len = strlen(current->data); int len = strlen(current->data);
int len2 = strlen(current->next->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. */ /* length of both strings plus space between strings and ending \0. */
current->data = nrealloc(current->data, len + len2 + 2); current->data = nrealloc(current->data, len + len2 + 2);
current->data[len++] = ' '; current->data[len++] = ' ';
@ -1779,6 +1790,7 @@ int do_justify(void)
} while ((strlenpt(current->data) > (fill)) } while ((strlenpt(current->data) > (fill))
&& !no_spaces(current->data)); && !no_spaces(current->data));
} }
tmpbot = current;
if (current->next) if (current->next)
current = current->next; current = current->next;
@ -1801,7 +1813,27 @@ int do_justify(void)
} }
edit_refresh(); 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; return 1;
#else #else
nano_small_msg(); nano_small_msg();

1
nano.h
View File

@ -212,6 +212,7 @@ know what you're doing */
#define NANO_REFRESH_KEY NANO_CONTROL_L #define NANO_REFRESH_KEY NANO_CONTROL_L
#define NANO_JUSTIFY_KEY NANO_CONTROL_J #define NANO_JUSTIFY_KEY NANO_CONTROL_J
#define NANO_JUSTIFY_FKEY KEY_F(4) #define NANO_JUSTIFY_FKEY KEY_F(4)
#define NANO_UNJUSTIFY_KEY NANO_CONTROL_U
#define NANO_UP_KEY NANO_CONTROL_P #define NANO_UP_KEY NANO_CONTROL_P
#define NANO_DOWN_KEY NANO_CONTROL_N #define NANO_DOWN_KEY NANO_CONTROL_N
#define NANO_FORWARD_KEY NANO_CONTROL_F #define NANO_FORWARD_KEY NANO_CONTROL_F

View File

@ -189,7 +189,7 @@ Usage: nano [option] +LINE <file>\n\
{"Cannot move edit win", 154}, {"Cannot move edit win", 154},
{"Cannot resize bottom win", 155}, {"Cannot resize bottom win", 155},
{"Cannot move bottom win", 156}, {"Cannot move bottom win", 156},
{"Justify Complete", 157}, {"Can now UnJustify!", 157},
{"%s enable/disable", 158}, {"%s enable/disable", 158},
{"enabled", 159}, {"enabled", 159},
{"disabled", 160}, {"disabled", 160},

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -679,56 +679,56 @@ msgstr ""
msgid "Cannot move bottom win" msgid "Cannot move bottom win"
msgstr "" msgstr ""
#: nano.c:1804 #: nano.c:1816
msgid "Justify Complete" msgid "Can now UnJustify!"
msgstr "" msgstr ""
#: nano.c:1872 #: nano.c:1904
#, c-format #, c-format
msgid "%s enable/disable" msgid "%s enable/disable"
msgstr "" msgstr ""
#: nano.c:1884 #: nano.c:1916
msgid "enabled" msgid "enabled"
msgstr "" msgstr ""
#: nano.c:1885 #: nano.c:1917
msgid "disabled" msgid "disabled"
msgstr "" msgstr ""
#: nano.c:2115 #: nano.c:2147
msgid "Main: set up windows\n" msgid "Main: set up windows\n"
msgstr "" msgstr ""
#: nano.c:2128 #: nano.c:2160
msgid "Main: bottom win\n" msgid "Main: bottom win\n"
msgstr "" msgstr ""
#: nano.c:2134 #: nano.c:2166
msgid "Main: open file\n" msgid "Main: open file\n"
msgstr "" msgstr ""
#: nano.c:2171 #: nano.c:2203
#, c-format #, c-format
msgid "I got Alt-O-%c! (%d)\n" msgid "I got Alt-O-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2193 #: nano.c:2225
#, c-format #, c-format
msgid "I got Alt-[-1-%c! (%d)\n" msgid "I got Alt-[-1-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2226 #: nano.c:2258
#, c-format #, c-format
msgid "I got Alt-[-2-%c! (%d)\n" msgid "I got Alt-[-2-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2274 #: nano.c:2306
#, c-format #, c-format
msgid "I got Alt-[-%c! (%d)\n" msgid "I got Alt-[-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2300 #: nano.c:2332
#, c-format #, c-format
msgid "I got Alt-%c! (%d)\n" msgid "I got Alt-%c! (%d)\n"
msgstr "" msgstr ""

View File

@ -131,6 +131,7 @@ void page_up_center(void);
void blank_edit(void); void blank_edit(void);
void search_init_globals(void); void search_init_globals(void);
void replace_abort(void); void replace_abort(void);
void add_to_cutbuffer(filestruct * inptr);
#ifdef NANO_EXTRA #ifdef NANO_EXTRA
void do_credits(void); void do_credits(void);
#endif #endif