473,657 Members | 2,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

disable putchar line-wrapping?

Hello!

When I use putchar to fill up an entire screen (of 80x25) with text, it
seems to leave an empty line at the end, thus forcing me to scroll
upwards in to see the first line. This forces me to repositioning the
cursor to the first line, which costs computer power. I know the loss is
negligible, but it's more a matter of principle: how to prevent this
line-wrapping behaviour?

--

Cheers,

John den Haan
joDhn[dot]haEan[at]chLello[dot]nl

Remove capital 'DEL' from above addy to obtain e-mail address
Feb 18 '07 #1
7 2436
John den Haan wrote:
Hello!

When I use putchar to fill up an entire screen (of 80x25) with text, it
seems to leave an empty line at the end, thus forcing me to scroll
upwards in to see the first line. This forces me to repositioning the
cursor to the first line, which costs computer power. I know the loss is
negligible, but it's more a matter of principle: how to prevent this
line-wrapping behaviour?
In standard C, it's simply not possible, sorry. A newsgroup for your
specific system may be able to give a system-specific answer.

Feb 18 '07 #2
Harald van Dijk schreef:
John den Haan wrote:
>Hello!

When I use putchar to fill up an entire screen (of 80x25) with text, it
seems to leave an empty line at the end, thus forcing me to scroll
upwards in to see the first line. This forces me to repositioning the
cursor to the first line, which costs computer power. I know the loss is
negligible, but it's more a matter of principle: how to prevent this
line-wrapping behaviour?

In standard C, it's simply not possible, sorry. A newsgroup for your
specific system may be able to give a system-specific answer.
Does C offer alternatives to putchar that do not wrap?

--

Cheers,

John den Haan
joDhn[dot]haEan[at]chLello[dot]nl

Remove capital 'DEL' from above addy to obtain e-mail address
Feb 18 '07 #3
John den Haan wrote:
Harald van Dijk schreef:
>John den Haan wrote:
>>Hello!

When I use putchar to fill up an entire screen (of 80x25) with text, it
seems to leave an empty line at the end, thus forcing me to scroll
upwards in to see the first line. This forces me to repositioning the
cursor to the first line, which costs computer power. I know the loss is
negligible, but it's more a matter of principle: how to prevent this
line-wrapping behaviour?


In standard C, it's simply not possible, sorry. A newsgroup for your
specific system may be able to give a system-specific answer.

Does C offer alternatives to putchar that do not wrap?
Standard C does not provide a means to determine the properties of the
standard output. You have to use an platform specific library.

--
Ian Collins.
Feb 18 '07 #4
In article <d7************ *************** @news.chello.nl >,
John den Haan <no****@nospam. comwrote:
>Does C offer alternatives to putchar that do not wrap?
It isn't putchar() that is doing the wrapping: it is the terminal
emulation layer that the text is being displayed on to. There might
or might not be a way to control the wrapping behaviour of that
emulation layer, but if there is, then it is specific to that emulation
layer and not part of C. You'll probably find there are different
terminal emulation behaviours for different products even for the same OS,
so this really isn't something we can answer here.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Feb 18 '07 #5
John den Haan <no****@nospam. comwrites:
When I use putchar to fill up an entire screen (of 80x25) with text,
it seems to leave an empty line at the end, thus forcing me to scroll
upwards in to see the first line. This forces me to repositioning the
cursor to the first line, which costs computer power. I know the loss
is negligible, but it's more a matter of principle: how to prevent
this line-wrapping behaviour?
You didn't tell us *how* you use putchar to fill up the screen.

Do you write a newline character at the end of each of the 25 lines?
If so, on a typical display, the last newline will naturally cause the
disply to scroll up, leaving the cursor at the beginning of a blank
line.

If you print characters without a terminating newline, you should call
fflush(stdout) to ensure that they're displayed. (But some displays
may not be able to display a character in the lower right corner.)

Details of how displays work are target-specific, but we'll be glad to
help with any C issues.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 18 '07 #6
Keith Thompson wrote:
John den Haan <no****@nospam. comwrites:
>When I use putchar to fill up an entire screen (of 80x25) with text,
it seems to leave an empty line at the end, thus forcing me to scroll
upwards in to see the first line. This forces me to repositioning the
cursor to the first line, which costs computer power. I know the loss
is negligible, but it's more a matter of principle: how to prevent
this line-wrapping behaviour?

You didn't tell us *how* you use putchar to fill up the screen.

Do you write a newline character at the end of each of the 25 lines?
If so, on a typical display, the last newline will naturally cause the
disply to scroll up, leaving the cursor at the beginning of a blank
line.

If you print characters without a terminating newline, you should call
fflush(stdout) to ensure that they're displayed. (But some displays
may not be able to display a character in the lower right corner.)

Details of how displays work are target-specific, but we'll be glad to
help with any C issues.
Whew. At last a sane answer to the query. But remember that
fflush only flushes the C system buffers - there may be (on poor
implementations ) further op-system buffers to flush.

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Feb 19 '07 #7
>When I use putchar to fill up an entire screen (of 80x25) with text, it
>seems to leave an empty line at the end, thus forcing me to scroll
upwards in to see the first line. This forces me to repositioning the
cursor to the first line, which costs computer power.
Your posting probably used millions of times more than the picowatt
required to do that.
>I know the loss is
negligible, but it's more a matter of principle: how to prevent this
line-wrapping behaviour?
C doesn't guarantee that you have a screen, or that it will scroll
(ASR-33 Teletype anyone?).

For some terminals and/or terminal emulations, writing the character
at the bottom right of the screen scrolls the screen, and there's
not anything you can do about it. Sometimes there's a mode you can
turn on or off which makes it either scroll or wrap to the upper
left corner.

In the implementation of some versions of curses, and for some terminals,
you can set the bottom-right character using the following ugly hack:
(1) move the cursor to one left of the bottom-right character
(Direct cursor positioning if you've got it)
(2) write the character you want at the bottom-right there
(yes, this is one space off)
(3) move the cursor to one left of the bottom-right character
(same place as (1); often a cursor-left sequence will work)
(4) send a sequence to enable insert-character mode
(5) write the character you want to the left of the bottom-right there
This moves the character that was there one to the right.
(6) send a sequence to disable insert-character mode

Note that in order to change the bottom-right character, you have
to know what you want in the character to the left of it. No, you
can't depend on reading the screen, especially if the user is busy
entering data on the keyboard. Since curses keeps an image of how
it wants the whole screen to look anyway, this is not a problem.

Curses can use this sort of hack when necessary without the user
of curses having to deal with it.

Feb 19 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
3286
by: MasonC | last post by:
I find I cannot disable javascript in MSIE 6 I've Help'd, Google'd, and searched here to no avail. <noscript> You don't have javascript enabled </noscript> will not display for me. Mason C
10
6550
by: Craig | last post by:
I'm a beginner with JS. When I try to disable JavaScript in IE6, I can't seem to turn it off in order to do off-line tests -- with or without JS enabled -- on my developing site. What I try in IE is: Tools => Internet Options => Security => Custom Level => Scripting => Active Scripting (disable). When I do this, and visit sites on-line, JS is disabled. And I can disable JS in NN, Moz and Opera (and use the <noscript> </noscript>...
5
4398
by: Confused User | last post by:
I am working on device that utilizes a Motorola 68HC16 microcontroller. I am using an old unsupported piece of crap Whitesmith's / Intermetrics / Tasking compiler. The embedded compiler business was quite insestual for while wasn't it? I need to write putchar so that printf can function properly. Anyway, the compiler comes with just a shell of a putchar routine. It literally returns the character you passed to it and nothing else. That is...
1
11262
by: Philip Bondi | last post by:
Hello to all SQL Server junkies who work with non-English characters: For people running scripts from the command line using ANSI files with special characters, it is very important to use isql and disable "Automatic ANSI to OEM conversion": - This only affects isql from the command line, and no gui applications - http://support.microsoft.com/?scid=kb;EN-US;153449 - Start the "Client Network Utility" C:\WINDOWS\system32\cliconfg.exe
5
6051
by: Ike | last post by:
Does anyone know how to disable a list box element in VB 6 ? Thanks Ike
19
9879
by: RedDevilDan | last post by:
I am working on a Memory Footprint Reduction project. I came across an idea to disable all printf statements so that less memory is required. In addition, when there is no single printf statement, the printf library will not be linked, so it further reduces the executable size. Is there an easy way to disable printf in a large project? In my project, we have thousands of C & C++ files. They don't have a common included common header. ...
1
10687
by: martin paul | last post by:
Sir please consider the following question and code. 1) printing a integer variable 'a' having value less than 1000. putchar( (a/100) + ' 0 ' ); a=a%100; putchar( (a/10) + ' 0 ' ); a=a%10; putchar(a + ' 0 ' ); Could you please explain the above. Thank you.
37
5039
by: Vince C. | last post by:
Hi all. I've installed Bloodshed Dev-C++ on a Windows 2000 SP4 machine. I'm using MinGW 3.4.2. I'd like to temporarily disable standard functions to write to stderr, i.e. for instance redirect stderr to a temporary file (or /dev/null but is there an equivalent under Windows? Is it "nul:") and then to *restore* the default stderr so that standard library functions that write to stderr produce output again.
8
3697
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? ----------------------------------------------------------------------- The oncontextmenu intrinsic event is the only safe and reliable method. Of the other approaches often presented, most depend on an alert box interrupting the process and rarely work. Note that oncontextmenu is a non-standard event and is not...
9
4086
by: anon.asdf | last post by:
In terms of efficieny: Is it better to use multiple putchar()'s after one another as one gets to new char's OR is it better to collect the characters to a char-array first, and then use puts() to print to screen ????
0
8385
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.