Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Softimage® / XSI SDK / Color coded script editor (with issues)
  RSS 2.0 ATOM  

Color coded script editor (with issues)
Rate this thread
 
30094
 
Permlink of this thread  
avatar
  • saajjj
  • Posted: 08 September 2008 10:38 AM
  • Total Posts: 161
  • Joined: 10 June 2008 12:38 PM

[B]NOTE: Please visit this thread for an update to the Script Editor. [/B]
The JScript version was abandoned in favour of one done in c++
-----------------------------------------------------------------
I started a thread earlier about how to get the regular script editor in XSI to support syntax highlighting. Thought it would be more appropriate to move the discussion here. It boils down to using the Text Editor Widget.

I’ve pasted my code below. The problems I have right now are:

[LIST=1]
[*]File > Open, File > New: don’t do anything in the editor. To test stuff, I used a single siControlTextEditor with the siUIToolbar and still those two menu items do nothing. (siTextEditorCapability has nothing to do with it since it’s there to limit stuff)
[*]The ‘Edit’ menu doesn’t show at all. The SDK doc does state that setting siUIToolbar to true enables the File and Edit menu.
[*]Can’t figure out the ‘run’ script button yet. If there is a ‘run’ attribute (which Steve mentioned here), this shouldn’t be an issue at all. I’m pretty sure with this we can even have combo boxes which allow to run as Python, JScript, VB etc.
[/LIST]

Are 1 and 2 bugs, or am I missing something?

Paste to script editor and run as jscript :)

var oPSet ActiveSceneRoot.AddProperty("CustomProperty"false"scriptEditor");
var 
oLayout oPSet.PPGLayout;
oLayout.Clear();

for (var 
0;5;i++)
{
    oLayout
.AddTab("  "+i+"  ");
    
oPSet.AddParameter3("x"+i,siString"");
    
//oLayout.AddGroup("Editor");
    //oLayout.AddButton("bttn", "bttn");
    
oItem oLayout.AddItem("x"+i""siControlTextEditor );
    
oItem.SetAttribute(siUIToolbartrue);

    
oItem.SetAttribute(siUIHeight400);
    
oItem.SetAttribute(siUILineNumberingtrue);
    
oItem.SetAttribute(siUIMarginWidth3);
    
oItem.SetAttribute(siUIFoldingtrue);
    
oItem.SetAttribute(siUINoLabeltrue);
    
oItem.SetAttribute(siUIFont"Tahoma");
    
oItem.SetAttribute(siUICommentFont"Comic Sans MS" );
    
oItem.SetAttribute(siUILanguage"Python");
    
//oItem.SetAttribute(siUIKeywordFile, "C:\\Softimage\\XSI_7.0\\Doc\\syntaxHighlight\\python.keywords");
    
oItem.SetAttribute(siUIAutoCompletesiKeywords)

    
oItem.SetAttribute(siUILineWrapfalse);
    
oItem.SetAttribute(siUIHorizontalScrolltrue);
    
oItem.SetAttribute(siUIVerticalScrolltrue);
    
//oLayout.endGroup();
}

InspectObj
(oPSet);


Replies: 0
avatar
  • scaron
  • Posted: 08 September 2008 03:05 PM

sorry i couldn’t find any reference to a ‘run’ attribute… but i think widget does have a ‘target’ attribute that will give you the content in the editor as a string, which you can put into an “ExecuteScriptCode()” command. so making your own run button would have to be done

steven



Replies: 0
avatar
  • saajjj
  • Posted: 09 September 2008 03:18 AM

I’ve got the following working:
1. Multiple tabs
2. Each tab supports it’s own scripting language (jscript, python, vb)
3. All the goodness of Scintilla (color coding, auto-completion etc)

What’s driving me insane is, perhaps a buggy, siUIToolbar for the Text Editor Widget:
1. Edit menu missing completely
2. File > Open, File > New don’t do anything. I have a feeling I need to set more attributes to make this work, perhaps setFolder or something similar.

I’ve written to SI about the siUIToolbar, hopefully they’ll be able to sort it out soon enough. If anyone else knows what I’m doing wrong, do tell :)

Note: Right now the keyword file path is disabled. I’m reading up on what format the keyword file should be. Different colours for different things etc.

Here’s the latest code:

var oPSet ActiveSceneRoot.AddProperty("CustomProperty"false"scriptEditor");
var 
oLayout oPSet.PPGLayout;

oLayout.Logic runCode_OnClicked.toString() +


oLayout.Clear();
for (var 
0;5;i++)
{
    editorID 
"x" i;
    
oLayout.AddTab(editorID);
    
    
oPSet.AddParameter3(editorIDsiString"");
    
oPSet.AddParameter3("combo"+editorIDsiString"JScript");
    
//oLayout.AddGroup("Editor");

    
oLayout.AddRow();

    
oRunBttn oLayout.AddButton("runCode""Run");
    
oLayout.Language "JScript";

    var 
lingoArray = new Array("JScript","JScript",
                                
"Python","Python",
                                
"VB Script""VBScript");
    
oLingoCB oLayout.AddEnumControl("combo"+editorIDlingoArray"Language"siControlCombo);
    
oLingoCB.SetAttribute(siUINoLabeltrue);
    
oLingoCB.SetAttribute(siUICX100);    

    
oLayout.EndRow();

    
oItem oLayout.AddItem(editorID""siControlTextEditor );
    
oItem.SetAttribute(siUIToolbartrue);

    
oItem.SetAttribute(siUIHeight400);
    
oItem.SetAttribute(siUILineNumberingtrue);
    
oItem.SetAttribute(siUIMarginWidth3);
    
oItem.SetAttribute(siUIFoldingtrue);
    
oItem.SetAttribute(siUINoLabeltrue);
    
oItem.SetAttribute(siUIFont"Tahoma");
    
oItem.SetAttribute(siUICommentFont"Comic Sans MS" );
    
oItem.SetAttribute(siUILanguage"JScript");
    
//oItem.SetAttribute(siUIKeywordFile, "C:\\Softimage\\XSI_7.0\\Doc\\syntaxHighlight\\python.keywords");
    
oItem.SetAttribute(siUIAutoCompletesiKeywords)

    
oItem.SetAttribute(siUILineWrapfalse);
    
oItem.SetAttribute(siUIHorizontalScrolltrue);
    
oItem.SetAttribute(siUIVerticalScrolltrue);
    
//oLayout.endGroup();
}


function runCode_OnClicked()
{
    currentLingoPath 
PPG.name ".combo" PPG.CurrentTab;
    
currentLingo Dictionary.GetObject(currentLingoPath);

    
currentEditorPath PPG.name "." PPG.CurrentTab;    //get editortextbox value
    
oEditorObj Dictionary.GetObject(currentEditorPath);    //conver to obj
    
    
oScript oEditorObj.value;
    var 
executeLingo currentLingo.value;
    
    try    
{
        ExecuteScriptCode
(oScript.toString(), executeLingo);
    
}
    
catch(e{
        LogMessage
("Error: " e.description);
    
}
}

InspectObj
(oPSet);


Replies: 0
avatar
  • saajjj
  • Posted: 09 September 2008 06:00 AM

My mini-project has come to a dead end :( SI has confirmed that siUIToolbar is indeed buggy.

edit: I suppose I could use other workarounds to opening files, but it’s going to make the top toolbar quite messy.



Replies: 0
avatar

[QUOTE=saajjj;10825]My mini-project has come to a dead end :( SI has confirmed that siUIToolbar is indeed buggy.

edit: I suppose I could use other workarounds to opening files, but it’s going to make the top toolbar quite messy.

You could use a relational view to combine the Text Editor control with a toolbar that has menu buttons.



Replies: 0
avatar
  • saajjj
  • Posted: 09 September 2008 06:18 AM

Ah! That sounds like a brilliant plan. First I have to figure out how relational views work and making a menu toolbar should be fun.

Thanks!

*switches to xsi > hits Alt h s*



Replies: 0