Online code editor with syntax coloring

new BookmarkLockedFalling
mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Post by mmiscool on Oct 22, 2010 18:26:05 GMT -5

Hello,

I have built a little online code editor for rb.

It will allow you to edit your projects in a nice editor.

I have not implemented code for creating a new project as I have to look at what needs to be in the xml file in the project folder but for editing existing projects this will work great.


To use you must place the "edit_area" folder in the public directory for the nifty javascript color syntaxing.
The "edit_area" folder is attached as a zip file to this post

Ohh. And a shot out to JosephE for the help with the javascript thing.

print "please enter a password"

input password.test$
if password.test$ <> "mmiscool" then wait
[show.code.editor]
gosub [rb.code.editor.menue]
q$=Chr$(34)
EditAreaLink$ = "<script src=";q$;"../../../../../edit_area/edit_area_loader.js";q$;" type=";q$;"text/javascript";q$;"></script>"
head EditAreaLink$ ' Link in the edit area javascript
textarea #code, muoccw.code.for.textaria$ , 210, 50
#code setid("codeEditor")
EditArea$ = "<script language=";q$;"javascript";q$;" type=";q$;"text/javascript";q$;">"
EditArea$ = EditArea$; "editAreaLoader.init({id:";q$;"codeEditor";q$;", syntax:";q$;"libertybasic";q$;", start_highlight: true, toolbar: ";q$;"search, |, fullscreen, |, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help";q$;", language: 'en'}); </script>"
html EditArea$ ' The code that makes the textarea #code turn into a syntax highlighting code-eating machine. ;)
print
wait

[rb.code.editor.menue]
cls
'Button #win, "New ", [new.prod]
Button #win, "Open", [open.prod]
if file.open = 1 then Button #win, "Save", [save.prod]
Button #win, "Save & Run", [run.prod]
html "<hr>"
return




[save.prod]
html "<script>editAreaLoader.delete_instance('codeEditor')</script>"
muoccw.code.for.textaria$ = #code contents$()


open "projects\";prod.name$;"_project\";prod.name$;".bas" for output as #jjjj
print #jjjj, muoccw.code.for.textaria$
close #jjjj
goto [show.code.editor]


[open.prod]
gosub [rb.code.editor.menue]
file.open = 0
dim prod.list$(1000)
x = 0
files #dir, "projects\*"
#dir dateformat("mmm dd, yyyy")
while #dir hasAnswer()
#dir nextFile$()
x = x + 1
if #dir isdir() = 1 then prod.list$(x) = #dir name$()
wend

listbox #lb,prod.list$(),10
print " "
link #sel, "[Accept]",[select.project]
wait


[select.project]
prod.name$ = left$( #lb selection$(), len( #lb selection$()) - 8)
if prod.name$ = "" then print "you must select a project":wait

open "projects\";prod.name$;"_project\";prod.name$;".bas" for input as #jjjj
muoccw.code.for.textaria$ = Input$(#jjjj, LOF(#jjjj))
close #jjjj
file.open = 1
goto [show.code.editor]

[run.prod]
html "<script>editAreaLoader.delete_instance('codeEditor')</script>"
muoccw.code.for.textaria$ = #code contents$()

open "projects\";prod.name$;"_project\";prod.name$;".bas" for output as #jjjj
print #jjjj, muoccw.code.for.textaria$
close #jjjj


gosub [rb.code.editor.menue]
run prod.name,ドル #top2
render #top2
wait


Attachments:



Last Edit: Oct 22, 2010 18:29:51 GMT -5 by mmiscool
Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
ekvirtanen
Guest

Guest Avatar

mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
ekvirtanen
Guest

Guest Avatar

mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Last Edit: May 14, 2011 22:52:13 GMT -5 by mmiscool
Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
ekvirtanen
Guest

Guest Avatar

tydb
New Member
*

tydb Avatar

Posts: 2

Post by tydb on Aug 17, 2013 17:04:10 GMT -5

I have the editor running in Linux. Changed some '\' to the right way and hard coded complet e path to 'projects/' (bad, bad).
Only issue I am having is the loaded code is line spaced with about 5 blank lines in between each line. It saves like that and is like that when it is opened in the nativeRB editor. Any solutions?
Linux Mageia 3
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Post by StefanPendl on Aug 18, 2013 15:46:53 GMT -5

tydb Avatar
Only issue I am having is the loaded code is line spaced with about 5 blank lines in between each line. It saves like that and is like that when it is opened in the nativeRB editor.


Might be a problem with CrLf end-of-line character used in Windows and Lf end-of-line character used in Linux.
So you may need a parser to remove the extra blank lines.
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
jerry
Junior Member
**

jerry Avatar

Posts: 86Male

Last Edit: May 3, 2014 16:53:34 GMT -5 by jerry
An old guy that cant wait to retire!