IRC-Client: last functional changes for first release

This commit is contained in:
Jörg Deckert 2014-01-26 19:53:50 +01:00
parent a76f4cdd98
commit aebd98e497
3 changed files with 313 additions and 100 deletions

100
lib/led-engine.spin Normal file
View File

@ -0,0 +1,100 @@
{{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// E555 Light Emitting Diode Engine
//
// Author: Kwabena W. Agyeman
// Updated: 7/27/2010
// Designed For: P8X32A
// Version: 1.1
//
// Copyright (c) 2010 Kwabena W. Agyeman
// See end of file for terms of use.
//
// Update History:
//
// v1.0 - Original release - 1/26/2010.
// v1.1 - Added support for variable pin assignments - 7/27/2010.
//
// For each included copy of this object only one spin interpreter should access it at a time.
//
// Nyamekye,
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// LED Circuit:
//
// LEDPinNumber --- LED Driver (Active High).
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}}
PUB LEDFrequency(newFrequency, LEDPinNumber) '' 11 Stack Longs
'' ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'' // Changes the light emitting diode frequency using the SPIN interpreter's counters. Brightness will be set to zero.
'' //
'' // NewFrequency - The new frequency. Between 0 Hz and 80MHz @ 80MHz. -1 to reset the pin and counter modules.
'' // LEDPinNumber - Pin to use to drive the LED circuit. Between 0 and 31.
'' ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LEDSetup((newFrequency <> -1), LEDPinNumber, true)
newFrequency := ((newFrequency <# clkfreq) #> 0)
result := 1
repeat 32
newFrequency <<= 1
result <-= 1
if(newFrequency => clkfreq)
newFrequency -= clkfreq
result += 1
frqa := result~
PUB LEDBrightness(newBrightness, LEDPinNumber) '' 11 Stack Longs
'' ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'' // Changes the light emitting diode brightness using the SPIN interpreter's counters. Frequency will be set to zero.
'' //
'' // NewBrightness - The new brightness. Between 0% and 100%. -1 to reset the pin and counter modules.
'' // LEDPinNumber - Pin to use to drive the LED circuit. Between 0 and 31.
'' ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LEDSetup((newBrightness <> -1), LEDPinNumber, false)
frqb := (((newBrightness <# 100) #> 0) * constant(posx / 50))
PRI LEDSetup(activeOrInactive, LEDPinNumber, frequencyOrBrightness) ' 6 Stack Longs
LEDPinNumber := ((LEDPinNumber <# 31) #> 0)
dira[LEDPinNumber] := activeOrInactive
outa[LEDPinNumber] := false
ctra := (((constant(%0_0100 << 26) + LEDPinNumber) & activeOrInactive) & frequencyOrBrightness)
ctrb := (((constant(%0_0110 << 26) + LEDPinNumber) & activeOrInactive) & (not(frequencyOrBrightness)))
spr[2 - frequencyOrBrightness] := 0
spr[10 - frequencyOrBrightness] := 0
spr[12 - frequencyOrBrightness] := 0
{{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TERMS OF USE: MIT License
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}}

View File

@ -1197,6 +1197,7 @@ PRI lan_connect | ipaddr, remoteport, handle, handleidx, i
i++ i++
ifnot (handle := sock.connect(ipaddr, remoteport, @bufrx[i*rxlen], rxlen, @buftx[i*txlen], txlen)) == -102 ifnot (handle := sock.connect(ipaddr, remoteport, @bufrx[i*rxlen], rxlen, @buftx[i*txlen], txlen)) == -102
sock.resetBuffers(handle)
handleidx := handle.byte[0] 'extract the handle index from the lower 8 bits handleidx := handle.byte[0] 'extract the handle index from the lower 8 bits
sockhandle[handleidx] := handle 'komplettes handle zu handle index speichern sockhandle[handleidx] := handle 'komplettes handle zu handle index speichern
bufidx[i] :=handleidx bufidx[i] :=handleidx

View File

@ -35,6 +35,7 @@ OBJ
str: "glob-string" str: "glob-string"
num: "glob-numbers" 'Number Engine num: "glob-numbers" 'Number Engine
gc : "glob-con" gc : "glob-con"
led: "led-engine"
CON CON
@ -66,6 +67,7 @@ LEN_NICK = 32
LEN_USER = 32 LEN_USER = 32
LEN_CHAN = 32 LEN_CHAN = 32
LEN_IRCLINE = 512 LEN_IRCLINE = 512
LEN_IRCSRV = 64
MAX_LINES_WIN1 = 1000 ' maximale Zeilenanzahl im Puffer für Fenster 1 (Chat) MAX_LINES_WIN1 = 1000 ' maximale Zeilenanzahl im Puffer für Fenster 1 (Chat)
MAX_LINES_WIN2 = 1000 ' maximale Zeilenanzahl im Puffer für Fenster 2 (Status) MAX_LINES_WIN2 = 1000 ' maximale Zeilenanzahl im Puffer für Fenster 2 (Status)
@ -85,7 +87,9 @@ VAR
long t1char 'Empfangs-Zeitpunkt des 1. Zeichen einer Zeile long t1char 'Empfangs-Zeitpunkt des 1. Zeichen einer Zeile
long ip_addr long ip_addr
long hiveid long hiveid
long ledcog
long bufstart[4] long bufstart[4]
long ledstack[30] 'Stack für LED-Cog
word buflinenr[4] word buflinenr[4]
word scrolllinenr[4] word scrolllinenr[4]
word ip_port word ip_port
@ -93,14 +97,16 @@ VAR
word sendpos word sendpos
byte handleidx 'Handle-Nummer IRC Verbindung byte handleidx 'Handle-Nummer IRC Verbindung
byte rows,cols,vidmod byte rows,cols,vidmod
byte joined
byte x0[4], y0[4], xn[4], yn[4], hy[4], buflinelen, focus byte x0[4], y0[4], xn[4], yn[4], hy[4], buflinelen, focus
byte password[LEN_PASS+1],nickname[LEN_NICK+1],username[LEN_USER+1],channel[LEN_CHAN+1] byte password[LEN_PASS+1],nickname[LEN_NICK+1],username[LEN_USER+1],channel[LEN_CHAN+1],ircsrv[LEN_IRCSRV+1]
byte input_str[64] byte input_str[64]
byte temp_str[256] byte temp_str[256]
byte print_str[256] byte print_str[256]
byte print_str_ptr byte print_str_ptr
byte send_str[LEN_IRCLINE] byte send_str[LEN_IRCLINE]
byte receive_str[LEN_IRCLINE] byte receive_str[LEN_IRCLINE]
byte brightness
PUB main | key PUB main | key
@ -108,6 +114,7 @@ PUB main | key
repeat repeat
if ios.keystat > 0 if ios.keystat > 0
ledStop
key := ios.key key := ios.key
case key case key
gc#KEY_TAB: f_focus gc#KEY_TAB: f_focus
@ -129,13 +136,16 @@ PRI init
ip_port := 0 ip_port := 0
readpos := 0 readpos := 0
sendpos := 0 sendpos := 0
ledcog := 0
handleidx := $FF handleidx := $FF
password[0] := 0 password[0] := 0
nickname[0] := 0 nickname[0] := 0
username[0] := 0 username[0] := 0
channel[0] := 0 channel[0] := 0
send_str[0] := 0 send_str[0] := 0
ircsrv[0] := 0
focus := 3 focus := 3
joined := FALSE
ios.start 'ios initialisieren ios.start 'ios initialisieren
ifnot (ios.admgetspec & LANMASK) ifnot (ios.admgetspec & LANMASK)
@ -373,6 +383,8 @@ PRI conf_load | i
PRI ircConnect | t PRI ircConnect | t
joined := FALSE
handleStatusStr(string("Verbinde mit IRC-Server..."), 2, TRUE) handleStatusStr(string("Verbinde mit IRC-Server..."), 2, TRUE)
ios.lanstart ios.lanstart
if (handleidx := ios.lan_connect(ip_addr, ip_port)) == $FF if (handleidx := ios.lan_connect(ip_addr, ip_port)) == $FF
@ -395,6 +407,8 @@ PRI ircClose
handleidx := $FF handleidx := $FF
handleStatusStr(string("Verbindung mit IRC-Server getrennt..."), 2, TRUE) handleStatusStr(string("Verbindung mit IRC-Server getrennt..."), 2, TRUE)
title_draw
PRI ircPass PRI ircPass
handleStatusStr(string("Sende Paßwort..."), 2, TRUE) handleStatusStr(string("Sende Paßwort..."), 2, TRUE)
@ -402,17 +416,18 @@ PRI ircPass
handleStatusStr(string("Fehler beim Senden des Paßwortes"), 2, TRUE) handleStatusStr(string("Fehler beim Senden des Paßwortes"), 2, TRUE)
return(-1) return(-1)
PRI ircReg PRI ircNick
if strsize(@channel) == 0
handleStatusStr(string("Sende Nickname und Benutzerinformationen..."), 2, TRUE)
else
handleStatusStr(string("Sende Nickname und Benutzer, verbinde mit Channel..."), 2, TRUE)
if sendStr(string("NICK ")) or sendStr(@nickname) or sendStr(string(13,10)) if sendStr(string("NICK ")) or sendStr(@nickname) or sendStr(string(13,10))
handleStatusStr(string("Fehler beim Senden des Nicknamens"), 2, TRUE) handleStatusStr(string("Fehler beim Senden des Nicknamens"), 2, TRUE)
return(-1) return(-1)
PRI ircReg
handleStatusStr(string("Sende Nickname und Benutzerinformationen..."), 2, TRUE)
ircNick
if sendStr(string("USER ")) or sendStr(@username) or sendStr(string(" 8 * :Hive #")) or sendStr(str.trimCharacters(num.ToStr(hiveid, num#DEC))) or sendStr(string(13,10)) if sendStr(string("USER ")) or sendStr(@username) or sendStr(string(" 8 * :Hive #")) or sendStr(str.trimCharacters(num.ToStr(hiveid, num#DEC))) or sendStr(string(13,10))
handleStatusStr(string("Fehler beim Senden der Benutzerinformationen"), 2, TRUE) handleStatusStr(string("Fehler beim Senden der Benutzerinformationen"), 2, TRUE)
return(-1) return(-1)
@ -426,6 +441,22 @@ PRI ircJoin
handleStatusStr(string("Fehler beim Verbinden mit Channel"), 2, TRUE) handleStatusStr(string("Fehler beim Verbinden mit Channel"), 2, TRUE)
return(-1) return(-1)
joined := TRUE
title_draw
PRI ircPart
sendStr(string("PART "))
sendStr(@channel)
if send_str[5] == " "
sendStr(@send_str[5])
sendStr(string(13,10))
channel[0] := 0
handleChatStr(@channel, @nickname, @send_str, 1)
joined := FALSE
title_draw
PRI ircGetLine | i, x, prefixstr, nickstr, chanstr, msgstr, commandstr PRI ircGetLine | i, x, prefixstr, nickstr, chanstr, msgstr, commandstr
if readLine(2000) 'vollständige Zeile empfangen if readLine(2000) 'vollständige Zeile empfangen
@ -438,7 +469,7 @@ PRI ircGetLine | i, x, prefixstr, nickstr, chanstr, msgstr, commandstr
prefixstr := 0 prefixstr := 0
commandstr := @receive_str 'es geht gleich mit dem Kommando los commandstr := @receive_str 'es geht gleich mit dem Kommando los
if str.findCharacters(commandstr, string("PRIVMSG ")) == commandstr 'Chat Message if str.startsWithCharacters(commandstr, string("PRIVMSG ")) 'Chat Message
chanstr := commandstr + 8 chanstr := commandstr + 8
if (msgstr := str.replaceCharacter(chanstr, " ", 0)) if (msgstr := str.replaceCharacter(chanstr, " ", 0))
msgstr++ msgstr++
@ -456,16 +487,17 @@ PRI ircGetLine | i, x, prefixstr, nickstr, chanstr, msgstr, commandstr
sendStr(nickstr) sendStr(nickstr)
sendStr(string(" :VERSION HiveIRC 1.0.0 [P8X32A/80MHz] <http://hive-project.de/>",13,10)) sendStr(string(" :VERSION HiveIRC 1.0.0 [P8X32A/80MHz] <http://hive-project.de/>",13,10))
else else
ledStart
if byte[chanstr] == "#" 'Message an Channel if byte[chanstr] == "#" 'Message an Channel
handleChatStr(chanstr, nickstr, msgstr, 0) handleChatStr(chanstr, nickstr, msgstr, 0)
else 'Message an mich else 'Message an mich
handleChatStr(string("<priv>"), nickstr, msgstr, 2) handleChatStr(string("<priv>"), nickstr, msgstr, 2)
elseif str.findCharacters(commandstr, string("PING :")) == commandstr 'PING elseif str.startsWithCharacters(commandstr, string("PING :")) 'PING
handleStatusStr(string("PING erhalten, sende PONG"), 2, TRUE) handleStatusStr(string("PING erhalten, sende PONG"), 2, TRUE)
byte[commandstr][1] := "O" byte[commandstr][1] := "O"
sendStr(commandstr) sendStr(commandstr)
sendStr(string(13,10)) sendStr(string(13,10))
elseif str.findCharacters(commandstr, string("JOIN :")) == commandstr 'JOIN elseif str.startsWithCharacters(commandstr, string("JOIN ")) 'JOIN
if (str.replaceCharacter(prefixstr, "!", 0)) if (str.replaceCharacter(prefixstr, "!", 0))
repeat x from 0 to strsize(prefixstr) - 1 repeat x from 0 to strsize(prefixstr) - 1
temp_str[x] := byte[prefixstr][x] temp_str[x] := byte[prefixstr][x]
@ -474,7 +506,7 @@ PRI ircGetLine | i, x, prefixstr, nickstr, chanstr, msgstr, commandstr
temp_str[x++] := byte[msgstr][i] temp_str[x++] := byte[msgstr][i]
temp_str[x] := 0 temp_str[x] := 0
handleStatusStr(@temp_str, 2, TRUE) handleStatusStr(@temp_str, 2, TRUE)
elseif str.findCharacters(commandstr, string("QUIT :")) == commandstr 'QUIT elseif str.startsWithCharacters(commandstr, string("PART ")) 'PART
if (str.replaceCharacter(prefixstr, "!", 0)) if (str.replaceCharacter(prefixstr, "!", 0))
repeat x from 0 to strsize(prefixstr) - 1 repeat x from 0 to strsize(prefixstr) - 1
temp_str[x] := byte[prefixstr][x] temp_str[x] := byte[prefixstr][x]
@ -483,12 +515,49 @@ PRI ircGetLine | i, x, prefixstr, nickstr, chanstr, msgstr, commandstr
temp_str[x++] := byte[msgstr][i] temp_str[x++] := byte[msgstr][i]
temp_str[x] := 0 temp_str[x] := 0
handleStatusStr(@temp_str, 2, TRUE) handleStatusStr(@temp_str, 2, TRUE)
elseif str.startsWithCharacters(commandstr, string("QUIT :")) 'QUIT
if (str.replaceCharacter(prefixstr, "!", 0))
repeat x from 0 to strsize(prefixstr) - 1
temp_str[x] := byte[prefixstr][x]
msgstr := string(" hat den Server verlassen")
repeat i from 0 to strsize(msgstr) - 1
temp_str[x++] := byte[msgstr][i]
temp_str[x] := 0
handleStatusStr(@temp_str, 2, TRUE)
elseif str.startsWithCharacters(commandstr, string("NOTICE ")) 'Notiz
elseif str.startsWithCharacters(commandstr, string("MODE ")) 'Mode
elseif str.startsWithCharacters(commandstr, string("NICK ")) 'Nick
if (str.replaceCharacter(prefixstr, "!", 0))
repeat x from 0 to strsize(prefixstr) - 1
temp_str[x] := byte[prefixstr][x]
msgstr := string(" hat seinen Nicknamen geändert in ")
repeat i from 0 to strsize(msgstr) - 1
temp_str[x++] := byte[msgstr][i]
msgstr := commandstr + 5
if byte[msgstr] == ":"
msgstr++
repeat i from 0 to strsize(msgstr) - 1
temp_str[x++] := byte[msgstr][i]
temp_str[x] := 0
handleStatusStr(@temp_str, 2, TRUE)
elseif byte[commandstr][3] == " " 'Kommando 3 Zeichen lang -> 3stelliger Returncode elseif byte[commandstr][3] == " " 'Kommando 3 Zeichen lang -> 3stelliger Returncode
byte[commandstr][3] := 0 byte[commandstr][3] := 0
nickstr := commandstr + 4 nickstr := commandstr + 4
msgstr := str.replaceCharacter(nickstr, " ", 0) msgstr := str.replaceCharacter(nickstr, " ", 0)
case num.FromStr(commandstr, num#DEC) case num.FromStr(commandstr, num#DEC)
372: handleStatusStr(msgstr + 3, 1, FALSE) 'MOTD 1: if prefixstr
msgstr := string("Verbunden mit ")
repeat x from 0 to strsize(msgstr) - 1
temp_str[x] := byte[msgstr][x]
repeat i from 0 to LEN_IRCSRV
ircsrv[i] := byte[prefixstr][i]
temp_str[x++] := byte[prefixstr][i]
if byte[prefixstr][i] == 0
quit
ircsrv[LEN_IRCSRV] := 0
handleStatusStr(@temp_str, 2, TRUE)
title_draw
372: handleStatusStr(msgstr + 3, 1, FALSE) 'MOTD
375..376: 375..376:
other: repeat x from 0 to strsize(commandstr) - 1 'unbehandelter Return-Code other: repeat x from 0 to strsize(commandstr) - 1 'unbehandelter Return-Code
temp_str[x] := byte[commandstr][x] temp_str[x] := byte[commandstr][x]
@ -502,6 +571,8 @@ PRI ircGetLine | i, x, prefixstr, nickstr, chanstr, msgstr, commandstr
handleStatusStr(@temp_str, 2, TRUE) handleStatusStr(@temp_str, 2, TRUE)
else 'unbekanntes Kommando else 'unbekanntes Kommando
handleStatusStr(commandstr, 2, FALSE) handleStatusStr(commandstr, 2, FALSE)
ios.winset(3)
ios.curon
PRI ircPutLine | i PRI ircPutLine | i
@ -510,37 +581,57 @@ PRI ircPutLine | i
elseif str.startsWithCharacters(@send_str, string("/save")) 'Konfiguration speichern elseif str.startsWithCharacters(@send_str, string("/save")) 'Konfiguration speichern
confSave confSave
elseif str.startsWithCharacters(@send_str, string("/srv")) 'mit Server verbinden elseif str.startsWithCharacters(@send_str, string("/srv")) 'mit Server verbinden
if confServer 'wenn Eingabe IP und Port korrekt if send_str[4] == " " and send_str[5] <> " " and send_str[5] <> 0 'Nick als Parameter angegeben
win_contentRefresh ifnot strToIpPort(@send_str[5], @ip_addr, @ip_port)
ircClose 'bei bestehender Verbindung diese beenden handleStatusStr(string("Fehlerhafte Eingabe von IP-Adresse und Port des IRC-Servers."), 2, TRUE)
ircConnect return (FALSE)
ircPass
ircReg
else else
win_contentRefresh ifnot confServer 'Eingabefenster
win_contentRefresh
return(FALSE)
else
win_contentRefresh
ircClose 'bei bestehender Verbindung diese beenden
ircConnect
ircPass
ircReg
elseif str.startsWithCharacters(@send_str, string("/quit")) 'Verbindung mit Server trennen elseif str.startsWithCharacters(@send_str, string("/quit")) 'Verbindung mit Server trennen
ircClose ircClose
elseif str.startsWithCharacters(@send_str, string("/pass")) 'Paßwort ändern elseif str.startsWithCharacters(@send_str, string("/pass")) 'Paßwort ändern
confPass confPass
win_contentRefresh win_contentRefresh
handleStatusStr(string("Paßwort geändert, zum Anwenden neu verbinden"), 2, FALSE)
elseif str.startsWithCharacters(@send_str, string("/nick")) 'Nickname ändern elseif str.startsWithCharacters(@send_str, string("/nick")) 'Nickname ändern
confNick if send_str[5] == " " and send_str[6] <> " " and send_str[6] <> 0 'Nick als Parameter angegeben
win_contentRefresh repeat i from 0 to LEN_NICK
nickname[i] := send_str[6+i]
if send_str[6+i] == 0
quit
channel[LEN_NICK] := 0
else
confNick
win_contentRefresh
ircNick
elseif str.startsWithCharacters(@send_str, string("/user")) 'User ändern elseif str.startsWithCharacters(@send_str, string("/user")) 'User ändern
confUser confUser
win_contentRefresh win_contentRefresh
handleStatusStr(string("User geändert, zum Anwenden neu verbinden"), 2, FALSE)
elseif str.startsWithCharacters(@send_str, string("/join")) 'mit Channel verbinden elseif str.startsWithCharacters(@send_str, string("/join")) 'mit Channel verbinden
confChannel if joined
win_contentRefresh handleStatusStr(string("Kanal bereits betreten, vorher mit /part verlassen"), 2, FALSE)
ircJoin else
if send_str[5] == " " and send_str[6] == "#" 'Channel als Parameter angegeben
repeat i from 0 to LEN_CHAN
channel[i] := send_str[6+i]
if send_str[6+i] == 0
quit
channel[LEN_IRCSRV] := 0
else
confChannel
win_contentRefresh
ircJoin
elseif str.startsWithCharacters(@send_str, string("/part")) 'Channel verlassen elseif str.startsWithCharacters(@send_str, string("/part")) 'Channel verlassen
sendStr(string("PART ")) ircPart
sendStr(@channel)
if send_str[5] == " "
sendStr(@send_str[5])
sendStr(string(13,10))
channel[0] := 0
handleChatStr(@channel, @nickname, @send_str, 1)
elseif str.startsWithCharacters(@send_str, string("/msg")) 'Message an Nickname elseif str.startsWithCharacters(@send_str, string("/msg")) 'Message an Nickname
sendStr(string("PRIVMSG ")) sendStr(string("PRIVMSG "))
if (i := str.replaceCharacter(@send_str[5], " ", 0)) if (i := str.replaceCharacter(@send_str[5], " ", 0))
@ -561,17 +652,34 @@ PRI ircPutLine | i
sendStr(string(13,10)) sendStr(string(13,10))
handleChatStr(@channel, @nickname, @send_str, 1) handleChatStr(@channel, @nickname, @send_str, 1)
PRI frame_draw PRI title_draw | spaces, i
ios.winset(0) ios.winset(0)
ios.curoff ios.curoff
ios.printcls
ios.cursetx(W0X_MENU) ios.cursetx(W0X_MENU)
ios.cursety(W0Y_MENU) ios.cursety(W0Y_MENU)
ios.setcolor(COL_HEAD) ios.setcolor(COL_HEAD)
spaces := cols-W0X_MENU
ios.print(string(" IRC Client")) ios.print(string(" IRC Client"))
repeat cols-W0X_MENU-11 spaces -= 11
ios.printchar(" ") ifnot handleidx == $FF 'wenn verbunden
ios.print(string(" ("))
spaces -= 2
if joined
ios.print(@channel)
ios.printchar("@")
spaces -= strsize(@channel)+1
i := 0
repeat spaces - 1
if ircsrv[i] == 0 'Ende Servername erreicht
ios.printchar(" ")
else
ios.printchar(ircsrv[i])
if ircsrv[++i] == 0 'Ende Servername folgt
ios.printchar(")")
else
repeat spaces
ios.printchar(" ")
ios.printlogo(0,0) ios.printlogo(0,0)
PRI win_draw | i PRI win_draw | i
@ -701,7 +809,9 @@ PRI setscreen | buflen[4], i
repeat i from 0 to MAX_LINES_WIN3 - 1 'Fensterpuffer leeren repeat i from 0 to MAX_LINES_WIN3 - 1 'Fensterpuffer leeren
printStrBuf(3) printStrBuf(3)
frame_draw ios.winset(0)
ios.printcls
title_draw
win_draw win_draw
'Eingabe-Fenster (Nr. 4) 'Eingabe-Fenster (Nr. 4)
@ -722,7 +832,7 @@ PRI printTime | timeStr, i
print_str[print_str_ptr++] := byte[timeStr][i] print_str[print_str_ptr++] := byte[timeStr][i]
print_str[print_str_ptr++] := "]" print_str[print_str_ptr++] := "]"
PRI handleChatStr(chanstr, nickstr, msgstr, me) | i, channicklen, msglineend, ch, space PRI handleChatStr(chanstr, nickstr, msgstr, me) | i, timenicklen, msglineend, ch, space, lastline
'' ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ '' ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
'' │ Chat-Zeile erstellen, anzeigen und in Puffer schreiben │ '' │ Chat-Zeile erstellen, anzeigen und in Puffer schreiben │
'' | | '' | |
@ -734,81 +844,57 @@ PRI handleChatStr(chanstr, nickstr, msgstr, me) | i, channicklen, msglineend, ch
'' └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ '' └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
ios.winset(1) ios.winset(1)
print_str_ptr := 0 ' String neu beginnen lastline := FALSE 'letzte der erstellten Zeilen?
print_str_ptr := 0 'String neu beginnen
'1. Teilstring: Zeit '1. Teilstring: Zeit
print_str[print_str_ptr++] := COL_TIME 'Farbbyte print_str[print_str_ptr++] := COL_TIME 'Farbbyte
printTime printTime
print_str[print_str_ptr++] := 0 print_str[print_str_ptr++] := 0
'2. Teilstring: Channel '2. Teilstring: Nickname
if me == 2
print_str[print_str_ptr++] := COL_MYNICK 'Farbbyte
else
print_str[print_str_ptr++] := COL_CHAN 'Farbbyte
repeat i from 0 to strsize(chanstr) 'Länge Channel inkl. Abschluß-Null
print_str[print_str_ptr++] := byte[chanstr][i]
'3. Teilstring: Nickname
if me == 1 if me == 1
print_str[print_str_ptr++] := COL_MYNICK 'Farbbyte print_str[print_str_ptr++] := COL_MYNICK 'Farbbyte
else else
print_str[print_str_ptr++] := COL_NICK 'Farbbyte print_str[print_str_ptr++] := COL_NICK 'Farbbyte
print_str[print_str_ptr++] := ">" print_str[print_str_ptr++] := ">"
repeat i from 0 to strsize(nickstr) 'Länge Nickname inkl. Abschluß-Null repeat i from 0 to strsize(nickstr) - 1 'Länge Nickname ohne Abschluß-Null
print_str[print_str_ptr++] := byte[nickstr][i] print_str[print_str_ptr++] := byte[nickstr][i]
print_str[print_str_ptr++] := ":"
print_str[print_str_ptr++] := " "
print_str[print_str_ptr++] := 0
'4. Teilstring: 1. Teil der Mitteilung '3. Teilstring: 1. Teil der Mitteilung
if me == 1 if me == 1
print_str[print_str_ptr++] := COL_MYMSG 'Farbbyte print_str[print_str_ptr++] := COL_MYMSG 'Farbbyte
else else
print_str[print_str_ptr++] := COL_MSG 'Farbbyte print_str[print_str_ptr++] := COL_MSG 'Farbbyte
print_str[print_str_ptr++] := ":" timenicklen := strsize(nickstr) + 10
print_str[print_str_ptr++] := " " msglineend := cols - timenicklen -2
channicklen := strsize(chanstr) + strsize(nickstr) + 10 repeat until lastline
msglineend := cols - channicklen -2 if strsize(msgstr) =< msglineend 'msgline paßt auf Zeile
repeat lastline := TRUE
if strsize(msgstr) =< msglineend 'msgline paßt auf Zeile else 'msgline muß umgebrochen werden
repeat i from 0 to strsize(msgstr) 'Länge Mitteilung inkl. Abschluß-Null
print_str[print_str_ptr++] := byte[msgstr][i]
print_str[print_str_ptr++] := 0 'komplette Chat-Zeile fertig
print_str[print_str_ptr] := 0
print_str_ptr := 0
if scrolllinenr[1] == 0 'Chat-Fenster nicht gescrollt
ios.printnl
printStrWin(@print_str)
printStrBuf(1)
quit
else 'msgline muß umgebrochen werden
ch := byte[msgstr][msglineend] 'Zeichen am Zeilenende sichern ch := byte[msgstr][msglineend] 'Zeichen am Zeilenende sichern
byte[msgstr][msglineend] := 0 'Messagestring am Zeilenende abschließen byte[msgstr][msglineend] := 0 'Messagestring am Zeilenende abschließen
if (space := findCharacterBack(msgstr, " ")) 'wenn letztes Leerzeichen in msgstr gefunden if (space := findCharacterBack(msgstr, " ")) 'wenn letztes Leerzeichen in msgstr gefunden
byte[msgstr][msglineend] := ch 'Zeichen am Zeilenende wieder einfügen byte[msgstr][msglineend] := ch 'Zeichen am Zeilenende wieder einfügen
byte[space] := 0 'msgstr am letzten Leerzeichen abschließen byte[space] := 0 'msgstr am letzten Leerzeichen abschließen
repeat i from 0 to strsize(msgstr) 'und in print_str schreiben repeat i from 0 to strsize(msgstr) 'Länge Mitteilung inkl. Abschluß-Null
print_str[print_str_ptr++] := byte[msgstr][i] print_str[print_str_ptr++] := byte[msgstr][i]
print_str[print_str_ptr++] := 0 'komplette Chat-Zeile fertig, weitere folgt print_str[print_str_ptr++] := 0 'komplette Chat-Zeile fertig
print_str[print_str_ptr] := 0 print_str[print_str_ptr] := 0
print_str_ptr := 0 print_str_ptr := 0
if scrolllinenr[1] == 0 if scrolllinenr[1] == 0 'Chatfenster nicht gescrollt
ios.printnl ios.printnl
printStrWin(@print_str) printStrWin(@print_str) 'im Chatfenster anzeigen
printStrBuf(1) printStrBuf(1) 'in Fensterpuffer schreiben
else 'kein einziges Leerzeichen ifnot lastline 'wenn noch eine zeile folgt, diese bereits beginnen
repeat i from 0 to strsize(msgstr) 'in print_str schreiben
print_str[print_str_ptr++] := byte[msgstr][i]
print_str[print_str_ptr++] := 0 'komplette Chat-Zeile fertig, weitere folgt
print_str[print_str_ptr] := 0
print_str_ptr := 0
if scrolllinenr[1] == 0
ios.printnl
printStrWin(@print_str)
printStrBuf(1)
if me == 1 if me == 1
print_str[print_str_ptr++] := COL_MYMSG 'nach Zeilenumbruch beginnt neue Zeile wieder mit Farbbyte print_str[print_str_ptr++] := COL_MYMSG 'nach Zeilenumbruch beginnt neue Zeile wieder mit Farbbyte
else else
print_str[print_str_ptr++] := COL_MSG print_str[print_str_ptr++] := COL_MSG
repeat channicklen '"Tab" bis Ende Anzeige Channel + Nickname repeat timenicklen '"Tab" bis Ende Anzeige Channel + Nickname
print_str[print_str_ptr++] := " " print_str[print_str_ptr++] := " "
if space if space
msgstr := space + 1 msgstr := space + 1
@ -866,12 +952,12 @@ PRI handleStatusStr(statusstr, win, showtime) | i, statlineend
if showtime if showtime
print_str[print_str_ptr++] := COL_STTIME 'Farbbyte print_str[print_str_ptr++] := COL_STTIME 'Farbbyte
printTime printTime
print_str[print_str_ptr++] := " "
print_str[print_str_ptr++] := 0 print_str[print_str_ptr++] := 0
'2. Teilstring: Status '2. Teilstring: Status
print_str[print_str_ptr++] := COL_STDEFAULT 'Farbbyte print_str[print_str_ptr++] := COL_STDEFAULT 'Farbbyte
if showtime if showtime
print_str[print_str_ptr++] := " "
statlineend := cols - 10 statlineend := cols - 10
else else
statlineend := cols - 2 statlineend := cols - 2
@ -1010,18 +1096,19 @@ PUB input(strdesc, strdef, input_len) | i,n
byte[@input_str][i] := 0 byte[@input_str][i] := 0
ios.curon ios.curon
repeat 'entspricht ab hier ios.input repeat 'entspricht ab hier ios.input
n := ios.keywait 'auf taste warten n := ios.keywait 'auf taste warten
if n == $0d case n
quit $0d: quit 'Enter, Eingabe beenden
if (n == ios#CHAR_BS)&(i>0) 'backspace ios#CHAR_BS: if i > 0 'Zurück
ios.printbs ios.printbs
i-- i--
byte[@input_str][i] := 0 byte[@input_str][i] := 0
elseif i < input_len 'normales zeichen 9 .. 13, 32 .. 255: if i < input_len 'normales zeichen
ios.printchar(n) ios.printchar(n)
byte[@input_str][i] := n byte[@input_str][i] := n
i++ i++
byte[@input_str][i] := 0 byte[@input_str][i] := 0
ios.curoff ios.curoff
PRI readLine(timeout) : ch PRI readLine(timeout) : ch
@ -1039,6 +1126,10 @@ PRI readLine(timeout) : ch
readpos := 0 readpos := 0
return(TRUE) return(TRUE)
ifnot ios.lan_isConnected(handleidx) 'Verbindung unterbrochen
ircClose
return(FALSE)
if (readpos <> 0) and ((cnt - t1char) / (clkfreq / 1000) > timeout) 'Timeout seit Empfang 1. Zeichen if (readpos <> 0) and ((cnt - t1char) / (clkfreq / 1000) > timeout) 'Timeout seit Empfang 1. Zeichen
receive_str[readpos] := 0 receive_str[readpos] := 0
readpos := 0 readpos := 0
@ -1071,7 +1162,28 @@ PUB findCharacterBack(charactersToSearch, characterToFind) | i
return charactersToSearch + i return charactersToSearch + i
return 0 return 0
PRI ledStart
ifnot ledcog
ledcog := cognew(ledTwinkle(clkfreq/150), @ledstack)
PRI ledStop
if ledcog
cogstop(ledcog)
ledcog := 0
PRI ledTwinkle(rate)
repeat
repeat brightness from 0 to 100
led.LEDBrightness(brightness, gc#HBEAT) 'Adjust LED brightness
waitcnt(rate + cnt) 'Wait a moment
repeat brightness from 100 to 0
led.LEDBrightness(brightness,gc#HBEAT) 'Adjust LED brightness
waitcnt(rate + cnt) 'Wait a moment
DAT DAT
strWin1 byte "Chat",0 strWin1 byte "Chat",0