Commit 5d92fa5b authored by Philipp's avatar Philipp

Initial import

parents
LightbarMenu PPE v0.1
Lightbar Menu for PCBoard
. Fully lightbar driven
. Scrolling of long menus
. Can start PPEs, display
files and text
. Multiple (sub-)menus
. Fully configurable
. Source included
<c> 2019 stimpy {cbd}
4 ; XPos of first list entry
12 ; YPos of first list entry
75 ; Max. length of each line
10 ; Height of menu (before scrolling)
@X0F ; Default color
@X1B ; Hilight color
Entry #1 title ; Entry #1 title
!d:\pcb\ppl\ustats\agsstats.ppe ; Entry #1 PPE file
Entry #2 title ; Entry #2 title
%d:\pcb\gen\stats.pcb ; Entry #2 PCB file
Entry #3 title ; Entry #3 ....
Just some string to display...
Entry #4 title
!d:\pcb\ppl\menu\menu.ppe submenu
Entry #5 title
d:\pcb\ppl\foo\bar.ppe
Entry #6 title
d:\pcb\ppl\foo\bar.ppe
Entry #7 title
d:\pcb\ppl\foo\bar.ppe
Entry #8 title
d:\pcb\ppl\foo\bar.ppe
Entry #9 title
d:\pcb\ppl\foo\bar.ppe
Entry #10 title
d:\pcb\ppl\foo\bar.ppe
Entry #11 title
d:\pcb\ppl\foo\bar.ppe
Entry #12 title
d:\pcb\ppl\foo\bar.ppe
Entry #13 title
d:\pcb\ppl\foo\bar.ppe
Entry #14 title
d:\pcb\ppl\foo\bar.ppe
Entry #15 title
d:\pcb\ppl\foo\bar.ppe
; Empty line (important!)
\ No newline at end of file
@X07 @X08@X07
@X08 @X0F @X08 @X0F @X08 @X0F @X08 @X0F @X08@X07@X70[@X74@X78/@X74@X78/@X748@X78/@X742@X70]@X07
@X08 @X0F @X08@X07@X70Move up/down@X07
@X08 @X0F @X08@X07@X70[@X74/@X78/@X744@X78/@X746@X70]@X07
@X08 @X0F @X08@X07@X70Page up/down@X07
@X08 @X0F @X08@X07@X70[@X74ENTER@X70]@X07
@X08 @X0F @X08@X07@X70Select@X07
@X08 @X0F @X08@X07@X70[@X74ESC@X70]@X07
@X08 @X0F @X08 @X0F @X08 @X0F @X08 @X0F @X08@X07@X70Exit@X07
@X08@X07
@X08 @X07@X0F
@X07
@X08
@X78
@X08 @X7F
@X0F @X07@X08
File added
; LightbarMenu v0.1
; (C)opyright 2019 by Philipp Giebel <stimpy@kuehlbox.wtf>
;
; Licensed under MIT License:
; https://opensource.org/licenses/MIT
;
; Repository:
; https://gitlab.ambhost.net/stimpy/ppe_menu
;
; See README.md for more information...
;
declare procedure ReadConfig()
declare procedure DrawMenu(byte lstart )
declare procedure LBMenu()
declare procedure PrintLBLine( byte xpos, byte ypos, string col, string line )
declare procedure ReadMenu()
declare procedure ClearList( byte start )
declare procedure RunMenu( byte pos )
declare function Center( string in ) string
byte xpos
byte ypos
byte width
byte height
byte numentries
string entries(100)
string cmds(100)
string hlcol
string locol
string menuname
begin
if ( TokCount() > 0 ) then
menuname = GetToken()
else
menuname = "menu"
endif
ReadConfig()
ReadMenu()
cls
AnsiPos 1, 1
print "@POFF@"
if ( exist( PPEPath() + menuname+".pcb" ) ) then
DispFile PPEPath() + menuname+".pcb", DEFS
elseif ( exist( PPEPath() +"menu.pcb" ) ) then
DispFile PPEPath() +"menu.pcb", DEFS
endif
DrawMenu( 1 )
LBMenu()
end
procedure RunMenu( byte pos )
begin
if ( left( cmds(pos), 1 ) == "%" ) then
DispFile Mid( cmds(pos), 2, len( cmds(pos)-1 ) ), DEFS
wait
else
DispStr cmds(pos)
endif
endproc
procedure PrintLBLine( byte xpos, byte ypos, string col, string line )
begin
ansipos xpos, ypos
print col + Center( line )
if ( col != locol ) print locol
endproc
procedure LBMenu()
begin
integer pos
integer opos
integer lpos
integer olpos
integer lstart
integer olstart
boolean finished
boolean keypress
string key
pos = 1
opos = 1
lpos = 1
olpos = 1
lstart = 1
olstart = 1
finished = 0
keypress = 1
while ( !finished ) do
key = Upper( InKey() )
select case ( key )
case "HOME", "H", "1"
opos = pos
pos = 1
olpos = lpos
lpos = 1
lstart = 1
keypress = 1
case "END", "E"
opos = pos
pos = numentries
if ( height > numentries ) then
olpos = lpos
lpos = numentries
lstart = 1
else
olpos = lpos
lpos = height
if ( olpos < lpos-height ) olpos = height
lstart = numentries-height+1
endif
keypress = 1
case "PGUP", "-", "[", "LEFT", "4"
if ( pos-height > 1 ) then
pos = pos-height ;+lpos
if ( pos < lpos ) then
lpos = pos
olpos = pos
endif
else
pos = lpos
endif
if ( lstart-height > 1 ) then
lstart = lstart - height
else
lstart = 1
endif
keypress = 1
case "PGDN", "+", "]", "RIGHT", "6"
if ( pos+height < numentries-height+1 ) then
pos = pos+height+lpos
else
pos = numentries-height+lpos
endif
if ( lstart+height <= numentries-height ) then
lstart = lstart + height
else
lstart = numentries-height+1
endif
keypress = 1
case "UP", "8"
if ( pos > 1 ) then
Dec pos
if ( lpos > 1 ) Dec lpos
if ( pos < lstart ) Dec lstart
else
opos = pos
pos = numentries
if ( height > pos ) then
lpos = pos
else
lpos = height
endif
lstart = numentries-height+1
if ( lstart < 0 ) lstart = 1
endif
keypress = 1
case "DOWN", "2"
if ( pos < numentries ) then
Inc pos
if ( pos > height ) then
if ( lpos == height ) Inc lstart
endif
if ( lpos < height ) Inc lpos
else
opos = pos
pos = 1
lstart = 1
lpos = 1
endif
keypress = 1
case chr(13)
finished = 1
case chr(27)
finished = 1
pos = 0
end select
if ( olstart <> lstart ) then
DrawMenu( lstart )
olstart = lstart
endif
if ( keypress ) then
; enable for debugging
; ansipos 1,22
; print "opos: "+ string(opos) +"; pos: "+ string(pos) +"; olpos: "+ string(olpos)
; print "; lpos: "+ string(lpos) +"; lstart: "+ string(lstart) +"; keypress: "+ string(keypress)
PrintLBLine( xpos, ypos+lpos-1, hlcol, entries(pos) )
keypress = 0
endif
if ( opos <> pos ) then
if ( olpos <= height ) then
if ( ( olpos > 0 ) && ( lpos <> olpos ) && ( ( ( opos < pos ) && ( opos >= pos-height ) ) || ( ( opos > pos ) && ( opos <= pos+height ) ) ) ) then
PrintLBLine( xpos, ypos+olpos-1, locol, entries(opos) )
endif
endif
olpos = lpos
opos = pos
endif
endwhile
ansipos 1,23
if ( pos > 0 ) then
RunMenu(pos)
else
pos = 1
lpos = 1
endif
endproc
function Center( string in ) string
begin
byte half
half = ( width - len( StripAtX( in ) )-1 )/2
center = space( half ) + in + space( half )
if ( ( width - len( StripAtX( in ) )-1 )%2 > 0 ) then
center = center+" "
endif
endfunc
procedure DrawMenu( byte lstart )
begin
byte c
byte l
byte half
boolean runit
l = lstart
c = 1
runit = 1
while ( runit ) do
if ( entries(l) != "" ) then
if ( c <= height ) then
half = ( width - len( StripAtX( entries(l) ) )-1 )/2
ansipos xpos, ypos-1+c
print locol + Center( entries(l) )
inc c
inc l
else
runit = 0
endif
else
runit = 0
endif
endwhile
ClearList( l )
endproc
procedure ClearList( byte start )
begin
byte i
for i = start to height
ansipos xpos, ypos-1+i
print locol+space( width )
next
endproc
procedure ReadMenu()
begin
byte c
byte l
boolean runit
if ( exist( PPEPath()+menuname+".cfg" ) ) then
c = 1
l = 7
runit = 1
while ( runit ) do
entries(c) = trim( left( readline( ppepath()+menuname+".cfg", l ), 68 ), " " )
if ( entries(c) == "" ) then
runit = 0
else if ( c > 99 ) then
runit = 0
else
Inc l
cmds(c) = trim( left( readline( ppepath()+menuname+".cfg", l ), 68 ), " " )
Inc l
Inc c
endif
endwhile
numentries = c-1
else
printLN "Configfile missing: "+ menuname +".CFG"
end
endif
endproc
procedure ReadConfig()
begin
xpos = 4
ypos = 10
width = 74
height = 10
locol = "@X0F"
hlcol = "@X1F"
if ( exist( PPEPath()+menuname+".cfg" ) ) then
xpos = s2i( trim( left( readline( PPEPath()+menuname+".cfg", 1 ), 2 ), " " ), 10 )
ypos = s2i( trim( left( readline( PPEPath()+menuname+".cfg", 2 ), 2 ), " " ), 10 )
width = s2i( trim( left( readline( PPEPath()+menuname+".cfg", 3 ), 2 ), " " ), 10 )
height = s2i( trim( left( readline( PPEPath()+menuname+".cfg", 4 ), 2 ), " " ), 10 )
locol = trim( left( readline( PPEPath()+menuname+".cfg", 5 ), 4 ), " " )
hlcol = trim( left( readline( PPEPath()+menuname+".cfg", 6 ), 4 ), " " )
else
printLN "Configfile missing: "+ menuname +".CFG"
end
endif
endproc
# LightbarMenu v0.1
Copyright 2019 Philipp Giebel <stimpy@kuehlbox.wtf>
Licensed under the MIT License: https://opensource.org/licenses/MIT
## Introduction
LightbarMenu is... You guessed it... ;)
It's featuring multiple configurations, submenus, custom backgrounds per
menu / configuration, execution of PPEs, display of files and strings, up to
99 entries per menu and, well, lightbar navigation complete with
page up / down, home and end.
## Configuration
1. Create a new config file or copy MENU.CFG as an example, then edit to your
needs following the comments in the example configuration.
Starting with line 7, you find the menu items, followed by the commands to run
on each following line:
Menu entry #1
!d:\pcb\ppl\some.ppe parameter
Menu entry #2
%d:\pcb\gen\some.pcb
Menu entry #3
Some text...
Commands can start with "!" to run a PPE, "%" to display a file or nothing at
all to just output the line as text.
The last line has to be empty to mark the end.
2. Create a new background .PCB with the same name as your configuration.
E.g: If your configuration is called "FOO.CFG", the background has to be called
"FOO.PCB".
If omitted or not found, the default "MENU.PCB" will be used.
## Installation
3. Add a command for starting that LightbarMenu to your CMD.LST:
Start PCBSETUP, then hit "B" twice. Navigate to your CMD.LST, then press "F2"
to edit. Press Alt-I to insert a new line, which could look like that:
| Command | Sec | minute | use | PPE File Specification |
|-----------|------:|---------:|------:|:---------------------------------|
| FOO | 20 | 0 | 0 | D:\PCB\PPL\MENU\MENU.PPE FOO |
You can add as many menus and configurations as you want, you can even call
menu from inside a menu to create submenus.
## Support
To be honest, I don't know if I WILL still support this in a year.. ;)
That's, why I licensed it under the MIT License and included the source,
so you can do whatever your want with it, as long as you include me as the
original author.
That said, there is that GitLab, I host:
> https://gitlab.ambhost.net/stimpy/ppe_lbmenu
There, you can file issues and/or requests and always find the latest
version of the script.
## Source code
I've included the sourcecode, so you can modify, fix, enhance and make it
your own...
As of v0.1, the code is still pretty messy, but hey: I just re-started
coding PPL after almost 25 years, just two weeks ago and coding at a
screensize of 25x80 characters is kinda annoying.. ;)
I'll clean it up, later.. (tm) ;)
## Download
You can always find the latest version of LightbarMenu at my GitLab:
> https://gitlab.ambhost.net/stimpy/ppe_lbmenu
## Demo
You can see this script in action in my BBS called
"Da CyberDawg" (long story.. ;) ) at
> telnet://kuehlbox.wtf:1337
or
> https://kuehlbox.wtf/cyberdawg
for a web-client.
## Motivation
"Why the hell PPE in 2019!?", you might ask...
"For my 2019 PCBoard BBS at telnet://kuehlbox.wtf:1337 " is my answer...
"But why, for fucks sake, a PCBoard BBS in 2019!?", you might ask then...
...But then let me ask you a question: Why did you read all this up to this
very line, if you're not a PCBoard SysOp in 2019 yourself?
C'mon! Get a hobby! Like being a PCBoard SysOp for example... ;)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment