message_area_selection_with_lightbars
% lightbar msg area selector
% by ck
{
@ int maxCmd = 256 % maximum msg areas
@ byte maxLen = 50 % maximum msg area description length
@ byte curCmd = 1 % current lightbar position
@ str<maxLen>(maxCmd) menu
proc doMenu[byte numCmd] {
@ int longest, x, z, ty, tx, Top, WinSize
proc barOn[byte Num] {
gotoxy[tx-1,ty+Num-Top]
cout["@X1F "+strSize[menu(Num),longest]+" "]
}
proc barOff[byte Num] {
gotoxy[tx-1,ty+Num-Top]
cout["@X08 "+strSize[menu(Num),longest]+" "]
}
proc RedrawCmds {
@ int i
i = curCmd
for curCmd = Top to Top+WinSize-1 do if curCmd = i then barOn[curCmd] else barOff[curCmd]
curCmd = i
}
longest = 0 % find the longest msg area name
% to know where to put the list
% and the size of the lightbar
% (to center the list)
for x = 1 to numCmd do {
z = strLen[strnocolor[menu(x)]]
if z > longest then longest = z
}
ty = 3 % list starts at y = 3
tx = 40-(longest/2) % center the list
WinSize = 20 % Window size of the area list
Top = 1
z = curCmd
for curCmd = Top to Top+WinSize-1 do if curCmd = z then barOn[curCmd] else barOff[curCmd]
curCmd = z
RedrawCmds
@ str key
key = ""
while (not key = #13) and (not hangup) do
{
key = inkey
if (key = #80) or (key = " ") then % down or space pressed
{
barOff[curCmd]
if curCmd = NumCmd then % if at the end of the list
% go back to the first item
{
curCmd = 1
Top = curCmd
RedrawCmds
}
else
curCmd = curCmd + 1
z = curCmd - Top
if z >= WinSize then
{
Top = Top + 1
RedrawCmds
} else barOn[curCmd]
}
if (key = #72) then % up pressed
{
barOff[curCmd]
if curCmd = 1 then
{
curCmd = NumCmd
Top = curCmd - WinSize + 1
if Top < 1 then Top = 1
RedrawCmds
}
else
curCmd = curCmd - 1
if (curCmd < Top) then
{
Top = Top - 1
RedrawCmds
} else barOn[curCmd]
}
}
}
@ int i
@ int numCmd = 0
initmalist % load a list of areas to which user has access
for i = 1 to numMa do
if (i <= maxCmd) then
{
getma[i] % load msg area #i
menu(i) = maname
numCmd = numCmd + 1
}
setcolor[7,0]
clrscr
doMenu[numCmd]
setcolor[7,0]
getma[curCmd] % set the current msg area to selected item
}
message_area_selection_with_lightbars.txt · Last modified: by admin
