Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #509 > unrolled thread

Set/get console cursor position without use ncurses

Started by"Max" <noname@noreply.com>
First post2012-11-19 08:15 +0000
Last post2013-07-11 11:08 +0100
Articles 20 on this page of 45 — 14 participants

Back to article view | Back to comp.os.linux.development.apps


Contents

  Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-19 08:15 +0000
    Re: Set/get console cursor position without use ncurses Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2012-11-19 12:42 +0200
      Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-19 16:04 +0000
        Re: Set/get console cursor position without use ncurses Grant Edwards <invalid@invalid.invalid> - 2012-11-19 16:13 +0000
          Re: Set/get console cursor position without use ncurses Chris Cox <chrisncoxn@endlessnow.com> - 2012-11-19 15:41 -0600
            Re: Set/get console cursor position without use ncurses Grant Edwards <invalid@invalid.invalid> - 2012-11-19 22:43 +0000
              Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-20 09:28 +0000
                Re: Set/get console cursor position without use ncurses Chris Cox <chrisncoxn@endlessnow.com> - 2012-11-20 09:14 -0600
                  Re: Set/get console cursor position without use ncurses Brian Bebeau <bbebeau@computer.org> - 2012-11-21 15:56 -0500
        Re: Set/get console cursor position without use ncurses Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-11-19 09:55 -0700
          Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-20 09:31 +0000
            Re: Set/get console cursor position without use ncurses Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2012-11-20 15:17 +0200
        Re: Set/get console cursor position without use ncurses Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2012-11-19 20:24 +0200
          Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-20 09:21 +0000
            Re: Set/get console cursor position without use ncurses Chris Cox <chrisncoxn@endlessnow.com> - 2012-11-20 09:35 -0600
              Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-20 15:52 +0000
            Re: Set/get console cursor position without use ncurses Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-11-20 11:35 -0700
              Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-21 09:19 +0000
                Re: Set/get console cursor position without use ncurses Jan Panteltje <pNaonStpealmtje@yahoo.com> - 2012-11-21 09:34 +0000
                  Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-21 10:59 +0000
                    Re: Set/get console cursor position without use ncurses Jan Panteltje <pNaonStpealmtje@yahoo.com> - 2012-11-21 11:54 +0000
                    Re: Set/get console cursor position without use ncurses Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-11-21 16:43 +0000
                      Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-22 08:30 +0000
                        Re: Set/get console cursor position without use ncurses Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-11-22 13:14 +0000
                          Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-22 14:08 +0000
                            Re: Set/get console cursor position without use ncurses John Hasler <jhasler@newsguy.com> - 2012-11-22 10:06 -0600
                              Re: Set/get console cursor position without use ncurses Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-11-22 16:31 +0000
                                Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-23 09:11 +0000
                                  Re: Set/get console cursor position without use ncurses Jan Panteltje <pNaonStpealmtje@yahoo.com> - 2012-11-23 09:36 +0000
                                    Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-23 16:27 +0000
                                      Re: Set/get console cursor position without use ncurses Jan Panteltje <pNaonStpealmtje@yahoo.com> - 2012-11-23 20:13 +0000
                                  Re: Set/get console cursor position without use ncurses Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-11-23 14:54 +0000
                        Re: Set/get console cursor position without use ncurses John Hasler <jhasler@newsguy.com> - 2012-11-22 08:03 -0600
                        Re: Set/get console cursor position without use ncurses morey4857@gmail.com - 2016-08-18 22:48 -0700
                Re: Set/get console cursor position without use ncurses GangGreene <GangGreene@example.com> - 2012-11-21 07:48 -0500
                Re: Set/get console cursor position without use ncurses John Hasler <jhasler@newsguy.com> - 2012-11-21 08:24 -0600
                  Re: Set/get console cursor position without use ncurses "Max" <noname@noreply.com> - 2012-11-21 14:45 +0000
                    Re: Set/get console cursor position without use ncurses John Hasler <jhasler@newsguy.com> - 2012-11-21 11:11 -0600
                Re: Set/get console cursor position without use ncurses Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-11-21 10:20 -0700
                Re: Set/get console cursor position without use ncurses Grant Edwards <invalid@invalid.invalid> - 2012-11-21 17:23 +0000
    Re: Set/get console cursor position without use ncurses Grant Edwards <invalid@invalid.invalid> - 2012-11-19 15:38 +0000
      Re: Set/get console cursor position without use ncurses Joe Beanfish <joebeanfish@nospam.duh> - 2012-11-20 14:05 +0000
    Re: Set/get console cursor position without use ncurses Richard Kettlewell <rjk@greenend.org.uk> - 2012-11-21 11:30 +0000
    Re: Set/get console cursor position without use ncurses Ron House <rhouse@smartchat.net.au> - 2013-07-11 13:56 +1000
      Re: Set/get console cursor position without use ncurses Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-11 11:08 +0100

Page 1 of 3  [1] 2 3  Next page →


#509 — Set/get console cursor position without use ncurses

From"Max" <noname@noreply.com>
Date2012-11-19 08:15 +0000
SubjectSet/get console cursor position without use ncurses
Message-ID<k8cpre$feh$1@speranza.aioe.org>
Hi all

I'm looking for a way to get and set the cursor position in a Linux
console application (pure console, not X11 console) but without use the
function move() exported by ncurses library. I want to manage the
cursor position directly from my C application without use any
additional library. Is there a way?

Thank you for the help

-- 

[toc] | [next] | [standalone]


#510

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2012-11-19 12:42 +0200
Message-ID<k8d2f1$nf8$1@dont-email.me>
In reply to#509
On 19.11.12 10:15 , Max wrote:
> Hi all
>
> I'm looking for a way to get and set the cursor position in a Linux
> console application (pure console, not X11 console) but without use the
> function move() exported by ncurses library. I want to manage the
> cursor position directly from my C application without use any
> additional library. Is there a way?
>
> Thank you for the help



Please think twice: You're saying 'I need the services of ncurses,
but do not want to use it'. You need to code much of the functionality
of ncurses.

Basically, you have to pick the terminal capabilities, get the cursor
control codes, and using them to emit suitable control sequences.

-- 

Tauno Voipio

[toc] | [prev] | [next] | [standalone]


#512

From"Max" <noname@noreply.com>
Date2012-11-19 16:04 +0000
Message-ID<k8dlao$ju1$1@speranza.aioe.org>
In reply to#510
Tauno Voipio wrote:

> Please think twice: You're saying 'I need the services of ncurses,
> but do not want to use it'. You need to code much of the functionality
> of ncurses.

Since looking around it seem no one thought to find a way to move the
cursor without the help of ncourses move() function I used this
"standard call" as an example I need to get. ncurses have a lot of code
involving a large number af features I don't need at the moment. I
tried to check the code inside ncurses for move the cursor but it seem
really complicated (at least for me that I'm not expert in Linux
programming).

> Basically, you have to pick the terminal capabilities, get the cursor
> control codes, and using them to emit suitable control sequences.

This is the way I'm trying to follow at the moment but how is possible
to send control codes and get the reply directly to the console from C
code without have an echo in the screen? Do you know where is possible
to find an example code about?

Thank you



-- 

[toc] | [prev] | [next] | [standalone]


#513

FromGrant Edwards <invalid@invalid.invalid>
Date2012-11-19 16:13 +0000
Message-ID<k8dlrq$2c4$1@reader1.panix.com>
In reply to#512
On 2012-11-19, Max <noname@noreply.com> wrote:
> Tauno Voipio wrote:
>
>> Please think twice: You're saying 'I need the services of ncurses,
>> but do not want to use it'. You need to code much of the functionality
>> of ncurses.
>
> Since looking around it seem no one thought to find a way to move the
> cursor without the help of ncourses move()

Nonsense.

Just send the escape sequence yourself.

-- 
Grant Edwards               grant.b.edwards        Yow! BARRY ... That was
                                  at               the most HEART-WARMING
                              gmail.com            rendition of "I DID IT MY
                                                   WAY" I've ever heard!!

[toc] | [prev] | [next] | [standalone]


#516

FromChris Cox <chrisncoxn@endlessnow.com>
Date2012-11-19 15:41 -0600
Message-ID<k8e925$su9$1@speranza.aioe.org>
In reply to#513
On 11/19/2012 10:13 AM, Grant Edwards wrote:
> On 2012-11-19, Max <noname@noreply.com> wrote:
>> Tauno Voipio wrote:
>>
>>> Please think twice: You're saying 'I need the services of ncurses,
>>> but do not want to use it'. You need to code much of the functionality
>>> of ncurses.
>>
>> Since looking around it seem no one thought to find a way to move the
>> cursor without the help of ncourses move()
>
> Nonsense.
>
> Just send the escape sequence yourself.
>

Not quite right, but ok in many cases nowadays.. but the more correct answer is 
to query the capability from the current term database and use the codes that it 
wants you to use for that terminal.  That way, the implementation will be 
terminal independent.

See/man things like:

terminfo
tput
infocmp

For example, consider (from the shell):

tput clear
tput cup 5 5;echo -n Hello starting at 5,5

Now.. is that "curses"?  Well... in Linux the C terminfo calls are certainly 
part of a ncurses package... so I suppose you could say it is...




[toc] | [prev] | [next] | [standalone]


#517

FromGrant Edwards <invalid@invalid.invalid>
Date2012-11-19 22:43 +0000
Message-ID<k8ecmb$3ie$1@reader1.panix.com>
In reply to#516
On 2012-11-19, Chris Cox <chrisncoxn@endlessnow.com> wrote:
> On 11/19/2012 10:13 AM, Grant Edwards wrote:
>> On 2012-11-19, Max <noname@noreply.com> wrote:
>>> Tauno Voipio wrote:
>>>
>>>> Please think twice: You're saying 'I need the services of ncurses,
>>>> but do not want to use it'. You need to code much of the functionality
>>>> of ncurses.
>>>
>>> Since looking around it seem no one thought to find a way to move the
>>> cursor without the help of ncourses move()
>>
>> Nonsense.
>>
>> Just send the escape sequence yourself.
>
> Not quite right,

I was responding to the statement that nobody has found a way to move
the cursor without using ncurses move().

> but ok in many cases nowadays... but the more correct answer is to
> query the capability from the current term database and use the codes
> that it wants you to use for that terminal.  That way, the
> implementation will be terminal independent.

If terminal independence is a requirement, then that's definitely the
way to go.  However, the requirement was for "linux console" only.
_If_ that requirement is correct, then I doubt the linux console codes
are going to change much over the years.  They certainly haven't in
the first 20 years.  Are there any popular terminal emulators that
won't work with the ANSI cursor-movement sequence that's used by the
Linux console?

On the third hand, given that ncurses is ubiquitous and rather small,
trying to avoid it would seem to be a false economy.

-- 
Grant Edwards               grant.b.edwards        Yow! I am having FUN...
                                  at               I wonder if it's NET FUN or
                              gmail.com            GROSS FUN?

[toc] | [prev] | [next] | [standalone]


#519

From"Max" <noname@noreply.com>
Date2012-11-20 09:28 +0000
Message-ID<k8fifj$euk$1@speranza.aioe.org>
In reply to#517
Grant Edwards wrote:

> I was responding to the statement that nobody has found a way to move
> the cursor without using ncurses move().

I was referring to the fact that if I try to google search for a way to
move a cursor in the console all the reply I found concerning use
ncurses. Someone, like in this thread, suggested alternative way like
control codes but I still didn't find an example code showing better
how to properly make this operation (I'm still looking for this right
now).


-- 

[toc] | [prev] | [next] | [standalone]


#523

FromChris Cox <chrisncoxn@endlessnow.com>
Date2012-11-20 09:14 -0600
Message-ID<k8g6nl$2ca$1@speranza.aioe.org>
In reply to#519
On 11/20/2012 03:28 AM, Max wrote:
> Grant Edwards wrote:
>
>> I was responding to the statement that nobody has found a way to move
>> the cursor without using ncurses move().
>
> I was referring to the fact that if I try to google search for a way to
> move a cursor in the console all the reply I found concerning use
> ncurses. Someone, like in this thread, suggested alternative way like
> control codes but I still didn't find an example code showing better
> how to properly make this operation (I'm still looking for this right
> now).
>
>


Please reread my post folks.

No need for ncurses move.. but escape sequences... do you know them? Do you know 
them for EVERY possible terminal type out there?  No.. of course not.... so I 
was just telling you the historical way of finding out which is to query termcap 
(very old) and terminfo databases.

Sure.. you can ASSUME that every terminal is the same.. and for the most part, 
thanks to the PC, there's a lot of truth to that (as I mentioned).  But since I 
have worked on projects that aren't terribly old where that was NOT true, I just 
wanted to educate everyone on proper technique.

Code in shell was provided in my post.

man terminfo
(get the one from section 3 or 3ncurses depending)

So.. you don't have to use the ncurses move/windowing, etc.. stuff... you can 
query the terminfo database for the proper escape codes matching the current 
terminal device and use that information.  Yes.. in Linux, the terminfo database 
calls are part of ncurses... but the "ti" calls are quite low level.

Just how you do things....  there isn't another way (without error)...



[toc] | [prev] | [next] | [standalone]


#539

FromBrian Bebeau <bbebeau@computer.org>
Date2012-11-21 15:56 -0500
Message-ID<UMOdnRhCjv6U3TDNnZ2dnUVZ_t6dnZ2d@supernews.com>
In reply to#523
On 11/20/2012 10:14 AM, Chris Cox wrote:
> On 11/20/2012 03:28 AM, Max wrote:
>> Grant Edwards wrote:
>>
>>> I was responding to the statement that nobody has found a way to move
>>> the cursor without using ncurses move().
>>
>> I was referring to the fact that if I try to google search for a way to
>> move a cursor in the console all the reply I found concerning use
>> ncurses. Someone, like in this thread, suggested alternative way like
>> control codes but I still didn't find an example code showing better
>> how to properly make this operation (I'm still looking for this right
>> now).
> man terminfo
> (get the one from section 3 or 3ncurses depending)
>
> So.. you don't have to use the ncurses move/windowing, etc.. stuff...
> you can query the terminfo database for the proper escape codes matching
> the current terminal device and use that information.  Yes.. in Linux,
> the terminfo database calls are part of ncurses... but the "ti" calls
> are quite low level.

If you're worried about the performance overhead of ncurses, this is
definitely the way to go. Many years ago, I had to write a program to
talk to telephone switches. It worked well in curses, but using 20
instances of the program brought the machine to it's knees. I rewrote
it using just terminfo calls and it worked great. Look up the
curs_terminfo(3x) page for the calls. For instance, you only need to
do setupterm() instead of initscr(). You can then build up the string
you need using tgetstr() into a buffer, and only output it when you
need to using tputs(). ncurses does a lot of window refreshing, this
saves you all that until you really need it. The performance is much
improved.


[toc] | [prev] | [next] | [standalone]


#514

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2012-11-19 09:55 -0700
Message-ID<1blidxzg4h.fsf@snowball.wb.pfeifferfamily.net>
In reply to#512
"Max" <noname@noreply.com> writes:

> Tauno Voipio wrote:
>
>> Please think twice: You're saying 'I need the services of ncurses,
>> but do not want to use it'. You need to code much of the functionality
>> of ncurses.
>
> Since looking around it seem no one thought to find a way to move the
> cursor without the help of ncourses move() function I used this
> "standard call" as an example I need to get. ncurses have a lot of code
> involving a large number af features I don't need at the moment. I
> tried to check the code inside ncurses for move the cursor but it seem
> really complicated (at least for me that I'm not expert in Linux
> programming).

You can send any sequence of characters to the screen you want,
including the characters making a move happen.  You can either look up
the code in the terminal's manual, or look them up in the terminfo
database.  Using the codes for a vt100 will probably work well enough
for most terminals; of course, not all terminals use the same codes so
to be sure it'll work on any terminal you want you'll want to use
terminfo.  There's a man page documenting it.

Or you can make life easy for yourself and use ncurses.

>> Basically, you have to pick the terminal capabilities, get the cursor
>> control codes, and using them to emit suitable control sequences.
>
> This is the way I'm trying to follow at the moment but how is possible
> to send control codes and get the reply directly to the console from C
> code without have an echo in the screen? Do you know where is possible
> to find an example code about?

If you're talking about not echoing user input, there are a bunch of
ways you can turn that off.  One of them is with the termios family of
calls; again, there is a man page documenting it.

Or you can make life easy on yourself and...

[toc] | [prev] | [next] | [standalone]


#520

From"Max" <noname@noreply.com>
Date2012-11-20 09:31 +0000
Message-ID<k8filr$fjt$1@speranza.aioe.org>
In reply to#514
Joe Pfeiffer wrote:

> You can send any sequence of characters to the screen you want,
> including the characters making a move happen.  You can either look up
> the code in the terminal's manual, or look them up in the terminfo
> database.  Using the codes for a vt100 will probably work well enough
> for most terminals; of course, not all terminals use the same codes so
> to be sure it'll work on any terminal you want you'll want to use
> terminfo.  There's a man page documenting it.
> 
> Or you can make life easy for yourself and use ncurses.

Hi

I explained the reasons I would like to avoid use ncurses in another
post in thsi thread. Maybe I'm making a mistake, I'm open to every
suggestion. Anyway I understand the way you suggest and I'll try to get
more info. An example code would be very helpful, do you know where is
possible to get one?

Thank you

[toc] | [prev] | [next] | [standalone]


#521

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2012-11-20 15:17 +0200
Message-ID<k8fvsr$fcq$1@dont-email.me>
In reply to#520
On 20.11.12 11:31 , Max wrote:
> Joe Pfeiffer wrote:
>
>> You can send any sequence of characters to the screen you want,
>> including the characters making a move happen.  You can either look up
>> the code in the terminal's manual, or look them up in the terminfo
>> database.  Using the codes for a vt100 will probably work well enough
>> for most terminals; of course, not all terminals use the same codes so
>> to be sure it'll work on any terminal you want you'll want to use
>> terminfo.  There's a man page documenting it.
>>
>> Or you can make life easy for yourself and use ncurses.
>
> Hi
>
> I explained the reasons I would like to avoid use ncurses in another
> post in thsi thread. Maybe I'm making a mistake, I'm open to every
> suggestion. Anyway I understand the way you suggest and I'll try to get
> more info. An example code would be very helpful, do you know where is
> possible to get one?
>
> Thank you


Have you read <http://www.tldp.org/HOWTO/Text-Terminal-HOWTO.html>?

-- 

Tauno Voipio

[toc] | [prev] | [next] | [standalone]


#515

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2012-11-19 20:24 +0200
Message-ID<k8dth1$4bp$1@dont-email.me>
In reply to#512
On 19.11.12 6:04 , Max wrote:
> Tauno Voipio wrote:
>
>> Please think twice: You're saying 'I need the services of ncurses,
>> but do not want to use it'. You need to code much of the functionality
>> of ncurses.
>
> Since looking around it seem no one thought to find a way to move the
> cursor without the help of ncourses move() function I used this
> "standard call" as an example I need to get. ncurses have a lot of code
> involving a large number af features I don't need at the moment. I
> tried to check the code inside ncurses for move the cursor but it seem
> really complicated (at least for me that I'm not expert in Linux
> programming).
>
>> Basically, you have to pick the terminal capabilities, get the cursor
>> control codes, and using them to emit suitable control sequences.
>
> This is the way I'm trying to follow at the moment but how is possible
> to send control codes and get the reply directly to the console from C
> code without have an echo in the screen? Do you know where is possible
> to find an example code about?
>
> Thank you

Why is it undesirable to have ncurses?

It is usually a shared library, which is not too large, and
pretty probably already mapped to some process in the system
(132772 bytes in Ubuntu 12.04).

Please remember that in a demand-paged virtual memory system,
the memory allocation is in the address space of the process
only. The real RAM chips get only used when a page is accessed.
The extra functions do not load the memory capacity, except
in the file system.

-- 

Tauno Voipio

[toc] | [prev] | [next] | [standalone]


#518

From"Max" <noname@noreply.com>
Date2012-11-20 09:21 +0000
Message-ID<k8fi39$e4j$1@speranza.aioe.org>
In reply to#515
Tauno Voipio wrote:

> On 19.11.12 6:04 , Max wrote:
> > Tauno Voipio wrote:
> > 
> > > Please think twice: You're saying 'I need the services of ncurses,
> > > but do not want to use it'. You need to code much of the
> > > functionality of ncurses.
> > 
> > Since looking around it seem no one thought to find a way to move
> > the cursor without the help of ncourses move() function I used this
> > "standard call" as an example I need to get. ncurses have a lot of
> > code involving a large number af features I don't need at the
> > moment. I tried to check the code inside ncurses for move the
> > cursor but it seem really complicated (at least for me that I'm not
> > expert in Linux programming).
> > 
> > > Basically, you have to pick the terminal capabilities, get the
> > > cursor control codes, and using them to emit suitable control
> > > sequences.
> > 
> > This is the way I'm trying to follow at the moment but how is
> > possible to send control codes and get the reply directly to the
> > console from C code without have an echo in the screen? Do you know
> > where is possible to find an example code about?
> > 
> > Thank you
> 
> Why is it undesirable to have ncurses?
> 
> It is usually a shared library, which is not too large, and
> pretty probably already mapped to some process in the system
> (132772 bytes in Ubuntu 12.04).
> 
> Please remember that in a demand-paged virtual memory system,
> the memory allocation is in the address space of the process
> only. The real RAM chips get only used when a page is accessed.
> The extra functions do not load the memory capacity, except
> in the file system.

Hi

Thank you to all the the replies. I'll try to explain my requirements.
I'm developing a console application that must run under Linux, Windows
and MS-DOS. The 90% of the code is OS indipendant and the remaining 10%
is a wrapper around the specific calls of each different OS. Using this
way I can easily recompile the app just using different compiler with
properly define settings. In case of Linux this same app must be
distributed in binary format compiled for x86 and arm version. Since
the app must run in a lot of different embedded Linux distrubition
where is not possible to know if all the required shared libraries will
be present I compile tha app statically linking all the library needed
(currently only libc). The Linux native system where I work is x86
based and for make the arm version I'm currently using a toolchain. I
would like to avoid use additional libraries function, like ncurses in
this case, because, as explained, I want to have all the library
statically linked. I suppose I can get the static version of ncurses in
x86 system but this same static library compiled for arm is not present
in the toolchain. Than, suppose there is no other easy way to move
cursor out from ncurses I have two possibilities:

- Integrate the ncourses source code into my project so it will be
possible to recompile all the app and library using the compiler to x86
or arm
- Find the ncurses static library in binary format of both x86 and arm
version and integrate them in the project

Maybe I'm doing something wrong in my reasoning?

Anyway thank you again for the help

-- 

[toc] | [prev] | [next] | [standalone]


#524

FromChris Cox <chrisncoxn@endlessnow.com>
Date2012-11-20 09:35 -0600
Message-ID<k8g7v5$5g5$1@speranza.aioe.org>
In reply to#518
On 11/20/2012 03:21 AM, Max wrote:
...snip...
>
> Thank you to all the the replies. I'll try to explain my requirements.
> I'm developing a console application that must run under Linux, Windows
> and MS-DOS. The 90% of the code is OS indipendant and the remaining 10%

The Windows "terminal" is cmd... which is a weird animal.

DOS is DOS.

In neither case are there multi-terminal handling, neither Windows or DOS 
understand the idea of terminal devices.

So.. you do have to understand the limitations of the platform you are running on.

My comments about terminfo apply to true multi-user OS's like Unix/Linux and not 
to DOS/Windows.

So... IMHO, you can make assumptions about end terminal devices and assume an 
ANSI terminal (for example, and that's fairly safe)... and then you can use 
Linux to query terminfo for all of the escape codes you will need in order to 
hard code what you are wanting to do in the app.

Best assumption on the Linux side would be to run the program from a non-qui 
direct connected terminal (e.g. the "head" of the system).... in 99% of the 
cases, this will be an "Linux" terminal type, which is mostly ANSI.

If you're assuming a "console" X Windows client app.. then all bets are off and 
you're better off making the dynamic queries of terminal capabilities (through 
ncurses) to find those "escape sequences" so that things are done right.

Again, to use "escape sequences" does NOT require making curses calls... on 
Linux however, the querying of terminfo capabilities databases is done through 
low level calls current in the ncurses library.  So getting the right "escape 
sequences" for use on any X Windows terminal emulator client on Linux really 
requires getting them from the terminfo database.

Back to "DOS" for a second.  I have used many DOS applications that used the 
full SCO-ANSI set (with every shift, alt, ctrl sequence imaginable).... and let 
me just say that the terminfo database ones in Linux are NOT complete.  So I had 
to create my own (because we were running this "portable" app inside of Linux). 
  In my case, we were using the PuTTY terminal emulator ssh client from Windows, 
so I needed a full SCO-ANSI terminfo db on the Linux side where the ported DOS 
application was run from.  Again, the app need to see the full gambit of all 
possible key combinations (input is just as important as output in my case).

On a Linux system (with ncurses infocmp installed) take a look at (from bash or 
something not csh):

TERM=linux infocmp

TERM=ansi infocmp

TERM=scoansi infocmp

Then you can see the differences (well, at least for what is recorded in the 
terminfo databases) for these terminal types.

So.. you have to know your terminal in order to know everything you can or 
cannot do.  Assuming ANSI may be a "safe" answer, all depends on how much you 
need to do.

[toc] | [prev] | [next] | [standalone]


#525

From"Max" <noname@noreply.com>
Date2012-11-20 15:52 +0000
Message-ID<k8g8vv$862$1@speranza.aioe.org>
In reply to#524
Chris Cox wrote:

> The Windows "terminal" is cmd... which is a weird animal.
> 
> DOS is DOS.
> 
> In neither case are there multi-terminal handling, neither Windows or
> DOS understand the idea of terminal devices.
> 
> So.. you do have to understand the limitations of the platform you
> are running on.
> 
> My comments about terminfo apply to true multi-user OS's like
> Unix/Linux and not to DOS/Windows.

For this problem different OS have different approach. In case of DOS
is very easy since there are specific interrupt calls for move the
cursor position around the screen. Same easy solution for Windows with
specific Windows API allow to move the cursor around the terminal
screen. This code was done without problem. In this case the real
problem is Linux since it seem there isn't a direct call making this
simply work of position the cursor in a specific point (well, indeed
there is a simply call, is the move() function from ncurses under
discussion but is not native of the system and require an additional
external library).

-- 

[toc] | [prev] | [next] | [standalone]


#526

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2012-11-20 11:35 -0700
Message-ID<1bhaokyvez.fsf@snowball.wb.pfeifferfamily.net>
In reply to#518
"Max" <noname@noreply.com> writes:
>
> Thank you to all the the replies. I'll try to explain my requirements.
> I'm developing a console application that must run under Linux, Windows
> and MS-DOS. The 90% of the code is OS indipendant and the remaining 10%
> is a wrapper around the specific calls of each different OS. Using this
> way I can easily recompile the app just using different compiler with
> properly define settings. In case of Linux this same app must be
> distributed in binary format compiled for x86 and arm version. Since
> the app must run in a lot of different embedded Linux distrubition
> where is not possible to know if all the required shared libraries will
> be present I compile tha app statically linking all the library needed
> (currently only libc). The Linux native system where I work is x86
> based and for make the arm version I'm currently using a toolchain. I
> would like to avoid use additional libraries function, like ncurses in
> this case, because, as explained, I want to have all the library
> statically linked. I suppose I can get the static version of ncurses in
> x86 system but this same static library compiled for arm is not present
> in the toolchain. Than, suppose there is no other easy way to move
> cursor out from ncurses I have two possibilities:
>
> - Integrate the ncourses source code into my project so it will be
> possible to recompile all the app and library using the compiler to x86
> or arm
> - Find the ncurses static library in binary format of both x86 and arm
> version and integrate them in the project
>
> Maybe I'm doing something wrong in my reasoning?
>
> Anyway thank you again for the help

If you want to target both linux and DOS, ncurses moves from being the
right way to do it to being *really* the right way to do it.  At worst,
for linux, you need to bundle a version of ncurses with your
application.  For DOS, it turns out there is a library called PDCurses
which works pretty much the same way (according to wikipedia, anyway --
I've never used it, unlike ncurses).  Any platform-dependency you need
to insert in your code will be an order of magnitude easier if it's
between two similar libraries instead of between a platform that comes
close to emulating a terminal and one that's Completely Different.

[toc] | [prev] | [next] | [standalone]


#527

From"Max" <noname@noreply.com>
Date2012-11-21 09:19 +0000
Message-ID<k8i6at$pdu$1@speranza.aioe.org>
In reply to#526
Joe Pfeiffer wrote:

> If you want to target both linux and DOS, ncurses moves from being the
> right way to do it to being really the right way to do it.  At worst,
> for linux, you need to bundle a version of ncurses with your
> application.  For DOS, it turns out there is a library called PDCurses
> which works pretty much the same way (according to wikipedia, anyway
> -- I've never used it, unlike ncurses).  Any platform-dependency you
> need to insert in your code will be an order of magnitude easier if
> it's between two similar libraries instead of between a platform that
> comes close to emulating a terminal and one that's Completely
> Different.

As replied in another post of this same thread there is no need of
ncurses (or similar libraries) functionalities under DOS or Windows.
All the function for easily move the cursor position and a lot of other
graphic functions are available through interrupt calls (DOS) or direct
API calls (Windows). Under Linux it seem ncurses is the only way to get
easily what in other OS is natively available without additional
efforts or libraries...


-- 

[toc] | [prev] | [next] | [standalone]


#528

FromJan Panteltje <pNaonStpealmtje@yahoo.com>
Date2012-11-21 09:34 +0000
Message-ID<k8i776$nqo$1@news.albasani.net>
In reply to#527
On a sunny day (Wed, 21 Nov 2012 09:19:25 +0000 (UTC)) it happened "Max"
<noname@noreply.com> wrote in <k8i6at$pdu$1@speranza.aioe.org>:

>As replied in another post of this same thread there is no need of
>ncurses (or similar libraries) functionalities under DOS or Windows.
>All the function for easily move the cursor position and a lot of other
>graphic functions are available through interrupt calls (DOS) or direct
>API calls (Windows). Under Linux it seem ncurses is the only way to get
>easily what in other OS is natively available without additional
>efforts or libraries...

MS DOS is a memory limited piece of shit, and long dead.
MS windows is an ever repeating attempt to write new ever worse versions of an OS to extract money from its victims.
You should REALLY not support either of that anti human crap.
Microsoft is pretty much dead anyways, I guess even to the totally ignorant
users selling feature limited crap over and over again must have been noticed.
So much for your 'no additional effort and libraries' statement.

Be glad there IS ncurses, or learn to use the terminal control codes,
or even better learn how to write a decent GUI or a command line program
that does not need cursor jingling.
Its easy.
Dropping support for MS crap will give you time to learn that, and optimize your Linux design.

[toc] | [prev] | [next] | [standalone]


#529

From"Max" <noname@noreply.com>
Date2012-11-21 10:59 +0000
Message-ID<k8ic5t$a8n$1@speranza.aioe.org>
In reply to#528
Jan Panteltje wrote:

Warning, your reply risk to start a flame that I don't want to join in. 

If you are one of the "classic" Linux user that think Linux is the only
one OS star in the world and all other OS are shit is your problem but
the reality is not as you think. I'll reply you ONCE just for show my
think but I'll don't reply to any other post out of the current problem
discussion anymore.

So, let's start...

> MS DOS is a memory limited piece of shit, and long dead.

MS-DOS is dead for standard users but is quite still live for companies
making embedded hardware since can be booted easily from an USB key (I
know Linux too, just for prevent your reply), can run with a very
limited quantity of memory and allow to easily have access to memory
(high memory using extension like DOS32), IO port, PCI and so on. The
only "limitation" is it can work only in x86 system but is very useful
in a lot of occasions.

> MS windows is an ever repeating attempt to write new ever worse
> versions of an OS to extract money from its victims.  You should
> REALLY not support either of that anti human crap.  Microsoft is
> pretty much dead anyways, I guess even to the totally ignorant users
> selling feature limited crap over and over again must have been
> noticed.  So much for your 'no additional effort and libraries'
> statement.

"Ignorant users" as you call normal people are the same people who only
need to use a computer without face problem like kernel configuration,
recomiling libraries, fight with all the problem Linux give with driver
of each device you try to connect and so on. The list of very long. I
know very well people like you, sice I have some friend who think
exactly the same. Maybe you are a Linux expert and all these problems I
listed are "normal". You know how to fix them so no problem at all. But
normal people can PAY for have a stable system that don't give a lot of
troubles without all the problem below. I don't say Windows doesn't
have problems or is the perfect OS but compared from linux have a
characteristic and is fundamentals and in called STANDARDS. I can run
on Windows 7 a software developed from Windows 2000 whithout problems
in the majority of cases. Do you think the possibility to run in the
last Linux version a software compiled for a Linux distrubution older
more than 10 years are very high? I don't think so. Yes, you can
recompile but also in this case I don't think you could have success
without apply patches (supposign someone made them), updating libraries
and so on. In your mind you don't consider these as problem but in the
reality these ARE problems. In my work I develop software for both
Windows a Linux. I can appreciate some positive feature of Linux but I
prefer Windows for the reasons I explained above. I'm sure you don't
agree but I don't care.

> Be glad there IS ncurses, or learn to use the terminal control codes,

I should be glad because someone invented this strange and quite
complex ways for make the same operation I can have with few lines of
native code in other OS?

> or even better learn how to write a decent GUI or a command line
> program that does not need cursor jingling.

You are a little strung? Since you don't know nothing about the
application I need to develop you have no right to criticize my choices.
Just for your information I need to show some binary data in the screen
and refresh continuously the current value of them. The solution is
usually used in this case is to print the data, reposition the cursor
at the beginning and reprint again the new data for cover the old one.
I'm open to any suggestion, if you have a better idea, please, explain
me.

> Dropping support for MS crap will give you time to learn that, and
> optimize your Linux design.

As already said in the beginning of this post this will be my only
reply about this argument. You can throw your anger as you like but, as
already said, I don't care.

Bye


-- 

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.os.linux.development.apps


csiph-web