^bind ^E end_of_line
^bind ^O self_insert
^bind ^_ self_insert
^bind ^B self_insert
^bind ^A beginning_of_line
for (@ii=0, ii<=9, @ii++) {^bind meta1-$ii parse_command ^window swap $ii}
^set channel_name_width 0
^set cdcc_prompt %K[%ccdcc%K]%n
^set beep_on_msg none
^set status_does_expandos on
^set mode_stripper on
^set clock_format %I:%M%p
@ savevars = [a.path a.pager a.urlgrab a.awaymsg a.backmsg a.autoaway a.aawtime a.aawmsg a.logprom pubansi a.email echo a.rlasc a.rkick a.pkick a.mckick dict.server tab_levels a.nmatchpats a.tname a.dispname a.lcctcp a.pubaway a.awaynot a.awaynotim a.fsync a.rkickm a.pkickm a.mkickm a.topbar a.tkexp]
@ a.tkexp = 10
@ a.topbar = [off]
@ a.ncchars = [: ,]
@ a.awaynotime = 120
@ a.fsync = [off]
@ a.awaynot = [on]
@ a.pubaway = [on]
@ a.recycle = [off]
@ a.lcctcp = [off]
@ a.dispname = [on]
@ a.nmatchpats = [%n %n? %n* ?%n *%n ?%n? *%n*]
@ a.path = [~/argon/etc]
@ a.varsave = [$(a.path)/vars.sav]
@ a.msglogfile = [$(a.path)/msglog.s]
@ a.grab = [$(a.path)/grab.s]
@ a.ilinefile = [$(a.path)/ilines.s]
@ a.memofile = [$(a.path)/memos.s]
@ a.botfile = [$(a.path)/bots.s]
@ a.fkeyfile = [$(a.path)/fkeys.s]
@ a.msglog = [on]
@ a.pager = [on]
@ a.rlasc = [off]
@ a.urlgrab = [off]
@ a.cinfo = [ ]
@ a.awaymsg = [outta hear?]
@ a.backmsg = [hi.]
@ a.autoaway = [on]
@ a.aawtime = 10
@ a.aawmsg = [auto-away \(%mm\)]
@ a.logprom = [off]
@ a.rkick = [off]
@ a.pkick = [off]
@ a.mckick = [off]
@ a.rkickm = [don't repeat repeat yourself!]
@ a.pkickm = [punctuation limit exceeded!!!!]
@ a.tkncomp = [on]
@ a.mkickm = [mirc colors<*]
@ grab.patterns = [*ftp:* *http:*]
@ tab_levels = [msg wall ar dmsg ftp]
@ _lame.versions = [*mirc* *ircle* *homer* *pirch* *ircn* *7thsphere*]
@ pubansi = [off]
@ a.loglevels = [msg notice join mode connect disconnect dcc_connect ctcp public_other_ar invite dcc_error kick_user startlog closelog]
@ _uhost = _userhost($N)
@ _uptime.i = uptime()
@ dict.server = [dict.org]
@ a.email = X
do ^window add $sar(g/ /,/$mychannels())

@ delarray(fkeys)
@ setitem(fkeys 0 user)
@ setitem(fkeys 1 scan $$C)

^bind meta3-A parse_command dok 0
^bind meta3-B parse_command dok 1
^bind meta3-C parse_command dok 2
^bind meta3-D parse_command dok 3
^bind meta3-E parse_command dok 4
^bind meta3-F parse_command dok 5
^bind meta3-G parse_command dok 6
^bind meta3-H parse_command dok 7
^bind meta3-I parse_command dok 8

^bind meta2-M parse_command dok 0
^bind meta2-N parse_command dok 1
^bind meta2-O parse_command dok 2
^bind meta2-P parse_command dok 3
^bind meta2-Q parse_command dok 4
^bind meta2-R parse_command dok 5
^bind meta2-S parse_command dok 6
^bind meta2-T parse_command dok 7
^bind meta2-U parse_command dok 8
alias dok {
  ^bind ~ nothing
  ^local aa $getitem(fkeys $0)
  if (aa) {$aa}
  ^timer 1 ^bind ~ self_insert}

alias tlevel {setflag tab_levels,tabkey levels,$*}
alias apath {setflag a.path,argon savefile path,$*}
alias pager {setflag a.pager,paging,$*}
alias recycle {setflag a.recycle,cycle empty channels,$*}
alias awaym {setflag a.awaymsg,default away message,$*}
alias backm {setflag a.backmsg,default back message,$*}
alias pubansi {setflag pubansi,public ansi,$*}
alias rlasc {setflag a.rlasc,ascending relay list,$*}
alias autoaway {setflag a.autoaway,auto-away,$*}
alias automsg {setflag a.aawmsg,auto-away message,$*}
alias autotime {setflag a.aawtime,auto-away time,$*}
alias logprom {setflag a.logprom,readlog prompting on /back,$*}
alias urlgrab {setflag a.urlgrab,url grabber,$*}
alias email {setflag a.email,e-mail address,$*}
alias pkick {setflag a.pkick,punctuation kicker,$*}
alias rkick {setflag a.rkick,repeat kicker,$*}
alias mkick {setflag a.mckick,mirc color kicker,$*}
alias lvers {setflag _lame.versions,lame versions,$*}
alias fsync {setflag a.fsync,improved /sc sorting,$*}
alias dserv {setflag dict.server,dictionary server,$*}
alias lvar {@ function_return = flag($0) ? [on] : [off]}
alias gvar {@ function_return = [$($0)]}

alias clearconfig {
  @ delarray(config.t)
  @ delarray(config.n)
  @ delarray(config.v)}

alias addconfig {
  @ setitem(config.$0 $numitems(config.$0) $1-)}

alias cfg config
alias config if ([$0]) {
  ^local nn.
  @ nn.1 = numitems(config.t)
  @ nn.2 = nn.1 + numitems(config.n)
  @ nn.3 = nn.2 + numitems(config.v)
  @ nn.1x = numitems(config.t) + 1
  @ nn.2x = (nn.1 + numitems(config.n)) + 1
  @ nn.3x = (nn.2 + numitems(config.v)) + 1
  if (0 < [$0] && [$0] <= nn.1) {
      @ $leftw(1 $getitem(config.t ${[$0]-1})) = not($($leftw(1 $getitem(config.t ${[$0]-1}))))
      if (afterw($leftw(1 $getitem(config.t ${[$0]-1})) $getitem(config.t ${[$0]-1})) == [topicbar]) {^window split $a.topbar}
      ge toggled $(c.hk)[$(c.lc)$afterw($leftw(1 $getitem(config.t ${[$0]-1})) $getitem(config.t ${[$0]-1}))$(c.hk)]: $(cl)$lvar($leftw(1 $getitem(config.t ${[$0]-1})))} elsif (nn.1 < [$0] && [$0] <= nn.2) {
    if ([$1] && isnum($1)) {
      @ $leftw(1 $getitem(config.n ${[$0]-nn.1x})) = [$1]
      ge set $(c.hk)[$(c.lc)$afterw($leftw(1 $getitem(config.n ${[$0]-nn.1x})) $getitem(config.n ${[$0]-nn.1x}))$(c.hk)]: $(cl)$($leftw(1 $getitem(config.n ${[$0]-nn.1x})))} else {
      ${!isnum($1) ? {ge error: specified value must be a number.} : {ge $(c.hk)[$(c.lc)$afterw($leftw(1 $getitem(config.n ${[$0]-nn.1x})) $getitem(config.n ${[$0]-nn.1x}))$(c.hk)]$(cl) is currently$(c.hk): $(cl)$($leftw(1 $getitem(config.n ${[$0]-nn.1x})))}}}} elsif (nn.2 < [$0] && [$0] <= nn.3) {
      if ([$1]) {
        @ $leftw(1 $getitem(config.v ${[$0]-nn.2x})) = [$1-]
        ge set $(c.hk)[$(c.lc)$afterw($leftw(1 $getitem(config.v ${[$0]-nn.2x})) $getitem(config.v ${[$0]-nn.2x}))$(c.hk)]: $(cl)$($leftw(1 $getitem(config.v ${[$0]-nn.2x})))} else {
        ge $(c.hk)[$(c.lc)$afterw($leftw(1 $getitem(config.v ${[$0]-nn.2x})) $getitem(config.v ${[$0]-nn.2x}))$(c.hk)]$(cl) is currently$(c.hk): $(cl)$($leftw(1 $getitem(config.v ${[$0]-nn.2x})))}} else {
    ge number is out of range!}} else {
  ^local i,co.,lines,null
  echo $box.head()
  checklin
  echo $box.echo_head(argon configuration$(c.hk).$(cl). /config $(c.lm)\($(cl)#$(c.lm)\) \($(cl)value$(c.lm)\)$(cl) to change.)
  checklin
  echo $box.echo($(c.hk)ÄÄ $(cl)toggles $(c.hk)$repeat(${70-15} Ä)$(cl))
  checklin
  for (@i=0,i<numitems(config.t),@i=i+2) {
  echo $box.echo($(c.hk)[$(c.lc)$[-2]rs(${i+1})$(c.hk)]$(cl) $numdots(21 $afterw($word(0 $getitem(config.t $i)) $getitem(config.t $i))) $(c.hk)[$(cl)$[-3]lvar($leftw(1 $getitem(config.t $i)))$(c.hk)] ${(i+1)<numitems(config.t)?[\[$(c.lc)$[-2]rs(${i+2})$(c.hk)\]$(cl) $numdots(21 $afterw($word(0 $getitem(config.t ${i+1})) $getitem(config.t ${i+1}))) $(c.hk)\[$(cl)$[-3]lvar($leftw(1 $getitem(config.t ${i+1})))$(c.hk)\]$(cl)]:});checklin}
  @ co.o += numitems(config.t)
  echo $box.echo($(c.hk)ÄÄ $(cl)numeric values $(c.hk)$repeat(${70-22} Ä)$(cl))
  checklin
  for (@i=0,i<numitems(config.n),@i=i+2) {
  echo $box.echo($(c.hk)[$(c.lc)$[-2]rs(${i+co.o+1})$(c.hk)]$(cl) $numdots(21 $afterw($word(0 $getitem(config.n $i)) $getitem(config.n $i))) $(c.hk)[$(cl)$[-3]gvar($leftw(1 $getitem(config.n $i)))$(c.hk)] ${(i+1)<numitems(config.n)?[\[$(c.lc)$[-2]rs(${i+co.o+2})$(c.hk)\]$(cl) $numdots(21 $afterw($word(0 $getitem(config.n ${i+1})) $getitem(config.n ${i+1}))) $(c.hk)\[$(cl)$[-3]gvar($leftw(1 $getitem(config.n ${i+1})))$(c.hk)\]$(cl)]:});checklin}
  echo $box.echo($(c.hk)ÄÄ $(cl)strings $(c.hk)$repeat(${70-15} Ä)$(cl))
  checklin
  @ co.o += numitems(config.n)
  for (@i=0,i<numitems(config.v),@i=i+1) {
  echo $box.echo($(c.hk)[$(c.lc)$[-2]rs(${i+co.o+1})$(c.hk)]$(cl) $numdots(21 $afterw($word(0 $getitem(config.v $i)) $getitem(config.v $i))) $(c.hk)[$(cl)$_apad(37 $gvar($leftw(1 $getitem(config.v $i))))$(c.hk)]);checklin}
  echo $box.footer()
  nulllin
}

alias checklin {
  ^local null
  @ lines++
  if (lines > winsize()) {
    @ null = [$"press enter to continue.. "]
    @ lines = 0}}

alias nulllin {
  @ lines = 0}

clearconfig
addconfig v a.path argon savefile path
addconfig t a.msglog message logging
addconfig t a.pager pager
addconfig t a.urlgrab urlgrab
addconfig v grab.patterns urlgrab patterns
addconfig t a.autoaway auto-away
addconfig n a.aawtime auto-away time
addconfig v a.aawmsg auto-away msg
addconfig v a.awaymsg default away message
addconfig v a.backmsg default back message
addconfig t a.logprom prompt for log
addconfig t pubansi public ansi
addconfig t a.pkick punctuation kicker
addconfig t a.rkick repeat kicker
addconfig t a.mckick mirc color kicker
addconfig v _lame.versions lame version kicks
addconfig v a.email e-mail address
addconfig t a.rlasc ascending relay list
addconfig v dict.server dictionary server
addconfig v tab_levels tabkey levels
addconfig v a.nmatchpats nickcomp matching
addconfig t a.dispname display theme name
addconfig t a.lcctcp lowercase CTCP
addconfig t a.pubaway public away
addconfig t a.awaynot away notice
addconfig n a.awaynotime away notice time
addconfig t a.fsync improved /sc sorting
addconfig v a.rkickm repeat kick msg
addconfig v a.pkickm punctuation kick msg
addconfig v a.mkickm mirc kick msg
addconfig t a.tkncomp tabkey nickcomp
addconfig t a.topbar topicbar
addconfig n a.tkexp tabkey expiry time
addconfig t a.recycle cycle empty channels
# fkey setup
alias fkey {
  switch ($*) {
  (-s) {
    savearray $a.fkeyfile fkeys ge loaded fkey setup created $strftime(%x)@$strftime(%X).
    ge fkey settings saved in $a.fkeyfile\.}
  (*) {
    if ([$*]) {
      if ((isdigit($0))&&([$0]<=9)&&[$0]!=0) {
        if ([$1]) {
          @ setitem(fkeys ${[$0] - 1} $1-)
          ge fkey $0 now set to \"$1-\".} else {
          ^local aa $getitem(fkeys ${[$0] - 1})
          if (aa) {
            ge fkey $0 set to \"$aa\".} else {
            ge fkey $0 is currently empty.}}} else {
        ge $0 is out of range (1-9 is valid).}} else {
      echo $box.head()
      echo $box.echo_head($(c.hw)$numdots(5 fkey) $(c.hw)$numdots(40 commands))
      for (@xx=1, xx < 10, @xx++) {
        ^local bb $getitem(fkeys ${xx - 1})
        echo $box.echo($(cl)$numdots(5 $xx) $(cl)$numdots(40 ${bb ? bb : [-empty-]}))}
      echo $box.footer()}}}}
