#-------------------------------------------------------------------------------
#
#	Name    : C
#	Purpose : StrongED mode file for C source files
#	Author  :  Guttorm Vik
#	Licence : Freeware
#	Version : 1.02, 22-07-03
#
#	Compilation may be started with F10.
#
#-------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Changes:
# 10.06.98 Made "{" a shortcut, which expands to brace set and places caret in the middle. (hmm)
# 16.06.98 Made "*/" a Syntaxword (group4), so it sticks out if the "/*" is missing.
# 29.06.98 Changed ListOfC button to not sort (since functions are often grouped logically)
#          In addition, Select now only searches *this* text, and adjust searches *all* texts.
# 29.06.98 Removed the ^H key binding for the 'load headerfile' function. This is now better
#          catered for by the clicklist (ctrl-Home or just doubleclick with mouse)
# 04.07.98 Dropped the ()'s from include1/2. Can now write A * @5 B
# 09.07.98 Removed the "{" shortcut again. Too damn annoying.
#          Added an "i(" shortcut
# 26.07.98 ctrl-Return will include any "/*" in its auto-indent.
# 22.10.98 Removed "*/" as reserved word. Clashed with " .. (char */*parm_name*/)
# 03.01.99 Removed duplicate 'do' and 'default' from Group1
# 21.07.00 Added #warning and #elif to the directives group (carl)
# 22.08.01 Updated HelpPath
# 03.11.02 Updated HelpPath again 
# 22.07.03 Group3 (preprocessor directives) now uses expression
# 22.07.03 Group1 was missing "case", part of switch..case..default 
#------------------------------------------------------------------------------

HelpPath	C-Version5,C++,C,OS,Wimp,MiscSWIs,InetSWIs,InetSocket,VDU,Toolbox,Desk,OSLib,UnixLib,

#-------------------------------------------

Search
	include1	[_spct] "#include" _spct "<" [_spct] @0 * @9 ".H" [_spct] ">"
	include2	[_spct] "#include" _spct '"' [_spct] @0 * @9 ".H" [_spct] '"'
	_Indent2	{" "} [ "/*" | "//" ] {" "}
	isblock		inblock .
	iscomment	"/*"
	wholecomment	"/*" ** "*/"
	preprocessor_	{" "} ("include" | "ifdef" | "ifndef" | "if" | "else" | "endif" | "pragma" | "line" | "error" | "define" | "undef" | "warning" | "elif")
	preprocessor	"#" preprocessor_
        function        < {" "} ~"else" ~"return" AD|"_" {'_A-Za-z0-9'}{' *'} AD|"_" {'_A-Za-z0-9'} {" "} "("
End

Foldparm1 ("/*{{{","/*}}}",startspace,case)

ClickList
	include1	LoadOne ("C:H.<tmp$word>")
#       include2        LoadOne ("<tmp$path>.^.H.<tmp$word>")
        include2        SetTmp(include2, "Tmp$Word") Run("<Tmp$Tool>.LoadHdr")
	iscomment	NoIndent MarkWord(WholeComment) GotoBlock_End CaretLeft CaretLeft DeleteRight DeleteRight GotoBlock_Start DeleteRight DeleteRight BlockClear
	isblock		NoIndent GotoBlock_Start "/*" GotoBlock_End "*/"
End

#-------------------------------------------

ID_FirstChar	A-Za-z_
ID_Middle	A-Za-z_0-9

SyntaxOptions
	SingleQuote	Yes
	DoubleQuote	Yes
	QuoteChar	\
	QuoteQuote	No
	SplitString	Yes
	HexPrefix	0x
End

SyntaxComment 1
	Type		MultiLine
	StartWith	/*
	EndWith		*/
End

SyntaxComment 2
	Type		OneLine
	StartWith	//
End

SyntaxWords Group1 case
	continue
	for while break return goto
	if else switch do default case
End

SyntaxWords Group2 case
	auto register static extern typedef
	void char short int long float double signed unsigned
	const volatile
	struct union
End

SyntaxWords Group3 nocase EndOfExpr preprocessor_
	#
End

SyntaxWords Group4 nocase EndAlways
	& *
End

SyntaxWords Group5 case 
	namespace public private friend operator class :: ~
End


## Make sure superfluous comment-end's stick out
#
#SyntaxWords Group5 nocase
#	"*/"
#End

#----------------------------------------------------------

KeyList
	^[		InsertStr("/*")
	^]		InsertStr("*/")
#	Return		Clicklist("indent")
	^Return		NewLine(indent,_Indent2)
End

#----------------------------------------------------------

Functions

	Key	F2
	Menu	List of functions F2
	Icon	LoF
	Select	ListOfC (Text)
	Help	HCM_lof

	Adjust	ListOfC (All)

        ^Select ListOfFound( function, Text, Whole, Line, Case, Nosort )

        ^Adjust ListOfFound( function, All, Whole, Line, Case, Nosort )

	Key 	PgUp
	Icon	up
	Select	GotoPrevC (Text)
	Help	HCM_up

	Key 	PgDown
	Icon	down
	Select	GotoNextC (Text)
	Help	HCM_dn

#	Key	^H
	Menu	Load H.*
	Icon	load
	Help	HCM_ld
	Select	SetTmp() LoadOne ("<tmp$path>.^.H.<tmp$word>","C:H.<tmp$word>")

	Key	F10
	Menu	Save & Compile      F10
	Icon	Run
#	Select	SaveDrag ("cc")
	Select	SetTmp() SaveRun("taskwindow \"gcc <tmp$path>.<tmp$leaf> -mthrowback\" -wimpslot 8000K")
	Help	HCM_run

	Key	^F10
	Menu	Save & Make      ^F10
	Icon	brick
	Select	SetTmp() SaveDClick ("<tmp$path>.^.Makefile")
	Help	HCM_mak

	Key	^G 1
	Menu	Goto function definition
	Icon	goto
	Select	Push GotoFoundC (all)
	Help	HCM_go

	Key	^G 2
	Select	Pop
End

Shortcuts
	w(	while (\@) {\n\i  \@\n\i}
	f(	for (\@;\@;\@) {\n\i  \@\n\i}
	s(	switch (\@) {\n\i  case \@\n\i}
	p(	printf("\@");
	i(	if(\@) \@
	#<	#include <\@.h>\n\@
	#"	#include "\@.h"\n\@
	``-	/*----------------------------------------------------------------------------*/
	``/	/*--- \@  */
	``*	/* \@  */
End
