#-------------------------------------------------------------------------------
#
#	Name    : News
#	Purpose : StrongED mode for editing E-mail
#	Author  : Guttorm Vik
#	Licence : Freeware
#	Version : 1.05 10-11-05
#
#-----------------------------------------------------------------------------
# 10.08.98 GV ctrl-Return inserts multiple newlines, to make room for a reply
# 10.08.98 GV Clicking on the 'mail' icon saves *without* asking.
#--- v 4.53 released
# 03.10.98 GV Modified _NoWrap to include lines with at least 4 consecutive
#             'special' characters. This should prevend separator lines from
#             being wrapped (Lines like '------', '~~~~~~~~' etc..)
# 26.10.98 GV Removed space from ID_Middle again. Don't know why it was there
# 04.11.98 GV Added _SpellIgnore
# 14.01.99 GV Now uses EndOfExpr ee_url instead of ID_Middle, as a test..
#          FG Added snip button
# 07.07.03 FG Added https:// and news: to syntax colouring
# 16.11.03 FG Extended ee_url
# 16.11.03 FG NoWrap updated
# 16.11.03 FG Added Bcc: to Group2
# 18.12.03 FG Added Lines: and User-Agent: to Group3
# 19.12.03 FG Added sig button
# 04-07-04 FG Uncommented SyntaxComment 1, multiline sigs show now be coloured
# 04-07-04 FG Altered _ParPrefix so it works with the rewritten hardwrap code
# 30-11-04 FG Added Cc: to Group2
# 10-11-05 FG Added In-Reply-To: to Group3
# 10-11-05 FG Added Tidy icon by Gavin Wraith
#-----------------------------------------------------------------------------

# Use comments to colour signatures
SyntaxComment 1
	CommentType	Multiline
	StartWhere	StartLine
	StartWith	"-- "
#  Endwith	"."
End

# Search expressions

Search
	ee_url		{'A-Za-z_0-9./~+\-:;*()?%=@&$,"\\!#'}+
#	serverpart	{'A-Za-z0-9+%\-'}+
#	We ignore:	<message-id's>			| server.names					| words containing numbers or underscore
#	_SpellIgnore	("<"{'A-Za-z0-9.+%\-'}"@"*">")	| (serverpart"."serverpart"."serverpart)	| ({?} {'0-9_'}+ {?})
	ToSnip		{InBlock '\x00-\xff'}+
	StartSpc	< {" "}+
	fquote		($ [" "] {'>|*' [" "]}+)
	Bullet2		(< {'>' [' ']}+) {' '} @1 '\-*o'

	Headers		(<("Subject"|"To"|"From"|"Message-ID"|"User-Agent"|("X-" Alpha {Alpha|"-"}+)) ": " * >)
	Quoted		{'>' [' ']}+
	Bullet		{' '} '*\-o' ' '
	Spaces		{' '}
	QuotedLine	Quoted * >
	SigSeparator	< "-- " >
	Signature	[NL] SigSeparator [{NL {.}}+]
	QuotedSig	[NL] Quoted "-- " [{NL {.}}+]

# We don't want to involve the sig separator or headerlines in hardwrap.
	_NoTrim		SigSeparator
	_NoWrap		SigSeparator | Headers | * {'\-*_~^+='}4:4
	_ParPrefix	< [Quoted] @1 [Bullet] @2 [Spaces]
	_SpellIgnore	Headers | http | QuotedLine
End

Replace
	Snipped		NL "[snip]" NL NL
	NewLine		NL
	Unbullet	@01 " "
End

# Header lines we want to stand out

SyntaxWords Group2 StartOfLine EndOfLine nocase
	From: To: Cc: Bcc: Subject:
End

# Header lines we want to 'hide'

SyntaxWords Group3 StartOfLine EndOfLine nocase
	Path: Newsgroups: Date: Organization: X- References:
	Mime-Version: Content-Type: NNTP-Posting-Host: Message-ID:
	Distribution: Originator: Lines: User-Agent: In-Reply-To:
End

# URL colouring

SyntaxWords Group4 nocase EndOfExpr ee_url
	URL: https:// http:// ftp:// telnet:// mailto: news: www.
End

# Four levels of quote colouring, using four different colours

SyntaxWords Group5 StartOfLine EndOfLine nocase
	> "> "
End

SyntaxWords Group6 StartOfLine EndOfLine nocase
	>> ">> " "> >" "> > "
End

SyntaxWords Group7 StartOfLine EndOfLine nocase
	>>>    ">> >"  "> >>"  "> > >"
	">>> " ">> > " "> >> " "> > > "
End

SyntaxWords Group8 StartOfLine EndOfLine nocase
	>>>>    ">>> >"  ">> >>"  ">> > >"  "> >>>"  "> >> >"  "> > >>"  "> > > >"
	">>>> " ">>> > " ">> >> " ">> > > " "> >>> " "> >> > " "> > >> " "> > > > "
End

# If you're reading a newsbox, you can fold on its subject lines.

FoldParm1 ("Subject:",,startofline)

# Key definitions and functions

KeyList
#	^R		Rot13()
	^Q		CheckWidth(78) KillView()
	^O		Replace(StartSpc,"",Block,,) Replace(fquote," ",block,,) Reformat()
	^Return		Newline Newline Newline CaretUp CaretUp
	^Return	Newline(Indent, _ParPrefix) StartOfTLine MarkLine Replace(Bullet2, Unbullet, Block, Line) BlockClear Reformat Reformat Newline Newline Newline CaretUp CaretUp
End

Functions
	Key	F2
	Menu	Subjects  F2
	Icon	lof
	Select	ListOfFound ("Subject:",Text,After,Line,Case)

	Adjust	ListOfFound ("Subject:",All,After,Line,Case)

	Key	PgUp
	Icon	up
	Select	GotoPrev ("Subject:",Text,Line)

	Key	PgDown
	Icon	down
	Select	GotoNext ("Subject:",Text,Line)  Position(Top,4)

	Menu	From
	Select	ListOfFound ("From:",Text,After,Line,Case)

	Key	^S
	Menu	Snip block   ^S
	Icon	snip
	Help	Hnws_snp
	Select	Replace(ToSnip, Snipped, Block) BlockClear

	Adjust	Replace(ToSnip, NewLine, Block) BlockClear

	Icon	sm!news
	Help	Hnws_snd
	Select	CheckWidth(78) SaveKill

#	Icon	signature
#	Select	EndOfText NewLine NewLine CaretUp GotoPrev(SigSeparator,text,line,nocase) BlockClear BlockMark_Standard EndOfText BlockMark_Standard BlockDelete

#	Adjust	EndOfText NewLine NewLine CaretUp GotoPrev(SigSeparator,text,line,nocase) BlockClear BlockMark_Standard EndOfText BlockMark_Standard BlockDelete SetTmp() InsertFile("<Tmp$Mode>.Files.Sig")

	Icon	signature
	Help	Hnws_sig
	Select	Replace(QuotedSig,"",Text,Line,nocase)

	^Select	Replace(Signature,"",Text,Line,nocase)

	Adjust	Replace(QuotedSig,"",Text,Line,nocase) EndOfText NewLine SetTmp() InsertFile("<Tmp$Mode>.Files.Sig")

	^Adjust	Replace(Signature,"",Text,Line,nocase) EndOfText NewLine SetTmp() InsertFile("<Tmp$Mode>.Files.Sig")

	Menu	UnQuote
	Select	SetTmp() Process(,"<Tmp$Tool>.UnQuote <StrongED_Scrap$Dir>.out <StrongED_Scrap$Dir>.in")

	Key	^O
	Menu	Fix OE quoting
	Select	SetTmp() Process(Block,"<Tmp$Mode>.Tools.QuoteFix") Reformat()

	Icon	tidy
	Help	Hnws_tidy
	Select	SetTmp() Process(,"<Tmp$Mode>.Tools.Txtidy",,)
End

# Shortcuts for the news mode. Note that shortcuts that can be useful in other
# modes (like shortcut for email address) should be placed in BaseMode instead

Shortcuts
End
