[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Your favourite language!

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Your favourite language!
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Rakon   USA  (123 posts)  [Biography] bio
Date Fri 19 May 2006 08:31 AM (UTC)  quote  ]
Message
Quote:
On the subject of editors, there was someone a while back that wanted an editor that would edit plugins but syntax colour the script part correctly...


Yes, Cedit can color different languages in one file, I used to remeber how to do this, I know its automatic for HTML. When I remeber how, I'll post here for you guys.

--Rakon

Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 10 May 2006 10:00 AM (UTC)  quote  ]
Message
Yes indeed. The editor you choose in the Scripting configuration tab (if any) is used in preference to the inbuilt notepad, for both the world's script file, and editing plugins.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nickpick   (24 posts)  [Biography] bio
Date Wed 10 May 2006 08:40 AM (UTC)  quote  ]
Message
Hmmm.. I though we could select the editor which MUSHClient uses for script editing. Well, at least the one you get when you edit plug-in.
[Go to top] top

Posted by Shadowfyr   USA  (1,774 posts)  [Biography] bio
Date Wed 10 May 2006 12:01 AM (UTC)  quote  ]
Message
Heh, don't pick on me Nick. ;) Seriously though, the discussion was with a number of us and about if Mushclient might at some point support something like Scintilla in its own editor. This was based on the fact that some of use already use one called SciTE, which is based on Scintilla. Crimson may be a bit more versitile though, adding coloring, like making both the XML and script parts colored, would require a major recompile of scintilla.

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 09 May 2006 09:29 PM (UTC)  quote  ]
Message
On the subject of editors, there was someone a while back that wanted an editor that would edit plugins but syntax colour the script part correctly (Shadowfyr maybe).

It seems Crimson Editor may do that, although I haven't actually tested it. In its syntax colouring configuration file you can specify "ranges" for colouring. An example is PHP files, where you syntax colour scripts between <?php ... ?> differently from the HTML code which is outside those delimiters.

Thus, it would seem quite possible to have it colour between <script> ... </script> differently to elsewhere, which should solve the problem.

You could also probably colour XML keywords (like "trigger", "alias" and so on), in the non-script part.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 09 May 2006 08:23 AM (UTC)  quote  ]
Message
Sure. You can create n-dimensional tables in Lua. Since tables can be nested, and arrays are a special case of tables, you can have tables of tables of tables of tables of tables of tables of ... tables of tables of ... integers. :-)

For example,
function Make2dMatrix(width)
  local result = {}
  for i = 1, width do
    result[i] = {}
  end
  return result
end

matrix = Make2dMatrix(3)
matrix[1][1] = 1
matrix[1][2] = 2
matrix[1][3] = 3
matrix[2][1] = 4
matrix[2][2] = 5
matrix[2][3] = 6
matrix[3][1] = 7
matrix[3][2] = 8
matrix[3][3] = 9

for row = 1, 3 do
  for col = 1, 3 do
    io.write(matrix[row][col], " ")
  end
  io.write("\n")
end


This generates a 3x3 matrix, fills it up with some values, and prints them all out. The output is:
$ lua tmp.lua 
1 2 3 
4 5 6 
7 8 9

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nickpick   (24 posts)  [Biography] bio
Date Tue 09 May 2006 07:55 AM (UTC)  quote  ]
Message
Hmm.. Crimson does look nice.

On Lua tables: They really look like the arrays and I suppose they are arrays in a way. What I've been wondering about is whether it is possible to create 3D or 4D tables for Lua.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 08 May 2006 09:56 PM (UTC)  quote  ]

Amended on Mon 08 May 2006 10:00 PM (UTC) by Nick Gammon

Message
However, back to languages, one of the really nice things about Lua is its ability to treat functions as "first class values" (as the manual says). What this means is that functions can be:


  • assigned (eg. a = print)

  • passed as parameters to other functions

  • stored in tables

  • constructed on-the-fly (eg. a function defined as an argument to another function)

  • removed (eg. print = nil)

  • have their behaviour changed - for example redefining print to also log (by saving the previous value as a local variable and then assigning a new one to it)

  • have their environment changed - effectively this means that for a particular function call you can redefine its global address space, effectively "sandboxing" it

  • call in protected mode - thus catching any errors inside the function and reporting them, rather than having the script terminate


This leads to some nice elegant programming, for example the sort function can take as an argument a function that specifies the "less than" test, so you can have custom sort orders.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 08 May 2006 09:50 PM (UTC)  quote  ]

Amended on Tue 16 May 2006 11:29 PM (UTC) by Nick Gammon

Message
There seemed to be a problem in Crimson Editor in detecting block comments, in that they were commented out in the lua.spc file. I suspect this is because the block comment delimiter was the same as the multi-line string delimiter. However this file contents *seemed* to work for me:


$CASESENSITIVE=YES
$DELIMITERS=(){}[]<>+-*/%="'~!@#&$^&|\?:;,.
$ESCAPECHAR=\
$QUOTATIONMARK1="
$QUOTATIONMARK2='
$LINECOMMENT=--
$SHADOWON=[[
$SHADOWOFF=]]
$BLOCKCOMMENTON=--[[
$BLOCKCOMMENTOFF=--]]
$PAIRS1=()
$PAIRS2=[]
$PAIRS3={}
$MULTILINESTRINGCONSTANT=YES



Strictly speaking, a multi-line comment is terminated by just "]]", not "--]]", however the Lua manual recommends using "--]]" because you can then simply include or exclude the entire multi-line block (assuming it is code) by simply adding an extra hyphen to the leading comment. Also, I think it looks more symmetrical.

To quote from their manual:




A common trick, when we want to comment out a piece of code, is to write the following:


    --[[
    print(10)         -- no action (comment)
    --]]


Now, if we add a single hyphen to the first line, the code is in again:


    ---[[
    print(10)         --> 10
    --]]


In the first example, the -- in the last line is still inside the block comment. In the second example, the sequence ---[[ does not start a block comment; so, the print is outside comments. In this case, the last line becomes an independent comment, as it starts with --.

[EDIT]

Added a new line, found on another forum:

$MULTILINESTRINGCONSTANT=YES

This lets it recognise multi-line string costants, like this:


print "hello, \
world"



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 08 May 2006 09:41 PM (UTC)  quote  ]

Amended on Wed 04 Jun 2008 09:17 PM (UTC) by Nick Gammon

Message
Hmm, interesting. I had been using ScITE, however after trying Crimson Editor it also seems very nice.

Its home page:


http://www.crimsoneditor.com/


Quote:

Frankly, the only thing that bugs me is that no "Extended commands" option exists with a unique color for commands that are not part of the language itself.


I tried to add that to Crimson Editor with a good deal of success.

I edited the "key" file for Lua (in directory C:\Program Files\Crimson Editor\spec\lua.key) and added the following lines to the bottom. After reloading my script file all the MUSHclient script functions were coloured in orange.


[KEYWORDS3:GLOBAL]
#
# MUSHclient world library functions
#
Accelerator
AcceleratorList
Activate

... and so on ...

WorldPort
WriteLog

world



I entered the last one ("world") manually in case you did world.Note)

To generate the full list I did this in Lua:


for k, v in pairs (utils.functionlist ()) do
  print (v)
end


After that you can add the MUSHclient extra Lua libraries (like utils) by doing this:


for k in pairs (utils) do
  print ("utils", k)
end


(And then do the same thing for the "bit" library).


Of course, you could add the MUSHclient keywords to the key file for any language, not just Lua.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Mon 08 May 2006 09:30 PM (UTC)  quote  ]
Message
Since we're talking about editors, I use vi (vim, actually) for most of my editing, even locally. It's one of the best editors, if not the best editor that I have used; once I got used to it of course. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Shadowfyr   USA  (1,774 posts)  [Biography] bio
Date Mon 08 May 2006 09:16 PM (UTC)  quote  ]
Message
I personally use SciTE from here:

http://scintilla.sourceforge.net/SciTEDownload.html

for editing. It supports every language imaginable and you can edit the definition files (with some limitations) to have it color Mushclient commands for the language(s) you use the same as its own. Frankly, the only thing that bugs me is that no "Extended commands" option exists with a unique color for commands that are not part of the language itself. Say, blue for the language commands and orange or something for Mushclient. To do that required recompiling the Scintilla lexer dll itself, last I checked.

However, so long as you don't mind that limitation, it will color the syntax of damn near everything I have ever heard of.

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Rakon   USA  (123 posts)  [Biography] bio
Date Mon 08 May 2006 05:59 PM (UTC)  quote  ]
Message
I personnally use python for all my scripts, triggers, and such, as well as a few plugins. But for portability of plugins, a few that I have written use VBscript. I really like the way python's syntaxs are, especially the whitespace character as a scoping indicator,(because I dislike searching for or forgetting that one 'end' or brace). I use Cedit(Crimson Editor) and I love the ability it has to color file syntax, all .py,pyw, and once configured, .pys. Yeeep Monty Python is the language for me.

Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for.
[Go to top] top

Posted by Nickpick   (24 posts)  [Biography] bio
Date Mon 08 May 2006 05:58 PM (UTC)  quote  ]
Message
Okey, one thing I need to admit already is that it is clearly faster than VBScript.
[Go to top] top

Posted by Norbert   USA  (61 posts)  [Biography] bio
Date Mon 08 May 2006 05:38 PM (UTC)  quote  ]
Message
I recently switched to Lua myself. My old editor started crashing a lot (nothing to do with Lua) and in my search for a new one I found Crimson Editor, which has built in color syntax for lots of languages and it's well documented in the help on how to create your own syntax files for other languages or how modify current ones to meet your needs. I was really surprised that it came with a Lua syntax. It is free.

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


6,801 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]