----------------------------------------------------------------------
--- Knud van Eeden --- 06 April 2008 - 08:42 pm ----------------------
Computer: Editor: TSE: Macro: Template.s: How to add the abbreviation definition to the list view?
---
Steps: Overview:
1. -After adding some text to the file template.s
(located in the ..\mac directory of your TSE installation)
--- cut here: begin --------------------------------------------------
integer proc ListTemplates()
integer id, line, list_all, msg_level, n
string curr_ext[EXT_LEN]
STRING s[255] = "" // added [kn, ri, su, 06-04-2008 19:17:25]
line = 0
curr_ext = ExtensionType()
id = GotoBufferId(ctrl_id)
Hook(_LIST_STARTUP_, ListStartup)
list_all = FALSE
loop
EmptyBuffer(list_id)
GotoBufferId(ctrl_id)
// generate file
// if not list_all and NumLines() // old [kn, ri, su, 04-05-2008 23:08:24]
if NumLines()
BegFile()
repeat
//
s = GetText( 1, CurrLineLen() ) // added [kn, ri, su, 06-04-2008 19:17:25]
PushPosition() // added [kn, ri, su, 06-04-2008 19:17:25]
EditFile( template_fn ) // added [kn, ri, su, 06-04-2008 19:17:25]
GotoLine( Val( Trim( SubStr( s, 25, 32 - 25 + 1 ) ) ) ) // added [kn, ri, su, 06-04-2008 19:17:25]
Down() // added [kn, ri, su, 06-04-2008 19:17:25]
s = LeftStr( s, 25 ) + " " + GetText( 1, CurrLineLen() ) // added [kn, ri, su, 06-04-2008 19:17:25]
PopPosition() // added [kn, ri, su, 06-04-2008 19:17:25]
//
if list_all
AddLine(s, list_id)
elseif ( not list_all )
case trim( GetText(CTRL_pEXT, CTRL_lEXT) )
when '', curr_ext
AddLine( s, list_id )
endcase
endif
//
until not Down()
EditFile( template_fn ) // added [kn, ri, su, 06-04-2008 19:17:25]
AbandonFile() // added [kn, ri, su, 06-04-2008 19:24:20]
// GotoBufferId(list_id) // old [kn, ri, su, 04-05-2008 23:07:39]
endif
GotoBufferId(list_id) // new [kn, ri, su, 04-05-2008 23:07:47]
if NumLines()
PushBlock()
MarkColumn(1,1,NumLines(), LIST_WIDTH )
msg_level = Set(MsgLevel, _NONE_)
Sort(_IGNORE_CASE_)
Set(MsgLevel, msg_level)
BegFile()
// n = lList("Templates", LIST_WIDTH, NumLines(), _BLOCK_SEARCH_ | _ENABLE_SEARCH_ | _ANCHOR_SEARCH_) // old [kn, ri, su, 06-04-2008 19:18:52]
n = lList("Templates", LIST_WIDTH + 100, NumLines(), _BLOCK_SEARCH_ | _ENABLE_SEARCH_ | _ANCHOR_SEARCH_) // new [kn, ri, su, 06-04-2008 19:18:52]
PopBlock()
case n
when listENTER
line = CtrlLine()
break
when listDEL
DelTemplate()
when listINS
AddTemplate()
when listTOGGLE
list_all = not list_all
when listESCAPE
break
endcase
else
if not list_all
list_all = TRUE
else
Warn("No templates exist")
break
endif
endif
endloop
UnHook(ListStartup)
EmptyBuffer(list_id)
GotoBufferId(id)
if line
PushBlock()
Expand(line)
PopBlock()
endif
return (line)
end
--- cut here: end ----------------------------------------------------
2. -This does the following:
1. -Extracts the line number (e.g. 10000) where to find the start of the template
2. -Then opens the file template.dat
3. -Then goes to that line number (e.g. 10000)
4. -Extracts the first line of the abbreviation/template text below
5. -And adds it to the list (in addline(...))
===
Screencast: see also:
Adding template definition to list
===
Internet: see also:
===
Image: see also:
===
Video: see also:
---
----------------------------------------------------------------------