Jump to content




[v0.3] ed - The in-game IDE

utility

  • You cannot reply to this topic
24 replies to this topic

#1 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 21 September 2012 - 03:55 AM

ed - The in-game IDE

Attention
I stopped working on this project a few months ago when I started into college again. I really enjoyed working on it, but I have no specific intent on returning to work on it in the future. So if anyone wants to take the reigns, help yourself!

Backstory
From the moment I started using ComputerCraft I found many functions of the mod quirky and maybe a little frustrating, but the native editting program (edit) was unacceptable. Even for a monochrome text program with no mouse support and limited visibility there was still massive areas needing improvement. So I mostly coded in Notepad++ while I learned lua and the CC apis. Until I realized I need a new project and I know enough now to write MY OWN edit program. So, here it is.

For those of you wondering, IDE stands for "Integrated Development Environment".
If you have any suggestions for improvements, feel free to post them in this thread. :)/>

Download
Direct: http://pastebin.com/D1S03niy
Adfly: http://adf.ly/D7lKX
To install, turn on http use in your ComputerCraft config file and use the pastebin command (i.e. pastebin get D1S03niy ed).

Previous version downloads:
Spoiler

Features
- In-editor program execution, with debugger
- Customizable interface including line numbers and status bar that is saved across sessions
- Many improvements to movement controls and automatic text insertion
- One button saving, exiting, and running
- Support for turtles and terminals with custom screen sizes
- ...and more to come!

Screenshots
Spoiler

How to use
Spoiler

Planned Features
Spoiler

Changelog
Spoiler


#2 rickydaan

  • Members
  • 93 posts
  • LocationThe Netherlands

Posted 21 September 2012 - 07:31 PM

Looks nice
Need someone helping you at this program?

#3 hego555

  • Members
  • 89 posts

Posted 21 September 2012 - 08:28 PM

Be nice if computercraft allowed colors, syntex hi-lighting would be nice!

#4 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 22 September 2012 - 08:42 AM

View Postrickydaan, on 21 September 2012 - 07:31 PM, said:

Looks nice
Need someone helping you at this program?

Thanks! I think I'll go solo for now, as I've never worked in a team before or publicly released code or a program before, so I'm trying to take it one step at a time. :P/>

#5 Shazz

  • Members
  • 175 posts

Posted 22 September 2012 - 12:50 PM

This is one of the reasons why Dan200 should add colour coding for the terminals and monitors.

#6 rickydaan

  • Members
  • 93 posts
  • LocationThe Netherlands

Posted 22 September 2012 - 02:13 PM

On what server do you play?

#7 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 22 September 2012 - 07:12 PM

View Postrickydaan, on 22 September 2012 - 02:13 PM, said:

On what server do you play?
I play on CCNet (EpicCoderz) Server mostly

#8 Jahmaican

  • Members
  • 26 posts
  • LocationPoland

Posted 23 September 2012 - 10:44 AM

I'm not sure if showing all line numbers is actually a good idea, because default terminal is only 80 characters wide (even less when using a turtle), and here you waste 4 when working with average 100+ lines file. Showing only current line as in default editor would work fine for me, so maybe you should let users switch between these 2 options?

Also, when debugging fails, cursor could be automagically set in the line where error occured.

Other than that, I love it.

#9 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 23 September 2012 - 09:35 PM

View PostJahmaican, on 23 September 2012 - 10:44 AM, said:

I'm not sure if showing all line numbers is actually a good idea, because default terminal is only 80 characters wide (even less when using a turtle), and here you waste 4 when working with average 100+ lines file. Showing only current line as in default editor would work fine for me, so maybe you should let users switch between these 2 options?
That's been suggested before, so I'll probably work on that next. I probably won't have the menu out before then, so you'll have to change the setting variable in ed's file.

View PostJahmaican, on 23 September 2012 - 10:44 AM, said:

Also, when debugging fails, cursor could be automagically set in the line where error occured.
I would LOVE to do that, the problem is that the error you see when a program fails is just a print to the screen. None of that information is passed back via variables. There's also, as far as I know, no way to read current characters on the terminal. If you find a way around either of these, I'd be more than happy to add that to ed.

Thanks for your support! :P/>

#10 faubiguy

  • Members
  • 213 posts

Posted 23 September 2012 - 11:25 PM

View PostKinoftheFlames, on 23 September 2012 - 09:35 PM, said:

View PostJahmaican, on 23 September 2012 - 10:44 AM, said:

Also, when debugging fails, cursor could be automagically set in the line where error occured.
I would LOVE to do that, the problem is that the error you see when a program fails is just a print to the screen. None of that information is passed back via variables. There's also, as far as I know, no way to read current characters on the terminal. If you find a way around either of these, I'd be more than happy to add that to ed.

Thanks for your support! :)/>

Getting the error message is possible if instead of shell.run, you use a new function, a modified version of os.run:
function runProg( sProgram, ... ) --sProgram is a string containing the current text. Any other arguments are arguments to the program.
	local tArgs = { ... }
	local fnFile, err = loadstring( sProgram )
	if fnFile then
		local tEnv = {["shell"] = shell}
		setmetatable( tEnv, { __index = _G } )
		setfenv( fnFile, tEnv )
		local ok, err = pcall( function()
			fnFile( unpack( tArgs ) )
		end )
		if not ok then
			if err and err ~= "" then
				print( err )
						errorText = err -- errorText is the variable where you want the error
			end
			return false
		end
		errorText = "" -- error value set to "" on successful execution
		return true
	end
	if err and err ~= "" then
		print( err )
				errorText = err -- Again replace errorText with the variable where you want the error
	end
	return false
end

You can replace the call to shell.run on line 326 with this:
local progSuccess = runProg(table.concat(tFile, "\n"), unpack(tArguments))

And then if execution fails you can get the error message from the variable you replace errorText with.

EDIT: I forgot to mention that I made it use the data from directly in the editor rather than from a file.

#11 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 24 September 2012 - 12:21 AM

Wow man! That's awesome! Now there will be legit debugging built in! I'm so excited. Now it just needs a settings menu, hotkeys, text selection...

EDIT: I did some tweaking and I've already got this implemented. If you have a run-time error in your program, it will now go to the line that error was on and display the error message. :P/>

#12 faubiguy

  • Members
  • 213 posts

Posted 24 September 2012 - 02:12 AM

I have a suggestion for this. A find and find-replace feature would be useful, so you might want to think about adding that in a future version.

#13 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 24 September 2012 - 07:06 AM

If anyone knows how to tell if a timer is dead (that is identify it as having already gone off) please let me know. I won't be able to add timers properly without it.

#14 Xfel

    Peripheral Designer

  • Members
  • 515 posts

Posted 24 September 2012 - 07:30 AM

You should add the other keys supported by text editors:
- Home and End keys to work for navigating to the front/end of a line
- Ctrl+Home/End combination to navigate to the beginning/end of a program
- PgUp/PgDown keys to scroll through program
- the delete key! (is quite self-explaining)

Additionally, a go to line function would be nice.

EDIT:
I forgot, the third important thing: auto intention and eventually a quick code format?

#15 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 24 September 2012 - 12:48 PM

View PostXfel, on 24 September 2012 - 07:30 AM, said:

You should add the other keys supported by text editors:
- Home and End keys to work for navigating to the front/end of a line
- Ctrl+Home/End combination to navigate to the beginning/end of a program
- PgUp/PgDown keys to scroll through program
- the delete key! (is quite self-explaining)

Additionally, a go to line function would be nice.

EDIT:
I forgot, the third important thing: auto intention and eventually a quick code format?

Home/end, page up/down, and delete should already be in the latest release.
Auto indentation is on the way, and the hotkeys you suggested (Ctrl + something) are being looked into to see if they are feasible.
I'll consider adding a goto line though! That's an interesting one I hadn't thought of. :P/>

#16 GopherAtl

  • Members
  • 888 posts

Posted 24 September 2012 - 06:17 PM

only way I know to know when timers are dead, other than pulling the timer event, is to save the time when they're queued and periodically check later to see if more than the intended time has already elapsed. You'll want to wait a bit longer than the length of the timer, in case the events are late (which can happen).

#17 Sebra

  • Members
  • 726 posts

Posted 24 September 2012 - 07:34 PM

View PostKinoftheFlames, on 24 September 2012 - 07:06 AM, said:

If anyone knows how to tell if a timer is dead (that is identify it as having already gone off) please let me know. I won't be able to add timers properly without it.
My thought is to calculate time after which timer considered dead (provided events queue is empty).
Doubt key combinations available now.

#18 KinoftheFlames

  • New Members
  • 39 posts
  • LocationMichigan

Posted 25 September 2012 - 05:20 AM

Just updated to v0.3. A lot of stuff was added, and I can rest easy now knowing that the core stuff I wanted to add in (editor, customizable UI, settings menu, debugger) are all at least started on and have minimum functionality. I need a break haha

#19 stilldabomb

  • New Members
  • 110 posts

Posted 25 September 2012 - 08:12 AM

View PostKinoftheFlames, on 25 September 2012 - 05:20 AM, said:

Just updated to v0.3. A lot of stuff was added, and I can rest easy now knowing that the core stuff I wanted to add in (editor, customizable UI, settings menu, debugger) are all at least started on and have minimum functionality. I need a break haha

Haha, I know the feeling XD

#20 Sebra

  • Members
  • 726 posts

Posted 25 September 2012 - 02:18 PM

F1 as Help key is too more standard.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users