Post Reply 
a good code editor for HP Prime
10-09-2016, 05:20 AM
Post: #1
a good code editor for HP Prime
It's a good editor.
You can download the image in the attachment list for a preview.

Thank you.

sorry for the english of my classmates named fsc.


Attached File(s) Thumbnail(s)
   

.hpprgm  codeeditor.hpprgm (Size: 34.97 KB / Downloads: 133)
Find all posts by this user
Quote this message in a reply
01-18-2017, 02:42 PM
Post: #2
RE: a good code editor for HP Prime
Nice code sample, thank you.
Still needs quite some work, but it's beta, as you state yourself ^^
Find all posts by this user
Quote this message in a reply
11-02-2019, 12:04 AM (This post was last modified: 12-19-2019 02:05 PM by FrankP.)
Post: #3
RE: a good code editor for HP Prime
First of all my VERY BIG THANK YOU, Chong Wang!

I liked the syntax-highlighting editor and viewer a lot, but for my daily usage, it was missing a search feature.
  • Therefore I started version 1.2 beta of the editor, adding search functionality to the existing code of Chong. Link for 12beta.zip only for history reason. Please use instead zip 1.4 below.
    .zip  CodeEditor_12beta.zip (Size: 16.03 KB / Downloads: 11)
  • Version 1.3 added highlighting search results, jumping to found source lines and calls a virtual keyboard function. Link for 13.zip only for history reason. Please use instead zip 1.4 below.
    .zip  CodeEditor_13.zip (Size: 40.88 KB / Downloads: 10)

Version 1.4. contains also search functionality, search highlighting, jumping to search result, virtual leyboard. In addition it removes unnecessary double textlength checks to reduce startup time and reduces the size of assigned GROB for textoutput. And 1.4 can display the actual line in an input dialog as the only ugly workaround found to allow using all system menues.
Tested with Virtual Calculator 2.1.14181 (2018 10 16) on win 8 and 2.1.14294 (219 10 2) on Android 7.1
   
.zip  CodeEditor_14.zip (Size: 23.87 KB / Downloads: 8)
Some usage notes:

1. Codeeditor is intended for Virtual Calculator. Running Codeeditor on G1 Prime Hardware fails with "Error: Insufficient memory" (ref. Post number 9 onwards in this thread). Behaviour on other physical Prime revisions is unknown.

2. The editor handles basic keyboard entries:
  • key 'sin' can be used to enter "SIN()", "ASIN()", "G" and "g"
  • key 'Vars' can be used to enter "A" and "a".
    To activate the 'Vars' menu or the character table you need to press before the
    'Help' key.
    An input dialog for the corresponding line is displayed with all system menues active.
3. usual keys:
  • 'Enter' 'Shift-Enter'
  • 'Del' 'Shift-Del'
  • 'Up' 'Down' 'Left' 'Right' cursor movement
  • 'Shift-Up' 'Shift-Down' to end/beginning of file
  • 'Shift-Left''Shift-Right' to end/beginning of line
4. special keys:
  • 'Symb' Search all
    A syntax colored overview on all lines containing a search string will be displayed.
    To be ended by additional 'Symb' key press.
    When tapping on a line before ending the search display, the corresponding line number of the sources will be displayed.
    Search results are highlighted.
  • 'Plot' / 'Num' Search backward / backward
  • 'Alpha-Dot' Start virtual keybord.
    A function "virtual_keys()" returning a string is called. This could be for example the very comfortable virtual_keys program https://www.hpcalc.org/details/7914 resp. https://www.hpmuseum.org/forum/thread-8262.html. After installing that program only ensure the function virtual_keys() is changed to 'EXPORT' to have it activated from within CodeEditor.
  • 'Help' Display actual line in input dialog.
    This is used as an ugly workaround to allow editing with all system menues active. Including Copy, Paste, Help, Character table, Toolbox, Units, Math template, Relation palette ... (unfortunately no multi line editing via INPUT for example for copy-paste possible)
    PLEASE NOTE:
    A " in a line will be displayed as "" by the INPUT function. No way has been found to convince INPUT starting with " instead of "". Therfore you need to use 'Bksp' key before starting to edit. This will convert all double "" into single ".
Find all posts by this user
Quote this message in a reply
11-02-2019, 06:05 AM
Post: #4
RE: a good code editor for HP Prime
(11-02-2019 12:04 AM)FrankP Wrote:  First of all my VERY BIG THANK YOU, Chong Wang!

When looking more detailed to the code last days, I asked myself if Chong has a private version of the code including some comments. However, I guess he does not need it: his thoughts seem to be direct prime programming language ;-). Smart code, Chong!

I liked the syntax-highlighting editor and viewer a lot, but for my daily usage, it was missing a search feature. Version 1.2 beta of the editor is my attempt to add
  • search all ('Symb' key)
  • search forward ('Plot' key)
  • search backward ('Num' key)
to the existing code. Tested with Virtual Calculator 2.1.14181 (2018 10 16) on win 8 and 2.1.14294 (219 10 2) on Android 7.1 Hoping for a limited number of probs with the code. Enjoy!

The editor with highlighting and search looks really useful! Thanks to you both.

Some feedback after initial use:
*The Help system doesn't work in the editor.
*Using the touchscreen to position cursor stops working at some point to the right. Cursor keys do work.
*SHIFT Chars does not work. So no way to add comments //
*Copy and Paste do not work
*It would be nice to be able to return to a selected line number from the search menu

Thanks again for a useful program. It would be fantastic if these features of highlighting and search made it into the native prime editor Smile
Find all posts by this user
Quote this message in a reply
11-02-2019, 08:42 AM (This post was last modified: 11-02-2019 09:18 AM by FrankP.)
Post: #5
RE: a good code editor for HP Prime
Thanks for your post, Steve!

(11-02-2019 06:05 AM)Stevetuc Wrote:  *SHIFT Chars does not work. So no way to add comments //
Hmm. This is strange...
  • Don't you see in a gray "Arrow up"+"S" in the upper left corner in the line where the program name is displayed when pressing Shift?
  • And don't you get "/" when pressing the DIV key at the corresponing cursor position?

(11-02-2019 06:05 AM)Stevetuc Wrote:  *The Help system doesn't work in the editor.
*Copy and Paste do not work
Yes, that's right. Key handling done inside 'gtext' and 'chk' I did not need to get into in more details up to now. And to be honest I was happy about this ;-)

(11-02-2019 06:05 AM)Stevetuc Wrote:  *Using the touchscreen to position cursor stops working at some point to the right. Cursor keys do work.
G1 is initialisized in Line 371 for the text display. And if I'm right, DIMGROB_P does allow only a width up to 1024.

(11-02-2019 06:05 AM)Stevetuc Wrote:  *It would be nice to be able to return to a selected line number from the search menu
And highlighting found string and lots of other features of nowadays coding editiors come into my mind. But before adding any additional features, I would need to dig much deeper into Chong's code.

-----------------------

Although all your requests are correct and useful I'm not sure if and when I will work on it. Mainly due to the fact, that I also hope really very much the next prime release (hopefully coming soon) will have some enhancements to the native editor. Smoother integrated into the prime as the self-made CodeEditor is.

By the way:
  • Are you using Prime HW? is the file loading and searching speed accaptable?
Find all posts by this user
Quote this message in a reply
11-02-2019, 09:28 AM
Post: #6
RE: a good code editor for HP Prime
(11-02-2019 08:42 AM)FrankP Wrote:  Thanks for your post, Steve!

(11-02-2019 06:05 AM)Stevetuc Wrote:  *SHIFT Chars does not work. So no way to add comments //
Hmm. This is strange...
  • Don't you see in a gray "Arrow up"+"S" in the upper left corner in the line where the program name is displayed when pressing Shift?
  • And don't you get "/" when pressing the DIV key at the corresponing cursor position?


Although all your requests are correct and useful I'm not shure if and when I will work on it. Mainly due to the fact, that I also hope realy very much the next prime release will have some enhancements to the native editor. Smoother integrated into the prime as the selfmade CodeEditor is.

By the way:
  • Are you using Prime HW? is the file loading and searching speed accaptable?


Ah, I meant [SHIFT] and [Chars] key, to bring up the character menu. Shifting characters is working and I didnt think of adding "//" via the DIV key, I usually use [SHIFT CHARS] but DIV saves keystrokes!

Totally understand re the work, I too hope the native prime editor will be upgraded.I have only used on the Android app. I assume the file load time would be long on the real hardware.
Find all posts by this user
Quote this message in a reply
11-02-2019, 10:34 AM (This post was last modified: 11-02-2019 10:41 AM by FrankP.)
Post: #7
RE: a good code editor for HP Prime
(11-02-2019 09:28 AM)Stevetuc Wrote:  Ah, I meant [SHIFT] and [Chars] key, to bring up the character menu.
Sorry, unfortunately same story as with Help, Copy, Paste. Only basic characters are handled up to now by CodeEditor. Since I mostly use https://www.hpmuseum.org/forum/thread-8262.html I did not get the idea to directly use char view for normal editing.
I keep posting on CodeEditor changes. Maybe you feel meanwhile the need to take the challenge hacking on CodeEditor Wink
Find all posts by this user
Quote this message in a reply
11-06-2019, 09:14 AM
Post: #8
RE: a good code editor for HP Prime
In the beginning of the this post I added a version 1.3 of the CodeEditor, containing some viewing fixes and typing / searching improvements. Hopefully useful for some of you.
Find all posts by this user
Quote this message in a reply
11-20-2019, 03:59 PM
Post: #9
RE: a good code editor for HP Prime
Hi Frank,

I downloaded and installed what I thought was Code Editor 1.3 using the program list and it starts fine (get the little pop-up window) and I can define a new program shell. However, that is a far as it goes. When I try to edit it (or edit an existing program) I get the message "Error: Insufficient memory". I am running on a physical G1 calculator with most memory left (not too many items defined). Can it run on a G1? If so, what could I be doing wrong?

Thanks and take care, Steve
Find all posts by this user
Quote this message in a reply
11-21-2019, 03:43 AM (This post was last modified: 11-21-2019 03:20 PM by FrankP.)
Post: #10
RE: a good code editor for HP Prime
Hi Steve,

thanks for your feedback!

If you really use 1.3 please give CodeEditor_14.zip in the top of this thread a try. In version 1.4 the dimension of the GROB for textoutput is reduced depending on the file to show (defaults of 'pixmaxwidth' and 'maxnumrows' are in 'init()' overwritten by real file dimensions).
I hope this helps. Mostly since I don't have any physical calculator to verify the problem. Sorry :-(

Can you let me know, if 1.4 also explodes on the physical Prime? Thanks!

Frank
Find all posts by this user
Quote this message in a reply
11-21-2019, 11:22 PM
Post: #11
RE: a good code editor for HP Prime
Hi Frank,

Thanks, CodeEditor 1.4 works at least to create and edit a new file (which 1.3 did not), but still crashes when trying to edit any program of a good size (like CodeEditor 1.3 or Virtual keyboard). When I try to open a larger file, I first see "Separating…" flashed in blue in the upper left, then get a message:

CodeEditor 2 Error:
Insufficient memory

Note I named the program CodeEditor 2 (had to load the text code into a new program).

I am showing 10.62MB of memory (on some days up to 16MB) and 196.7MB of storage. Trying to edit text files of 50KB or so doesn't seem to work. I assume a G2 would work fine - good to know.

Thanks and take care, Steve
Find all posts by this user
Quote this message in a reply
11-22-2019, 06:01 AM (This post was last modified: 11-22-2019 12:56 PM by FrankP.)
Post: #12
RE: a good code editor for HP Prime
Hi Steve,
thank's a lot for your investigations!
I guess physical Prime does not survive DIMGROB_P(G1. In Chong's original sources the graphic was set to 'DIMGROB_P(G1,1024,13*rowm+5);' with rowm=400. It's a pitty that I have no physical Prime. So I can only ask you to change in line 558 of CodeEditor 1.4:
Code:
// DIMGROB_P(G1,pixmaxwidth,13*maxnumrows+5); // text
DIMGROB_P(G1,1024,13*400+5);
I have no idea what physical Prime is doing when scrolling and TEXTOUT_P go beyond row 400. Emu simply shows white space.

If this changed DIMGROB_P will show bigger files, it means CodeEditor would need to display blockwise on physical Prime. Something not foreseen in the actual concept of slurping in a file as one big list of strings and show it in one big memory eating graphic.
I fear when changed DIMGROB_P lets program execution continue, that parsing lines takes inaccaptable long time on physical Prime. On my Android parsing 800 lines takes about 4 seconds.

Frank
Find all posts by this user
Quote this message in a reply
11-22-2019, 07:17 PM
Post: #13
RE: a good code editor for HP Prime
Hi Frank,

The original code as you sent it did not work; ran out of space trying to open VirtualKB. I cut down the space further by changing to:

DIMGROB_P(G1,512,6*400+5);

...and it opened fine!!!

May try experimenting on settings to understand space limitations, but works great. Neat environment (with Virtual KB) if stuck editing directly on the G1.

Thanks and take care, Steve
Find all posts by this user
Quote this message in a reply
11-22-2019, 08:31 PM (This post was last modified: 11-22-2019 09:30 PM by FrankP.)
Post: #14
RE: a good code editor for HP Prime
Great news, Steve!

Especially since CodeEditor makes most sense for physical Prime users.They can't switch to alternative editors on their device as Emu users can on Android, Linux or PC.

I have been looking how to split textoutput on several smaller graphics and combine them when scrolling. Handling 'Bksp' and 'Enter' key I have to think about, but the rest is not magic. I will send an updated version 1.5 next days. Would be great if you could than test on physical Prime.
Again thanks a lot for your efforts!

Frank
Find all posts by this user
Quote this message in a reply
11-30-2019, 02:20 PM
Post: #15
RE: a good code editor for HP Prime
Hi Steve,

When rethinking your last post, your observations are not that great anymore:
A working 'DIMGROB_P(G1,512,6*400+5);' means a max of only 2405 pix height, thus 185 lines per G page (one line 13 pix height). Assuming G1...G4 are used for textoutput only 740 lines are available (depending on the version vkbd uses G7,G8,G9; G6 for header footer; G5 for textlength).

And what is more, when starting Virtual KB required less G1 size means: available max size of individual G depend on available overall mem. Thus even the 185 lines per one G page could fail, when using G1, G2, G3 and G4 together.

In any case here a version 1.5, using G1...G4 with
Code:
LOCAL numrowsper_g:=185; // is this the max value on physical Prime?
LOCAL pixmaxwidth :=512; // is this the max value on physical Prime?
corresponding your observations. Hope you find time to test this on physical prime and wonder what hardware will say to this attempt...

.zip  CodeEditor_15.zip (Size: 24.4 KB / Downloads: 5)
Frank.
Find all posts by this user
Quote this message in a reply
12-17-2019, 06:20 PM
Post: #16
RE: a good code editor for HP Prime
Hi Frank,

Bad news on my end running on a G1 physical calculator. You were right about the limitation of the space - only able to see 185 lines and mostly OK on the width under 1.4. Under 1.5, tried to edit "Virtual Keyboard" (and others) and got warnings on "File has too long lines! Display...", then get "Insufficient Memory" error. I also tried creating a new program, which it created the shell, then immediately got an "Insufficient Memory" error. Note that my Memory is also being taken away by Code Editor. I had ~ 16MB available to me before I ran Code Editor, then only about 1MB after. I needed to constantly do a reset to get the memory back.

Note I didn't try changing any settings - used as you had defined 1.5. Not sure how it would work under a G2 with 8 times the memory, but definitely not a go under G1 32MB.

Good luck and advise if you substantially changed the approach and would like me to test again.

Take care, Steve
Find all posts by this user
Quote this message in a reply
12-19-2019, 01:45 PM
Post: #17
RE: a good code editor for HP Prime
Hi Steve,

so the only way to get Codeeditor on G1 Prime hardware running seems to be dynamic creation of the display. However, that would ruin the user response when scrolling through the coloured sources.

To figure out why memory is not freed correctly on G1 hardware makes no sense, without having a device to play around with. Therefore, I make a note that Codeeditor is not suitable for G1 Prime Hardware. Unfortunately.

In any case thanks’ a lot for your tests!

Frank
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)