aspell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[aspell-devel] [PATCH] word-wrap not working on the last lines


From: Eric Piel
Subject: [aspell-devel] [PATCH] word-wrap not working on the last lines
Date: Mon, 28 Mar 2005 20:15:54 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050322)

Hello,

In the current version of aspell the word-wrap doesn't work correctly for the last lines displayed on the screen. You can notice this with the attached text. If your terminal is not huge you'll notice that the lines of the last third of the screen are only displayed partially, with their last character displayed instead of "\".

The following patch solves this issue. It's against the CVS of today (20050328). The effective modification is only on the "while". There are two other minors corrections: - correctly display the words which are longer that the screen width (you can check this by setting the terminal width to 10 chars)
 - remove the new_line calls which doesn't have any effect

Concerning this last point, I wonder if I've overlooked something, is this a workaround to fix some versions of ncurse? At least with my libncurses 5.4, it doesn't change anything. Probably new_line(int,int) could be removed too.


Hoping that you like the patch and apply it,
Regards
Eric

PS: sorry, I'm not subscribed to the mailing list, please CC in case of reply.
--- prog/check_funs.cpp.bak     2005-03-28 18:45:08.000000000 +0200
+++ prog/check_funs.cpp 2005-03-28 19:50:28.000000000 +0200
@@ -514,9 +514,6 @@ void display_misspelled_word() {
     }
     if (i.off_end()) ++i;
 
-    while (l != 0)
-      new_line(l,height);
-
     l = -1;
 
     const char * j = i->begin();
@@ -530,14 +527,20 @@ void display_misspelled_word() {
 
       wattrset(text_w,A_NORMAL);
       int last_space_pos = 0;
-      const char * last_space = i->begin();
+      const char * last_space = j;
 
       // NOTE: Combining characters after a character at the very end of
       //   a line will cause an unnecessary word wrap.  Unfortunately I
       //   do not know how to avoid it as they is no portable way to
       //   find out if the next character will combine with the
       //   previous.
-      while (j < i->end() && x0 <= x && *j != '\n')
+
+      // We check that:
+      // - we haven't reached the end of the text
+      // - we haven't reached the end of the line
+      // - curse haven't jumped to the next screen line
+      // - curse haven't reached the end of the screen
+      while (j < i->end() && *j != '\n' && y0 == y && x0 < width - 1)
       {
         if (asc_isspace(*j)) {
           last_space_pos = x;
@@ -565,6 +568,8 @@ void display_misspelled_word() {
         ++i;
         j = i->begin();
       } else {
+        if ((last_space_pos == 0) && (y < height - 1))
+          continue;
         if (x - last_space_pos < width/3) {
           wmove(text_w, y, last_space_pos);
           wclrtoeol(text_w);
@@ -579,9 +584,6 @@ void display_misspelled_word() {
       new_line(l,y,height);
     }
 
-    while (l != 0)
-      new_line(l,height);
-      
     wnoutrefresh(text_w);
 
   } else if (use_curses && !text_w) {


2 - The New Rock



Late that night, Moon-Watcher suddenly awoke. Tired out by the day's exertions 
and disasters, he had been sleeping more soundly than usual, yet he was 
instantly alert at the first faint scrabbling down in the valley.

He sat up in the fetid darkness of the cave, straining his senses out into the 
night, and fear crept slowly into his soul. Never in his life - already twice 
as long as most members of his species could expect - had he heard a sound like 
this. The great cats approached in silence, and the only thing that betrayed 
them was a rare slide of earth, or the occasional cracking of a twig. Yet this  
was a continuous crunching noise, that grew steadily louder. It seemed that 
some enormous beast was moving through the night, making no attempt at 
concealment, and ignoring all obstacles. Once Moon-Watcher heard the 
unmistakable sound of a bush, being uprooted; the elephants and dinotheria did 
this often enough, but otherwise they moved as silently as the cats.

And then there came a sound which Moon-Watcher could not possibly have 
identified, for it had never been heard before in the history of the world. It 
was the clank of metal upon stone.

Moon-Watcher came face to face with the New Rock when he led the tribe down to 
the river in the first light of morning. He had almost forgotten the terrors of 
the night, because nothing had happened after that initial noise, so he did not 
even associate this strange thing with danger or with fear. There was, after 
all, nothing in the least alarming about it.

It was a rectangular slab, three times his height but narrow enough to span 
with his arms, and it was made of some completely transparent material; indeed, 
it was not easy to see except when the rising sun glinted on its edges. As 
Moon-Watcher had never encountered ice, or even crystal-clear water, there were 
no natural objects to which he could compare this apparition. It was certainly 
rather attractive, and though he was wisely cautious of most new things, he did 
not hesitate for long before sidling up to it. As nothing happened, he put out 
his hand, and felt a cold, hard surface.

After several minutes of intense thought, he arrived at a brilliant 
explanation. It was a rock, of course, and it must have grown during the night. 
There were many plants that did this - white, pulpy things shaped like pebbles, 
that seemed to shoot up during the hours of darkness. It was true that they 
were small and round, whereas this was large and sharp-edged; but greater and 
later philosophers than Moon-Watcher would be prepared to overlook equally 
striking exceptions to their theories.

This really superb piece of abstract thinking led Moon-Watcher, after only 
three or four minutes, to a deduction which he immediately put to the test. The 
white round pebble-plants were very tasty (though there were a few that 
produced violent illness); perhaps this tall one...?

A few licks and attempted nibbles quickly disillusioned him. There was no 
nourishment here; so like a sensible man-ape, he continued on his way to the 
river and forgot all about the crystalline monolith, during the daily routine 
of shrieking at the Others. 

The foraging today was very bad, and the tribe had to travel several miles from 
the caves to find any food at all. During the merciless heat of noon one of the 
frailer females collapsed, far from any possible shelter. Her companions 
gathered round her, twittering and meeping sympathetically, but there was 
nothing that anyone could do. If they had been less exhausted they might have 
carried her with them, but there was no surplus energy for such acts of 
kindness. She had to be left behind, to recover or not with her own resources. 
They passed the spot on the homeward trek that evening; there was not a bone to 
be seen.

In the last light of day, looking round anxiously for early hunters, they drank 
hastily at the stream and started the climb up to their caves. They were still 
a hundred yards from the New Rock when the sound began.

It was barely audible, yet it stopped them dead, so that they stood paralyzed 
on the trail with their jaws hanging slackly. A simple, maddeningly repetitious 
vibration, it pulsed out from the crystal; and hypnotized all who came within 
its spell. For the first time - and the last, for three million years - the 
sound of drumming was heard in Africa.

The throbbing grew louder, more insistent. Presently the man-apes began to move 
forward, like sleepwalkers, toward the source of that compulsive sound. 
Sometimes they took little dancing steps, as their blood responded to rhythms 
that their descendants would not create for ages yet. Totally entranced, they 
gathered round the monolith, forgetting the hardships of the day, the perils of 
the approaching dusk, and the hunger in their bellies.

The drumming became louder, the night darker. And as the shadows lengthened and 
the light drained from the sky, the crystal began to glow.

First it lost its transparency, and became suffused with a pale, milky 
luminescence, Tantalizing, ill-defined phantoms moved across its surface and in 
its depths. They coalesced into bars of light and shadow, then formed 
intermeshing, spoked patterns that began slowly to rotate.

Faster and faster spun the wheels of light, and the throbbing of the drums 
accelerated with them. Now utterly hypnotized, the man-apes could only stare 
slack-jawed into this astonishing display of pyrotechnics. They had already 
forgotten the instincts of their forefathers and the lessons of a lifetime; not 
one of them, ordinarily, would have been so far from his cave, so late in the 
evening. For the surrounding brush was full of frozen shapes and staring eyes, 
as the creatures of the night suspended their business to see what would happen 
next.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]