Using the developers' features of ped (the Photon Editor)

Using the developers’ features of ped (the Photon Editor)
By Jerry Chappell <jchappell@qnx.com>, QNX Software Systems Ltd.

Besides providing basic wordprocessing facilities, the Photon Editor
(ped) also offers a number of features that can help in software
development. In this article, I’ll outline those features and others
(keyboard shortcuts, markers) that you can use to speed up your
programming cycle.

Working with source files
The ped editor has a number of features associated with C and C++ source
file programming. (Although ped currently supports only C/C++ source
files, your suggestions for further source support are welcome!)

First, check under Preferences (in the Edit menu) for the following
setting:

“When a source file is opened, also open the corresponding header file.”

This option lets you tell ped to automatically open a header (.h) file
with the same name as any C/C++ source file (.c/.cc/.cpp) that’s already
opened. So by opening program.c, the corresponding program.h file
(assuming it exists), will appear in a second buffer.

To switch between the two files, use the Ctrl-> and Ctrl-< shortcut keys
(or use the Buffer menu).

Now that you’re viewing a source file (.c/.cc/.cpp), you’ll see a
combobox on the status bar (bottom of the ped window). When your cursor
moves throughout your document, the Function name combobox will change
to display the name of the function where your cursor is resting. As you
move your cursor, and as you write new functions, this label will always
change to reflect the current function.

While this is a useful indicator, the real advantage is to open the
combobox where all your functions will be listed. Click on any function
to move your cursor immediately to the top of that function. And to jump
quickly from one function to the next, click the Fn icon next to the
combobox (left-click or right-click) or jump using these shortcut keys:

Ctrl-{
move to previous function
Ctrl-}
move to next function

Check the Preferences dialog (under the Edit menu) for an option called
“List function names alphabetically”. If this option is selected, your
function names will be automatically sorted by name within the combobox.
If it’s not selected, then the function names will appear in the same
order as defined in your source file.

Even using the combobox for the benefit of determining what functions
are defined in your current document is a useful feature in itself,
especially if your application has many source files to keep straight!

You can even jump to a particular function from the command line. Use
the syntax:

-c functionname

to jump to the given function at startup (assuming the function exists
in the opened source file). For example, if you issue this command:

ped -c init source1.cpp &

then ped will:

  • open with two buffers (source1.cpp and source1.h)
  • show source1.cpp
  • move to the last function starting with init.

Keyboard shortcuts
Suppose you’re working with a large file that contains a number of
functions that are difficult to remember or that simply require a large
number of parameters in order to call. If a function you want to call is
in the same file that you’re editing, the Ctrl-Shift-E and Ctrl-Shift-P
commands may come in handy.

Ctrl-Shift-E (enter a function)

Highlight any function name and press Ctrl-Shift-E to immediately enter
the function specified. Your cursor will automatically jump to the
highlighted function (if it’s in the same file).

Ctrl-Shift-P (copy parameters)

The alternative to jumping to a function is to copy its parameters
directly into your code where you’re calling the function. Simply type
the name of the function (without any braces or spaces) and press
Ctrl-Shift-P. This will automatically insert the braces and all
parameter definitions for the function you’ve specified. At this point,
it’s easy to replace the parameters with the data you need to pass. For
example, if you type:

MinMax

and press Ctrl-Shift-P, your screen will show:

MinMax(int lownumber, int highnumber, char *error_string)

F10 (match braces)

Let’s say you’re searching through someone else’s code, and they have a
very poorly formatted coding style (of course!). If you’re having
trouble matching up their braces { }, you can easily find a matching
brace by pressing F10.

Position your cursor next to the known brace, press F10, and the cursor
will be immediately moved to the matching brace. This works for a number
of pairs of punctuation marks, including ( ), { }, " ", ’ ', and [ ].
This is great for trying to find a missing bracket that even the
compiler can’t quite pinpoint for you.

Ctrl-Alt-H (help text search)

QNX has a good set of online documentation that you can search for any
text string. To facilitate this searching:

  1. Highlight a word or phrase in your document.
  2. Press Ctrl-Alt-H.

The QNX Helpviewer is launched automatically, and the highlighted text
becomes the search phrase within the help docs. Your ped session itself
isn’t affected. There’s nothing better than being able to double-click
on something like ApCreateModule, press Ctrl-Alt-H, and immediately see
the docs for that function!

Ctrl-Up/Down Arrows

While working on a document, I also find it useful to move the display
up or down without actually moving the cursor – maybe I want to see
what variables I have defined just off the top of the display.

To move your document up and down by one line, use Ctrl-Up (up arrow)
and Ctrl-Down (down arrow). If the cursor ends up off the top or bottom
of your display, just move the cursor with one of the arrow keys to jump
back to your editing position.

Ctrl-Shift-I (indent)

One of the most common programming requirements is to indent a block of
text. You can do this simply by highlighting a block of text and
pressing the Ctrl-Shift-I (indent) hotkey. To shift the text to the
right, the highlighted text will have a tab character inserted at the
beginning of each line.

Similarly, press Ctrl-Shift-U to un-indent the highlighted text by
removing a tab from the beginning of each line.

Ctrl-Shift-F (find)

To search for text within a document, you can highlight it, copy it to
the clipboard, open the find dialog, and paste the text from the
clipboard into it.

Or you can use the Ctrl-Shift-F hotkey to show the find dialog with the
currently selected text string already inserted; no copying or pasting
is required.

Ctrl-Shift-0 (file search)

This keystroke will take any highlighted filename and search for the
file in your current directory. If the file exists (remember, it must be
in the same directory as the file you’re currently editing), then it
will be opened in its own buffer, and the display will switch to that
buffer. Your current buffer is unaffected by this operation; you can
switch back to it anytime, using the Buffer menu.

Using markers
One function that I find extremely useful is markers. As you may have
noticed, they have their own menu. Any ped document can have up to ten
markers defined. The marker information is stored with the formatting
block saved at the end of the file (see the Preferences menu option;
choose the Style & Markers tab).

Markers are indicated with a number from 1-10 in the bar on the
left-hand side of the ped window. These markers simply stay with the
line they were placed upon; you can jump to any one of them quickly
using a keyboard hotkey or from the Markers menu.

When working in your code, you may need to jump to some other part of
the document to work on another part of the code or to check existing
code. To easily jump back to your current position, press Ctrl-Shift-1
(for the first marker) or use the Markers menu. A “1” will appear next
to your current cursor position.

Now move around your document as necessary. When you’re ready to jump
back to marker #1, press Ctrl-1. Your cursor will automatically return
to the first marker position. If you use the Markers menu, you’ll notice
that only the markers that have been previously set are available as
destinations.

You can also jump to markers between buffers. If, for example, you have
markers 1 and 2 defined in the first buffer, and a marker 2 only in the
second buffer, you can press Ctrl-1 from either document to immediately
display the first buffer and to jump to marker 1 in that buffer.
Additionally, you can press Ctrl-2 in the first buffer to jump to its
marker 2; any subsequent presses of Ctrl-2 will toggle your display
between the marker 2 of each buffer.

To clear all the markers in the currently displayed document, press
Ctrl-Shift-Backspace

Conclusion
I believe the nicest feature of ped is the fact that it’s graphical.
IMHO, it’s the nicest looking editor available for QNX. It may not have
as much flexibility as some of the macro-based text editors, but its
special features make it useful and convenient for everyday use.

I hope that these details of the behind-the-scenes features of ped will
help you use it at least occasionally. Remember, ped is a relatively new
program – if it doesn’t have all the features of your dream editor,
please send me your suggestions!

Thank you for your interest.

kim bigelow wrote:

Using the developers’ features of ped (the Photon Editor)
By Jerry Chappell <> jchappell@qnx.com> >, QNX Software Systems Ltd.

There are already the matured gvim, vim, jed and
Nedit … with syntax coloring and other features.

Why on Earth was it neccessary to develop that
‘ped’ ???

Armin


Besides providing basic wordprocessing facilities, the Photon Editor
(ped) also offers a number of features that can help in software
development. In this article, I’ll outline those features and others
(keyboard shortcuts, markers) that you can use to speed up your
programming cycle.

Working with source files
The ped editor has a number of features associated with C and C++ source
file programming. (Although ped currently supports only C/C++ source
files, your suggestions for further source support are welcome!)

First, check under Preferences (in the Edit menu) for the following
setting:

“When a source file is opened, also open the corresponding header file.”

This option lets you tell ped to automatically open a header (.h) file
with the same name as any C/C++ source file (.c/.cc/.cpp) that’s already
opened. So by opening program.c, the corresponding program.h file
(assuming it exists), will appear in a second buffer.

To switch between the two files, use the Ctrl-> and Ctrl-< shortcut keys
(or use the Buffer menu).

Now that you’re viewing a source file (.c/.cc/.cpp), you’ll see a
combobox on the status bar (bottom of the ped window). When your cursor
moves throughout your document, the Function name combobox will change
to display the name of the function where your cursor is resting. As you
move your cursor, and as you write new functions, this label will always
change to reflect the current function.

While this is a useful indicator, the real advantage is to open the
combobox where all your functions will be listed. Click on any function
to move your cursor immediately to the top of that function. And to jump
quickly from one function to the next, click the Fn icon next to the
combobox (left-click or right-click) or jump using these shortcut keys:

Ctrl-{
move to previous function
Ctrl-}
move to next function

Check the Preferences dialog (under the Edit menu) for an option called
“List function names alphabetically”. If this option is selected, your
function names will be automatically sorted by name within the combobox.
If it’s not selected, then the function names will appear in the same
order as defined in your source file.

Even using the combobox for the benefit of determining what functions
are defined in your current document is a useful feature in itself,
especially if your application has many source files to keep straight!

You can even jump to a particular function from the command line. Use
the syntax:

-c functionname

to jump to the given function at startup (assuming the function exists
in the opened source file). For example, if you issue this command:

ped -c init source1.cpp &

then ped will:

  • open with two buffers (source1.cpp and source1.h)
  • show source1.cpp
  • move to the last function starting with init.

Keyboard shortcuts
Suppose you’re working with a large file that contains a number of
functions that are difficult to remember or that simply require a large
number of parameters in order to call. If a function you want to call is
in the same file that you’re editing, the Ctrl-Shift-E and Ctrl-Shift-P
commands may come in handy.

Ctrl-Shift-E (enter a function)

Highlight any function name and press Ctrl-Shift-E to immediately enter
the function specified. Your cursor will automatically jump to the
highlighted function (if it’s in the same file).

Ctrl-Shift-P (copy parameters)

The alternative to jumping to a function is to copy its parameters
directly into your code where you’re calling the function. Simply type
the name of the function (without any braces or spaces) and press
Ctrl-Shift-P. This will automatically insert the braces and all
parameter definitions for the function you’ve specified. At this point,
it’s easy to replace the parameters with the data you need to pass. For
example, if you type:

MinMax

and press Ctrl-Shift-P, your screen will show:

MinMax(int lownumber, int highnumber, char *error_string)

F10 (match braces)

Let’s say you’re searching through someone else’s code, and they have a
very poorly formatted coding style (of course!). If you’re having
trouble matching up their braces { }, you can easily find a matching
brace by pressing F10.

Position your cursor next to the known brace, press F10, and the cursor
will be immediately moved to the matching brace. This works for a number
of pairs of punctuation marks, including ( ), { }, " ", ’ ', and [ ].
This is great for trying to find a missing bracket that even the
compiler can’t quite pinpoint for you.

Ctrl-Alt-H (help text search)

QNX has a good set of online documentation that you can search for any
text string. To facilitate this searching:

  1. Highlight a word or phrase in your document.
  2. Press Ctrl-Alt-H.

The QNX Helpviewer is launched automatically, and the highlighted text
becomes the search phrase within the help docs. Your ped session itself
isn’t affected. There’s nothing better than being able to double-click
on something like ApCreateModule, press Ctrl-Alt-H, and immediately see
the docs for that function!

Ctrl-Up/Down Arrows

While working on a document, I also find it useful to move the display
up or down without actually moving the cursor – maybe I want to see
what variables I have defined just off the top of the display.

To move your document up and down by one line, use Ctrl-Up (up arrow)
and Ctrl-Down (down arrow). If the cursor ends up off the top or bottom
of your display, just move the cursor with one of the arrow keys to jump
back to your editing position.

Ctrl-Shift-I (indent)

One of the most common programming requirements is to indent a block of
text. You can do this simply by highlighting a block of text and
pressing the Ctrl-Shift-I (indent) hotkey. To shift the text to the
right, the highlighted text will have a tab character inserted at the
beginning of each line.

Similarly, press Ctrl-Shift-U to un-indent the highlighted text by
removing a tab from the beginning of each line.

Ctrl-Shift-F (find)

To search for text within a document, you can highlight it, copy it to
the clipboard, open the find dialog, and paste the text from the
clipboard into it.

Or you can use the Ctrl-Shift-F hotkey to show the find dialog with the
currently selected text string already inserted; no copying or pasting
is required.

Ctrl-Shift-0 (file search)

This keystroke will take any highlighted filename and search for the
file in your current directory. If the file exists (remember, it must be
in the same directory as the file you’re currently editing), then it
will be opened in its own buffer, and the display will switch to that
buffer. Your current buffer is unaffected by this operation; you can
switch back to it anytime, using the Buffer menu.

Using markers
One function that I find extremely useful is markers. As you may have
noticed, they have their own menu. Any ped document can have up to ten
markers defined. The marker information is stored with the formatting
block saved at the end of the file (see the Preferences menu option;
choose the Style & Markers tab).

Markers are indicated with a number from 1-10 in the bar on the
left-hand side of the ped window. These markers simply stay with the
line they were placed upon; you can jump to any one of them quickly
using a keyboard hotkey or from the Markers menu.

When working in your code, you may need to jump to some other part of
the document to work on another part of the code or to check existing
code. To easily jump back to your current position, press Ctrl-Shift-1
(for the first marker) or use the Markers menu. A “1” will appear next
to your current cursor position.

Now move around your document as necessary. When you’re ready to jump
back to marker #1, press Ctrl-1. Your cursor will automatically return
to the first marker position. If you use the Markers menu, you’ll notice
that only the markers that have been previously set are available as
destinations.

You can also jump to markers between buffers. If, for example, you have
markers 1 and 2 defined in the first buffer, and a marker 2 only in the
second buffer, you can press Ctrl-1 from either document to immediately
display the first buffer and to jump to marker 1 in that buffer.
Additionally, you can press Ctrl-2 in the first buffer to jump to its
marker 2; any subsequent presses of Ctrl-2 will toggle your display
between the marker 2 of each buffer.

To clear all the markers in the currently displayed document, press
Ctrl-Shift-Backspace

Conclusion
I believe the nicest feature of ped is the fact that it’s graphical.
IMHO, it’s the nicest looking editor available for QNX. It may not have
as much flexibility as some of the macro-based text editors, but its
special features make it useful and convenient for everyday use.

I hope that these details of the behind-the-scenes features of ped will
help you use it at least occasionally. Remember, ped is a relatively new
program – if it doesn’t have all the features of your dream editor,
please send me your suggestions!

Thank you for your interest.

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A3238E1.A21D537D@web_.de…

kim bigelow wrote:

Using the developers’ features of ped (the Photon Editor)
By Jerry Chappell <> jchappell@qnx.com> >, QNX Software Systems Ltd.

There are already the matured gvim, vim, jed and
Nedit … with syntax coloring and other features.

Why on Earth was it neccessary to develop that
‘ped’ ???

Probably to shut-up those that where complaining
there wasn’t a native graphics based editor for Photon.

Now they have to undo it because you are complaining
it was created. Life’s a bitch isn’t it?

  • Mario

Mario Charest wrote:

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A3238E1.A21D537D@web_.de…


kim bigelow wrote:

Using the developers’ features of ped (the Photon Editor)
By Jerry Chappell <> jchappell@qnx.com> >, QNX Software Systems Ltd.

There are already the matured gvim, vim, jed and
Nedit … with syntax coloring and other features.

Why on Earth was it neccessary to develop that
‘ped’ ???


Probably to shut-up those that where complaining
there wasn’t a native graphics based editor for Photon.

OK … but why should that be done from the
scratch?
Why not porting e.g. ‘Nedit’ to Photon ?

Now they have to undo it because you are complaining it was created.

I respect what they have done … but when I
compare the result with other editors then I tend
to say it was a waste of time.

Do you know an other source code editor which
supports styles ? Curious!

Life’s a bitch isn’t it?

Sometimes … especially when you have to do some
Sisyphean tasks :slight_smile:

Armin

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A334612.2A48399F@web_.de…

Mario Charest wrote:

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A3238E1.A21D537D@web_.de…


kim bigelow wrote:

Using the developers’ features of ped (the Photon Editor)
By Jerry Chappell <> jchappell@qnx.com> >, QNX Software Systems Ltd.

There are already the matured gvim, vim, jed and
Nedit … with syntax coloring and other features.

Why on Earth was it neccessary to develop that
‘ped’ ???


Probably to shut-up those that where complaining
there wasn’t a native graphics based editor for Photon.

OK … but why should that be done from the
scratch?
Why not porting e.g. ‘Nedit’ to Photon ?

Now they have to undo it because you are complaining it was created.

I respect what they have done …

To me you don’t sound like you do.
(I emphasis “me” because I would never talk for anybody else
and I emphasis “sound” cause I would never assume that
what I read is what one really means)

compare the result with other editors then I tend
to say it was a waste of time.

Do you know an other source code editor which
supports styles ? Curious!

Life’s a bitch isn’t it?

Sometimes … especially when you have to do some
Sisyphean tasks > :slight_smile:

“The struggle itself toward the heights is enough to fill a man’s heart.
One must imagine Sisyphus happy.”
Albert Camus, The Myth of Sisyphus

I would even go further then Camus. I beleive Zeus (in his wisdom) condemn
Sisyphys for a greater purpose. What the story doesn’t tell
is the track created by Sisyphys endless work serve as water collector
for the village down below. Sisyphys didn’t even realise it himself,
but he saved many lifes.

What you may see as pointeless in your own realitity may mean
the whole world to somebody else.

Armin

Mario Charest wrote:

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A334612.2A48399F@web_.de…
[ clip … ]
I respect what they have done …

To me you don’t sound like you do.

I’m respecting their work and what they have done
looks nice … but ‘the way
is the goal’ isn’t applicable in that case.

(I emphasis “me” because I would never talk for anybody else
and I emphasis “sound” cause I would never assume that
what I read is what one really means)
[ clip …]
Life’s a bitch isn’t it?

Sometimes … especially when you have to do some
Sisyphean tasks > :slight_smile:

“The struggle itself toward the heights is enough to fill a man’s heart.
One must imagine Sisyphus happy.”
Albert Camus, The Myth of Sisyphus

The ‘TAO of software development’ - no targets -
the ‘development is the goal’ :slight_smile:

I would even go further then Camus. I beleive Zeus (in his wisdom) condemn
Sisyphys for a greater purpose. What the story doesn’t tell
is the track created by Sisyphys endless work serve as water collector
for the village down below. Sisyphys didn’t even realise it himself,
but he saved many lifes.

What you may see as pointeless in your own realitity may mean
the whole world to somebody else.

I agree … from a philosophical point of view

Armin

Mario Charest wrote:
[snip]

“The struggle itself toward the heights is enough to fill a man’s heart.
One must imagine Sisyphus happy.”
Albert Camus, The Myth of Sisyphus

I would even go further then Camus. I beleive Zeus (in his wisdom) condemn
Sisyphys for a greater purpose. What the story doesn’t tell
is the track created by Sisyphys endless work serve as water collector
for the village down below. Sisyphys didn’t even realise it himself,
but he saved many lifes.

[ROFL!] Very good, Mario.



What you may see as pointeless in your own realitity may mean
the whole world to somebody else.

Armin

“Richard R. Kramer” <rrkramer@kramer-smilko.com> wrote in message
news:3A355502.33A632C7@kramer-smilko.com

Mario Charest wrote:
[snip]
“The struggle itself toward the heights is enough to fill a man’s heart.
One must imagine Sisyphus happy.”
Albert Camus, The Myth of Sisyphus

I would even go further then Camus. I beleive Zeus (in his wisdom)
condemn
Sisyphys for a greater purpose. What the story doesn’t tell
is the track created by Sisyphys endless work serve as water collector
for the village down below. Sisyphys didn’t even realise it himself,
but he saved many lifes.

[ROFL!] Very good, Mario.

ROFL: I had to lookup that one up. First time I came upon
this acronyms, in the process I also learned about ROTFLMAO :wink:

What you may see as pointeless in your own realitity may mean
the whole world to somebody else.

Armin

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A353922.A4665173@web_.de…

Mario Charest wrote:

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A334612.2A48399F@web_.de…
[ clip … ]
I respect what they have done …

To me you don’t sound like you do.

I’m respecting their work and what they have done
looks nice … but ‘the way
is the goal’ isn’t applicable in that case.

It might be. Perhaps that will force them to fix bugs in PtMultiText finally
:wink:

(I emphasis “me” because I would never talk for anybody else
and I emphasis “sound” cause I would never assume that
what I read is what one really means)
[ clip …]
Life’s a bitch isn’t it?

Sometimes … especially when you have to do some
Sisyphean tasks > :slight_smile:

“The struggle itself toward the heights is enough to fill a man’s heart.
One must imagine Sisyphus happy.”
Albert Camus, The Myth of Sisyphus

The ‘TAO of software development’ - no targets -
the ‘development is the goal’ > :slight_smile:

Isn’t that what inspires open source enthusiasts which you like to make an
example of? KDE developers work ‘for sheer joy of writing the best software
in the world’ (or something very close to that)… Come on Armin, let them
have some joy too, it’s Christmas time almost.

Cheers,

  • igor

“The struggle itself toward the heights is enough to fill a man’s heart.
One must imagine Sisyphus happy.”
Albert Camus, The Myth of Sisyphus

I would even go further then Camus. I beleive Zeus (in his wisdom)
condemn
Sisyphys for a greater purpose. What the story doesn’t tell
is the track created by Sisyphys endless work serve as water collector
for the village down below. Sisyphys didn’t even realise it himself,
but he saved many lifes.

What you may see as pointeless in your own realitity may mean
the whole world to somebody else.

Brilliant (“Tagesziel erreicht.”).

Zeljko