Unix Programming - Is there exist console based c++ editor library?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2006 > Is there exist console based c++ editor library?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Is there exist console based c++ editor library?
key9

2006-10-28, 1:40 pm

Hi all

I am writting an console based application, looks like multiwindow editor,

I found it is fussy to write these line buffer mechanism .
and also these mechanism has nothing todo with what I want to prove.

so I wanna ask is there exist some c++ editor library, something like Text
Edit box under GUI?


Thank you very much.

your key9





Pascal Bourguignon

2006-10-28, 1:40 pm

"key9" <iamkey9@126.com> writes:
> I am writting an console based application, looks like multiwindow editor,
>
> I found it is fussy to write these line buffer mechanism .
> and also these mechanism has nothing todo with what I want to prove.
>
> so I wanna ask is there exist some c++ editor library, something like Text
> Edit box under GUI?


You could fork emacs, and if you need to edit or send emacs
command afterward, you can use emacsclient to communicate betweeb your
program and emacs.


Prototype using bash instead of C++:

#!/bin/bash
# initialization:
file=/tmp/data-$$.txt
ufile=$(dirname $file)/upcase-$(basename $file)
echo "Some initial data" > $file
# our main process:
(
sleep 3 # wait for emacs
# Let the user edit the file. He'll finish with C-x #
emacsclient $file >/dev/null 2>&1
# Let's run some emacs command on a file.
cp $file $ufile
emacsclient -e "(progn (find-file \"$ufile\") (mark-whole-buffer) (upcase-region (point-min) (point-max)) (save-buffer) (kill-buffer (current-buffer)))" >/dev/null 2>&1
# When we're done, let's tell emacs to quit:
emacsclient -e "(kill-emacs)" >/dev/null 2>&1
) & # we actually run in the child process, leaving the terminal to emacs
emacs -q -nw -f server-start
wait # for the forked process
# termination:
echo "=== file"
cat $file
echo "=== upcase-file"
cat $ufile
echo "==="
exit 0

You can also load in emacs some elisp code to have simple high-level
one-command entry points instead of sending long forms like that.


An alternative is to keep emacs as the main process, and fork from
emacs the C++ program, implementing the whole user interface in emacs,
and the core funntions in C++. Some applications take this approach.
One advantage, is that you get for free a "GUI" interface, on MacOSX,
MS-Windows and X, in addition to the terminal interface, thru emacs.

--
__Pascal Bourguignon__ http://www.informatimago.com/

"I have challenged the entire quality assurance team to a Bat-Leth
contest. They will not concern us again."
Pierre Barbier de Reuille

2006-10-29, 7:17 am

Pascal Bourguignon wrote:
> "key9" <iamkey9@126.com> writes:
>
> You could fork emacs, and if you need to edit or send emacs
> command afterward, you can use emacsclient to communicate betweeb your
> program and emacs.
>


Or you could fork vim Or, to be more flexible, you could fork the
program found in $EDITOR, while defaulting with vi or emacs, depending
on your prefered editor.

>
> Prototype using bash instead of C++:
>
> #!/bin/bash
> # initialization:
> file=/tmp/data-$$.txt
> ufile=$(dirname $file)/upcase-$(basename $file)
> echo "Some initial data" > $file
> # our main process:
> (
> sleep 3 # wait for emacs
> # Let the user edit the file. He'll finish with C-x #

if [-z $EDITOR]; then
> emacsclient $file >/dev/null 2>&1

else
$EDITOR $file
fi
> # Let's run some emacs command on a file.
> cp $file $ufile
> emacsclient -e "(progn (find-file \"$ufile\") (mark-whole-buffer) (upcase-region (point-min) (point-max)) (save-buffer) (kill-buffer (current-buffer)))" >/dev/null 2>&1
> # When we're done, let's tell emacs to quit:
> emacsclient -e "(kill-emacs)" >/dev/null 2>&1
> ) & # we actually run in the child process, leaving the terminal to emacs
> emacs -q -nw -f server-start
> wait # for the forked process
> # termination:
> echo "=== file"
> cat $file
> echo "=== upcase-file"
> cat $ufile
> echo "==="
> exit 0
>
> You can also load in emacs some elisp code to have simple high-level
> one-command entry points instead of sending long forms like that.
>
>
> An alternative is to keep emacs as the main process, and fork from
> emacs the C++ program, implementing the whole user interface in emacs,
> and the core funntions in C++. Some applications take this approach.
> One advantage, is that you get for free a "GUI" interface, on MacOSX,
> MS-Windows and X, in addition to the terminal interface, thru emacs.
>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
>
> "I have challenged the entire quality assurance team to a Bat-Leth
> contest. They will not concern us again."


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com