Board index FlightGear Development Nasal

Copy/Paste from Nasal window

Nasal is the scripting language of FlightGear.

Copy/Paste from Nasal window

Postby spencer.james » Tue Dec 16, 2014 7:43 pm

A Newbie here, and done a search but couldn't find anything here, but apologies if duplicate.

Been trying to develop some airport scenery, and have been able to load items using the UFO, and dump them to the Nasal script window. Underneath them is a copy / paste button, and I can see there is in inscreen instructions when you select them.

However, no matter what I do (click on copy, hit CTRL+C) I'm unable to copy the code from the Nasal script window to the windows clipboard so I can then paste the code generated into notepad.

Am I missing something, or do I need to do something different?

I'm running 3.2 on Windows 7.

Thanks in advance.
ErinAir

Project Ireland - Republic of and Northern Ireland Airports - http://forum.flightgear.org/viewtopic.php?f=5&t=26292 - Coming soon
spencer.james
 
Posts: 52
Joined: Thu Oct 30, 2014 6:40 pm
Callsign: ErinAir
Version: 3.4
OS: Windows 7

Re: Copy/Paste from Nasal window

Postby Hooray » Tue Dec 16, 2014 7:53 pm

the way this is currently implemented it only works for the Nasal console EDITOR, i.e. the part where you can enter code (i.e. NOT the output window) - equally, the copy/paste functionality is fairly generic at the moment, i.e. no mouse selection support, it will just copy/paste (=replace) the whole buffer.


however, the loglist widget (=output window) is a hard-coded thing (PUI widget) that isn't sufficiently exposed to scripting space yet:

Subject: How do I get output in the console
Hooray wrote:Agreed, but unfortunately, the loglist was still added as a custom and hardcoded PUI widget despite our Canvas GUI code, I did raise that issue a while ago and talked with Zakalawe and TheTom, and the general consensus back then was that the Canvas/GUI code wouldn't be quite ready yet to directly use the Canvas system here, I still came up with a simple Canvas-based loglist widget, which could obviously parse control characters and also colorize tokens using osgText animations:

http://wiki.flightgear.org/Canvas_GUI
Image

even without any changes to the Canvas/GUI system, this should work - the only thing missing to make this more than a proof-of-concept is exposing the SG_LOG() machinery via cppbind (or even just a single extension function), currently the loglist buffers are not accessible from Nasal space (though I haven't checked in a while). I still believe it's the right thing to do, but didn't feel like arguing ...


It would be possible to re-implement this on top of Nasal/Canvas though:

Subject: How does serviceable and failures work?
Hooray wrote:WRT the logging feature, I would suggest to make it a vector of strings, or possibly containing hash with timestamps and events/messages - that should be better maintainable in the long run, and it would also provide us with the option to support localization more easily. Equally, the number of messages/events could be easily configured by setting the vector to a certain max size.
Besides, there's already a hard-coded PUI loglist widget that is currently used for displaying Nasal related messages in the Nasal console dialog - it would be great to re-implement this on top of Canvas, so that we can phase out the loglist widget there to incrementally get rid of PUI - thus, if at all possible, please consider introducing a separate "loglist" widget in $FG_ROOT/Nasal/canvas/gui/widgets

http://wiki.flightgear.org/Canvas_GUI#PUI_Widgets

It would be great to update the Canvas Widgets article accordingly: http://wiki.flightgear.org/Canvas_Widgets

I once prototyped a simple Canvas-based loglist widget by adapting TheTom's demo code: http://wiki.flightgear.org/index.php?ti ... as_widgets
Image
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11312
Joined: Tue Mar 25, 2008 8:40 am

Re: Copy/Paste from Nasal window

Postby spencer.james » Tue Dec 16, 2014 8:26 pm

Thanks Horay

You can probably hear a whoosh as that flies right over my head :P !

OK, if it is not possible in the Nasal console, can I get the dumped data into something like Notepad any other way? Or am I going to be doing a lot of typing from one to another?

Thanks in advance.
ErinAir

Project Ireland - Republic of and Northern Ireland Airports - http://forum.flightgear.org/viewtopic.php?f=5&t=26292 - Coming soon
spencer.james
 
Posts: 52
Joined: Thu Oct 30, 2014 6:40 pm
Callsign: ErinAir
Version: 3.4
OS: Windows 7

Re: Copy/Paste from Nasal window

Postby Hooray » Tue Dec 16, 2014 8:35 pm

whatever is "dumped" to the Nasal console via print(), needs to exist in Nasal space in the first place - so you could just as well directly use the helper routines available in io.nas to write the corresponding data to a file - including even an XML file or CSV (Excel) etc.

Modifying the ufo.nas file accordingly should be straightforward and we can probably walk you through the whole thing fairly quickly - you should just state your exact requirements/use-case
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11312
Joined: Tue Mar 25, 2008 8:40 am

Re: Copy/Paste from Nasal window

Postby spencer.james » Tue Dec 16, 2014 10:49 pm

Hi Horay

That would be awesome!

Ok, so I would like to be able to, when placing objects in a position, say a radar on an airfield, after a number of items have been dropped down, dump the data (including the relevant STG tile) to a text file. Then I can copy the data from that into the STG file.

I could then also, for instance use that data on the bulk uploader on scenemodels, to quickly and accurately populate underdeveloped airports.

Thanks in advance :D
ErinAir

Project Ireland - Republic of and Northern Ireland Airports - http://forum.flightgear.org/viewtopic.php?f=5&t=26292 - Coming soon
spencer.james
 
Posts: 52
Joined: Thu Oct 30, 2014 6:40 pm
Callsign: ErinAir
Version: 3.4
OS: Windows 7

Re: Copy/Paste from Nasal window

Postby Hooray » Wed Dec 17, 2014 2:28 am

Open ufo.nas, and you'll see that most of the stuff you need is already there.
For example, the STG comptuation can be found here: https://gitorious.org/fg/fgdata/source/ ... o.nas#L397

And you'll find the print* functions there, too: https://gitorious.org/fg/fgdata/source/ ... o.nas#L724

https://gitorious.org/fg/fgdata/source/ ... o.nas#L766


As well as an existing export* function that saves to XML: https://gitorious.org/fg/fgdata/source/ ... o.nas#L799

So you can now modify/combine these chunks of code to create new functionality - for file I/O you'll want to refer to io.nas
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11312
Joined: Tue Mar 25, 2008 8:40 am


Return to Nasal

Who is online

Users browsing this forum: Thorsten and 2 guests

cron