Sunday, March 22, 2015

Digest for comp.lang.c++@googlegroups.com - 3 updates in 3 topics

"Öö Tiib" <ootiib@hot.ee>: Mar 22 12:19PM -0700

On Sunday, 22 March 2015 16:51:34 UTC+2, Bonnedav wrote:
> How do I make a console text editor in C++?
 
Standard C++ has bare minimum I/O support thru 'std::cout' and
'std::cin'. It is usually enough for a program to be executable from
other program or from script and also can be used by human directly
from console. It won't be widely popular since average human expects
down to key-press level interactive aid and hand holding that is not
doable with cout and cin. If you want to have console I/O that can
be made decent enough to that level then you have to use something
outside of C++ standard. For example try PDCurses library:
http://pdcurses.sourceforge.net/
ram@zedat.fu-berlin.de (Stefan Ram): Mar 22 07:18PM

>How do I make a console text editor in C++?
 
I have writte a console text editor for my C++ course
as an example in the lesson about reading input from
the console.
 
#include <iostream>
#include <ostream>
#include <istream>
#include <cstdlib>
 
int arg( ::std::string & s ){ return atoi( s.substr( 1 ).c_str() ); }
 
int main()
{ ::std::cout << "i1 insert \"1\"\n+1 move cursor right\n-1 "
" move cursor left\nd1 erase 1 character\n";
::std::string s{ "alpha" }, command; int pos = 0; while( 1 )
{ ::std::cout << s << '\n' << ::std::string( pos, ' ' ) << '^' << '\n';
::std::cin >> command; switch( command.at( 0 ))
{ case '+': pos += arg( command ); break;
case '-': pos -= arg( command ); break;
case 'i': s.insert( pos, command.substr( 1 )); break;
case 'e': s.erase( pos, arg( command )); break; }}}
 
A session transcript (the user input is: »+2«, »i__«, »-1«,
and »e2«, i.e., »move right by 2«, »insert "__"«, »move left«,
and »erase two characters«):
 
i1 insert "1"
+1 move cursor right
-1 move cursor left
d1 erase 1 character
alpha
^
+2
alpha
^
i__
al__pha
^
-1
al__pha
^
e2
a_pha
^
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Mar 22 07:07PM

On Sun, 22 Mar 2015 11:12:14 +0100
David Brown <david.brown@hesbynett.no> wrote:
[snip]
> three or four regulars who only post insults. (Brian beware -
> swearing /is/ allowed in s.e.d., and you will have no chance of
> stopping it.)
 
No, I just discounted the "sane radical" option as too absurd to
contemplate.
 
I believe history has proven me to be right. He has since claimed a
divine mandate for leading future C++ development efforts ('I claim
to represent the "clear vision" alternative that Scott talks about'):
 
https://groups.google.com/forum/#!topic/comp.lang.c++/5q7jqe6GPiA
 
which ridiculously overestimates his programming abilities and seems
evidence of mild mental illness and a messiah complex.
 
And he has since posted at great length that "I'm letting others know
the source of my help" which is off topic and seems designed to
undermine christian faith by making it laughable. As a christian, I
find it all quite painful.
 
Brian needs to fuck off.
 
Chris
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: