jEdit Community - Resources for users of the jEdit Text Editor
Mode C onversion and Newbie Console Help
Submitted by woodslanding on Thursday, 18 October, 2007 - 09:14
I am using a program called MUP, which compiles music graphics from text files I have been editing in JEdit. There are currently MUP syntax highlighting files for VIM, EMACS and KATE. I'm wondering if there is any way to convert any of these files into a mode file that JEdit can use. Or if there is a good tutorial out there on the way in which these type of syntax files are set up. It's obviously a problem that has been addressed by a number of programs in a variety of ways, but it's pretty much greek to me.

Also, if there is an intro to console tutorial somewhere, I'd like to check it out. The MUP compiler runs from the command line, so I'm thinking it should be possible to get it to compile from the console in JEDIT, but I'm not at all command-line savvy.... Ideally, I'd like to just compile from a key-command.

Any help welcome!
-eric
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
jEdit Help.
by elberry on Thu, 18/10/2007 - 19:29
The help documentation has a tutorial for writing new syntax modes, and how to install them. You might also try the files section here to see if there's a MUP syntax mode already available.

As for the console, if you have the console plugin you should be able to run your compile command from there just as you would from your normal command line.

I'm not familiar with MUP at all, but the console plugin comes with Commando, which allows you to essentially script a series of commands, which can be executed at the touch of a button.

If you can provide more information about how you use MUP, and how you compile from the command line, I may be able to help you create a commando file for it.

Learn from the past. Live in the present. Plan for the future.
 
Thanks for the quick response
by woodslanding on Sun, 28/10/2007 - 07:38
Thanks for the quick response! I haven't had time to address this myself. I'm getting some basic syntax coloring, just by indenting.

Nice!

Mup requires me to run two command lines:

mup myfile.mup

when this is run, if it has no errors, it creates the file:

myfile.gs

which then needs to be run by ghostscript.

I'm getting the hang of running both these from the command line, but I haven't been able to get my head around commando yet, and I don't know how to direct the created file on to the next app.

It's always the same thing, so I don't need a gui--just a macro with a key command would be great.

Any advice appreciated. I imagine it's quite easy to do, but I'm having trouble finding information in the documentation that doesn't presume a lot more command line experience than I have.... Thanks! eric

 
2 ways to do this
by elberry on Tue, 30/10/2007 - 22:31
K. There are at least 2 easy ways to do this. The first would be to create a macro that compiles the file you are currently editing in jedit. This macro would basically just run the commands you provided, in the console plugin. You should read the writing macros section in the help docs, so you at least know how to install them. Then you can install this macro (saved as Compile_Current_File.bsh):
[code]
// replace the strings with the actual commands if they are wrong.
String mupCompileCommand = "mup";
String ghostScriptCommand = "gs";
// get the current directory
String bufferPath = buffer.getPath();
String fileName = buffer.getName();
String rootFileName = fileName;
// remove the ".mup" file extension 
rootFileName = rootFileName.substring(0, rootFileName.length() - 4);
// the buffer path has the file name in it - so remove it.
bufferPath = bufferPath.replace(fileName, "");
if(bufferPath.contains(" ")) {
    // for windows: if there's a space in the path then we need to wrap the
    // path in quotes.
    bufferPath = "\"" + bufferPath + "\"";
}
// change directory - I'm assuming that you need to be in the directory of 
// the file to compile it.
runInSystemShell(view, "cd " + bufferPath);
// wait for that command to finish
waitForConsole(view);

if(fileName.contains(" ")) {
    // for windows: if there's a space in the name then we need to wrap the
    // path in quotes.
    fileName = "\"" + fileName + "\"";
}
// compile current file with mup compile command
runInSystemShell(view, mupCompileCommand + " " + fileName);
// wait for that command to finish
waitForConsole(view);

// create gs file
String gsFileName = rootFileName + ".gs";
if(gsFileName.contains(" ")) {
    // for windows: if there's a space in the name then we need to wrap the
    // path in quotes.
    gsFileName = "\"" + gsFileName + "\"";
}
// execute ghostscript on newly created gs file.
runInSystemShell(view, ghostScriptCommand + " " + gsFileName);
// wait for that command to finish
waitForConsole(view);
[/code]
Learn from the past. Live in the present. Plan for the future.
 
Thanks!!!!
by woodslanding on Wed, 31/10/2007 - 05:37
Wow, that's unbelievably helpful. I have already figured out how to set up macros, so I will try this out right away.

-edit- it works. Wow, I can't thank you enough. This would have taken a long time to figure out on my own!!!!

Thanks again! -eric

 
Great!
by elberry on Wed, 31/10/2007 - 16:11
I'm very happy to help. I know you happy with that macro, but I feel I should at least mention the other option. Smiling The other option is pretty much the same, in fact it uses exactly the same code w/out the calls to "runInSystemShell". The second option is to create a commando file. You should read the Console plugin help docs enough so you can install them, then you can install this.
[code]
<?xml version="1.0" ?>
<!DOCTYPE COMMANDO SYSTEM "commando.dtd">
<COMMANDO>
    <UI>
        <ENTRY LABEL="MUP Compile Command" VARNAME="mupCompileCommand" DEFAULT="mup" />
        <ENTRY LABEL="GhostScript Command" VARNAME="ghostScriptCommand" DEFAULT="gs" />
    </UI>
    <COMMANDS>
        <COMMAND SHELL="System" CONFIRM="FALSE">
            <!-- Changing directories to your file -->
            // get the current directory
            String bufferPath = buffer.getPath();
            String fileName = buffer.getName();
            String rootFileName = fileName;
            // remove the ".mup" file extension 
            rootFileName = rootFileName.substring(0, rootFileName.length() - 4);
            // the buffer path has the file name in it - so remove it.
            bufferPath = bufferPath.replace(fileName, "");
            if(bufferPath.contains(" ")) {
                // for windows: if there's a space in the path then we need to wrap the
                // path in quotes.
                bufferPath = "\"" + bufferPath + "\"";
            }
            // change directory - I'm assuming that you need to be in the directory of 
            // the file to compile it.
            return "cd " + bufferPath;
        </COMMAND>
        <COMMAND SHELL="System" CONFIRM="FALSE">
            <!-- Compiling mup file -->
            if(fileName.contains(" ")) {
                // for windows: if there's a space in the name then we need to wrap the
                // path in quotes.
                fileName = "\"" + fileName + "\"";
            }
            // compile current file with mup compile command
            return mupCompileCommand + " " + fileName;
        </COMMAND>
        <COMMAND SHELL="System" CONFIRM="FALSE">
            <!-- Executing gs on newly created gs file -->
            String gsFileName = rootFileName + ".gs";
            if(gsFileName.contains(" ")) {
                // for windows: if there's a space in the name then we need to wrap the
                // path in quotes.
                gsFileName = "\"" + gsFileName + "\"";
            }
            // execute ghostscript on newly created gs file.
            return ghostScriptCommand + " " + gsFileName;
        </COMMAND>
    </COMMANDS>
</COMMANDO>
[/code]
The difference here is that if there is an error it will prompt you to ask if you want to continue on with the rest of the commands. This way, if you compile a simple mup file and gs runs it, then you make changes to your mup file and it doesn't compile, gs won't just run your last one. You also get a nice simple UI to help you with optional inputs.

They are both very similar, just thought it was worth mentioning.

Cheers,
Eric

Learn from the past. Live in the present. Plan for the future.
User login
Browse archives
« April 2024  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82348
Context Free Art (*.cfdg)   0.31   46055
JBuilder scheme   .001   18495
BBEdit scheme   1.0   18116
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293