Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ console text editor.

103 views
Skip to first unread message

Bonnedav

unread,
Mar 22, 2015, 10:51:34 AM3/22/15
to
How do I make a console text editor in C++?

Barry Schwarz

unread,
Mar 22, 2015, 11:25:18 AM3/22/15
to
On Sun, 22 Mar 2015 07:51:06 -0700 (PDT), Bonnedav
<bonn...@gmail.com> wrote:

>How do I make a console text editor in C++?

Create a comprehensive unambiguous set of requirements.

Analyze as many different options that could satisfy those
requirements that you can think of.

Select the option for each requirement that best seems to suit your
intent.

Carefully design the software (data, user interface, program flow,
error handling, etc) that implements each option.

Code the software following the design.

Test the software.

For each problem detected, determine whether it is a coding error, a
design error, the wrong option, an undesirable requirement, etc and go
back to the previous step corresponding to that determination.

When you are all done, sit back and bask in the joy of accomplishment.

--
Remove del for email

Bonnedav

unread,
Mar 22, 2015, 11:32:46 AM3/22/15
to
On Sunday, March 22, 2015 at 8:51:34 AM UTC-6, Bonnedav wrote:
> How do I make a console text editor in C++?

Wow ok. I just want to make a simple text editor for my database program.
And by database I mean a folder with a bunch of files in it, each one being an entry.

Christian Gollwitzer

unread,
Mar 22, 2015, 12:33:08 PM3/22/15
to
Am 22.03.15 um 16:32 schrieb Bonnedav:
Forget it, it's a seriously complex task. Instead, call an external
program. On Unix, typically the environment variable EDITOR or VISUAL is
set. If so, invoke that tool. If nothing is set, invoke vi. If that does
not work, write an error.


Christian

Christian Gollwitzer

unread,
Mar 22, 2015, 12:34:32 PM3/22/15
to
Am 22.03.15 um 17:32 schrieb Christian Gollwitzer:
> Forget it, it's a seriously complex task. Instead, call an external
> program. On Unix, typically the environment variable EDITOR or VISUAL is
> set. If so, invoke that tool. If nothing is set, invoke vi. If that does
> not work, write an error.

PS: PLease reply to the message that you are replying to. Your message
showed up as a reply to your own mesage, not to Barry's answer.

>
> Christian
>

Johannes Bauer

unread,
Mar 22, 2015, 1:16:21 PM3/22/15
to
On 22.03.2015 17:34, Christian Gollwitzer wrote:

> PS: PLease reply to the message that you are replying to. Your message
> showed up as a reply to your own mesage, not to Barry's answer.

Oh the irony.

Cheers,
JOhannes

--
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1...@speranza.aioe.org>

Paavo Helde

unread,
Mar 22, 2015, 1:31:36 PM3/22/15
to
Bonnedav <bonn...@gmail.com> wrote in
news:9ff66538-18a9-4ba3...@googlegroups.com:

> On Sunday, March 22, 2015 at 8:51:34 AM UTC-6, Bonnedav wrote:
>> How do I make a console text editor in C++?

There are no builtin tools for that in standard C++. Tasks like this are
usually done by GUI frameworks like Qt or wxWidgets. However these are
for real GUI programs so do not meet your "console" requirement.

> Wow ok. I just want to make a simple text editor for my database
> program. And by database I mean a folder with a bunch of files in it,
> each one being an entry.

These requirements are totally different than "make a console text editor
in C++". I would just suggest launching an external editor for each file
you want to modify.

The next option would be to use some framework for console UI
programmings. I recall vaguely these were popular about 20 years ago,
maybe there is something which can be used also now. This would give
provide more control over the behavior than just launching external
editors.

Finally, you can code your own console text editor, with or without
helper libraries like ncurses. Beware this is a major project which would
distract you from the database project for several months or years.

hth
Paavo


Christian Gollwitzer

unread,
Mar 22, 2015, 1:56:58 PM3/22/15
to
Am 22.03.15 um 18:16 schrieb Johannes Bauer:
> On 22.03.2015 17:34, Christian Gollwitzer wrote:
>
>> PS: PLease reply to the message that you are replying to. Your message
>> showed up as a reply to your own mesage, not to Barry's answer.
>
> Oh the irony.

I use to put additions/corrections as an answer of my own post, to make
that clear - do you consider this wrong?

Christian

Melzzzzz

unread,
Mar 22, 2015, 2:51:52 PM3/22/15
to
On Sun, 22 Mar 2015 07:51:06 -0700 (PDT)
Bonnedav <bonn...@gmail.com> wrote:

> How do I make a console text editor in C++?

Write line editor for a start ;)

Message has been deleted

Öö Tiib

unread,
Mar 22, 2015, 3:19:22 PM3/22/15
to
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/


Message has been deleted

Bonnedav

unread,
Mar 23, 2015, 3:56:31 AM3/23/15
to
On Sunday, March 22, 2015 at 8:51:34 AM UTC-6, Bonnedav wrote:
> How do I make a console text editor in C++?

This is a windows project.

Robert Wessel

unread,
Mar 23, 2015, 4:20:45 AM3/23/15
to
On Mon, 23 Mar 2015 00:53:12 -0700 (PDT), Bonnedav
<bonn...@gmail.com> wrote:
>How do i do it on windows?


Invoke notepad?

Bonnedav

unread,
Mar 23, 2015, 4:39:59 AM3/23/15
to
On Sunday, March 22, 2015 at 8:51:34 AM UTC-6, Bonnedav wrote:
> How do I make a console text editor in C++?

in console no gui programs.

Christian Gollwitzer

unread,
Mar 23, 2015, 5:12:52 AM3/23/15
to
Am 23.03.15 um 08:53 schrieb Bonnedav:
> On Sunday, March 22, 2015 at 10:33:08 AM UTC-6, Christian Gollwitzer wrote:
>> On Unix, typically the environment variable EDITOR or VISUAL is
>> set. If so, invoke that tool. If nothing is set, invoke vi. If that does
>> not work, write an error.
>>
>
> How do i do it on windows?
>

Do you insist, that the editor itself also does not open a GUI window?
32 bit Windows comes with a console editor, which you get by invoking
"edit". Just try it on the command line first to see it. However, 64 bit
versions of Windows do not ship this tool, as Windows generally expects
for user interaction that you show a GUI window. You have several
options, you can run the application linked to .txt files. This is done,
for instance, by "start something.txt", usually you invoke "cmd /c start
something.txt". Or you can run Notepad, which is guaranteed to exist,
but is a very basic and limited editor. The problem is to decide when
the user has closed the application. start runs the app in the
background. If you exec Notepad directly, you probably can wait until it
terminates.

Christian

red floyd

unread,
Mar 23, 2015, 12:56:03 PM3/23/15
to
In which case, you're in the wrong newsgroup. Please see
FAQ 5.9, and/or look for a newsgroup with "windows" in its name.

Your problem is language independent, and therefore does not belong
here.

Please consider the following:

"Does my question make sense if I replace C++ with some other language?"
If so, you are in the wrong newsgroup, and you probably need to go to
a programming newsgroup rather than this language group.

"Does my question make sense if I replace 'Windows' with some other OS?"
If it doesn't, you have a Windows specific question,a nd again, you need
to go to a Windows group rather than this language group.




Paavo Helde

unread,
Mar 23, 2015, 2:17:40 PM3/23/15
to
Bonnedav <bonn...@gmail.com> wrote in
news:34849ece-7a40-4d3b...@googlegroups.com:

> On Sunday, March 22, 2015 at 8:51:34 AM UTC-6, Bonnedav wrote:
>> How do I make a console text editor in C++?
>
> in console no gui programs.
>

In Windows the underlying functionality for console access is provided
by Windows SDK console functions:
"https://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%
28v=vs.85%29.aspx"

See especially "Console Reference" - "Console functions". This section
documents the functions which need to be ultimately called either directly
by the text editor program or by some suitable library or framework it
uses.

How exactly to use them is off-topic for this group as this has nothing to
with C++ and everything to do with the Windows SDK.

hth
Paavo

Jorgen Grahn

unread,
Mar 24, 2015, 2:12:09 PM3/24/15
to
On Mon, 2015-03-23, Bonnedav wrote:
> On Sunday, March 22, 2015 at 10:33:08 AM UTC-6, Christian Gollwitzer wrote:
>> Am 22.03.15 um 16:32 schrieb Bonnedav:
>> > On Sunday, March 22, 2015 at 8:51:34 AM UTC-6, Bonnedav wrote:
>> >> How do I make a console text editor in C++?
>> >
>> > Wow ok. I just want to make a simple text editor for my database program.
>> > And by database I mean a folder with a bunch of files in it, each
...
>> >
>> Forget it, it's a seriously complex task. Instead, call an external
>> program. On Unix, typically the environment variable EDITOR or VISUAL is
>> set. If so, invoke that tool. If nothing is set, invoke vi. If that does
>> not work, write an error.
>
> How do i do it on windows?

It might be harder there. Sorry, don't know.

On Unix, what Christian describes is the defacto standard way of doing
it. It's what my newsreader is doing right now, for example -- slrn
has no text editor of its own (which means I can choose the one I
prefer).

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Bonnedav

unread,
Mar 25, 2015, 5:16:49 AM3/25/15
to
On Sunday, March 22, 2015 at 8:51:34 AM UTC-6, Bonnedav wrote:
> How do I make a console text editor in C++?

Is there any way to install "edit" or a similar console editor on 64-bit windows?

David Brown

unread,
Mar 25, 2015, 5:26:30 AM3/25/15
to
I would expect that "nano" is included as part of the msys or msys2
projects - it's a perfectly usable lightweight console editor.

Öö Tiib

unread,
Mar 25, 2015, 5:46:23 AM3/25/15
to
Sure.

Most typically people compile some vi or vim clone for windows (there
are literally piles freely available) and use it from PowerShell.
Controlling vi or vim is bit tricky to learn at first but unlike all
other things these may be still around 20-30 years later too.

Most similar to that Windows XP "edit" is perhaps SETEDIT,
http://setedit.sourceforge.net/ Open source but it may be
rather tricky to get that old Borland's C++ code to compile
for win 64.

Scott Lurndal

unread,
Mar 25, 2015, 1:49:59 PM3/25/15
to
Bonnedav <bonn...@gmail.com> writes:
>On Sunday, March 22, 2015 at 10:33:08 AM UTC-6, Christian Gollwitzer wrote:
>How do i do it on windows?

with an ubuntu live cd.

Christopher Pisz

unread,
Mar 25, 2015, 6:32:03 PM3/25/15
to
So, using windows prohibits you from going back to 1970 and editing text
on the command line. Could it be they expect you to....use a window?

Joking aside. Why do you need to be able to edit text on the command
line anyway?

From your description thus far, you might have an easier time using C#
and loading things up into a dataset that you can bind to a simple UI.
If you are feeling able.


--
I have chosen to troll filter/ignore all subthreads containing the
words: "Rick C. Hodgins", "Flibble", and "Islam"
So, I won't be able to see or respond to any such messages
---
0 new messages