Marquee implementation in C

P

praveen

Hi,

I want to scroll the text horizontally up to maximum of 50 characters
without using widgets.
How can i scroll the text ?
Give code snippet for this marquee implementation using C.

Thanks&Regards,
Rahul.
 
I

Ian Collins

praveen said:
Hi,

I want to scroll the text horizontally up to maximum of 50 characters
without using widgets.

This isn't the place to ask, try a group dedicated to your operating system.
 
S

santosh

Ian said:
Although I guess you could simply use puts in a loop.

I don't think it's possible without some dependence on implementation
defined behaviour. The easiest solution would be use some similar to
curses.
 
K

Keith Thompson

santosh said:
I don't think it's possible without some dependence on implementation
defined behaviour. The easiest solution would be use some similar to
curses.

It can be done if the carriage return character behaves as specified.
But I'm unwilling to do the OP's homework for him.
 
S

santosh

Keith said:
It can be done if the carriage return character behaves as specified.
But I'm unwilling to do the OP's homework for him.

Since that behaviour is unspecified the program, correct me if I'm
wrong, would depend on implementation specified behavior.

Also the OP has not specified exactly what he means by "scroll."
 
K

Keith Thompson

santosh said:
Since that behaviour is unspecified the program, correct me if I'm
wrong, would depend on implementation specified behavior.

C99 5.2.2p2 "Character display semantics":

Alphabetic escape sequences representing nongraphic characters in
the execution character set are intended to produce actions on
display devices as follows:

...

\r (carriage return) Moves the active position to the initial
position of the current line.

The weasel wording "are intended to" allows for considerable
variation, of course. For example, most of the terminal emulators I
use ignore the form feed character.
Also the OP has not specified exactly what he means by "scroll."

True.
 
M

Martin Wells

This isn't the place to ask, try a group dedicated to your operating system.


#define WIDGET_USAGE 0

#define MAX_SCROLL_CHAR 50

#include <stdio.h>

void Scroll(char const *str)
{
while (*str++)
{
puts(stdin,getsInLen(), MAX_SCROLL_CHAR);
}
}


Make sure you define "MAX_SCROLL_CHAR" before you include stdio.h.

Martin
 
C

Coos Haak

Op Sun, 07 Oct 2007 15:37:54 -0700 schreef Martin Wells:
#define WIDGET_USAGE 0

#define MAX_SCROLL_CHAR 50

#include <stdio.h>

void Scroll(char const *str)
{
while (*str++)
{
puts(stdin,getsInLen(), MAX_SCROLL_CHAR);
}
}


Make sure you define "MAX_SCROLL_CHAR" before you include stdio.h.
How did you learn C, from the Dead C scrolls perhaps ;-(
 
C

Christopher Benson-Manica

I don't think it's possible without some dependence on implementation
defined behaviour. The easiest solution would be use some similar to
curses.

Obviously curses is probably the "right" answer, but one could hack
together something standard that might meet the letter of the
requirements, assuming knowledge of the number of columns and lines on
the terminal window and busy waiting to moderate the screen "redraw"
rate.
 
D

David Thompson

It can be done if the carriage return character behaves as specified.
But I'm unwilling to do the OP's homework for him.

If CR behaves as sortof-almost-specified, AND 'overwriting' a line
works as you apparently expect but which is not even suggested by the
Standard. On some, formerly common, devices it can't. On modern
bitmapped displays it would be reasonable to ior the bitmaps to
simulate traditional over_printing_. It would be legal to xor the
bitmaps, and I think I might even come up with a plausible rationale
to do so. It would even be legal to combine the two character _codes_
and use the result as a single new extended code, probably
Unicode/10646 assuming the narrow codes are ASCII or ASCII-like.

And if one doesn't want 'continous' aka 'gradual' scrolling, nor
scrolling at a rate (or rates) more precise than the
implementation-dependent approximation of time() et al.

And if the output (device) supports sufficiently long lines, here 50
characters, which similarly is only sortof-almost-specified.

- formerly david.thompson1 || achar(64) || worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top