about summary refs log tree commit diff stats
path: root/src/event
Commit message (Collapse)AuthorAgeFilesLines
...
* Add cl_ev_disconnectJames Booth2016-01-033-0/+23
|
* Fixed compilation without libotrJames Booth2016-01-031-0/+2
|
* End OTR session when recipient goes offlineJames Booth2016-01-031-0/+6
|
* Sort roster roomsJames Booth2016-01-021-2/+2
|
* Show rooms in roster panelJames Booth2016-01-021-0/+4
|
* Added /console commandJames Booth2015-12-291-0/+1
|
* Added console MUC message preferenceJames Booth2015-12-291-1/+6
|
* Don't compile pgp code with --disable-pgpDmitry Podgorny2015-12-211-0/+2
|
* Added cons_show_incoming_room_message()James Booth2015-12-201-5/+58
|
* Fixed PGP error messageJames Booth2015-12-191-1/+1
|
* Show PGP error stringsJames Booth2015-12-151-3/+13
|
* Moved sending of initial presence to sv_ev_roster_receivedJames Booth2015-12-141-0/+31
|
* Allow /quit during TLS certificate verification promptJames Booth2015-11-101-7/+16
|
* Show current TLS certificateJames Booth2015-11-102-53/+7
|
* Added /tls cert to show current certificate fingerprintJames Booth2015-11-091-0/+1
|
* Store current TLS certificate fingerpint in memory for reconnectJames Booth2015-11-091-0/+8
|
* Renamed MUC private window functionsJames Booth2015-11-082-3/+3
|
* ui_incoming_private_msg takes ProfPrivateWin, added assertsJames Booth2015-11-081-7/+17
|
* mucwin_broadcast takes ProfMucWinJames Booth2015-11-021-3/+6
|
* mucwin_subject takes ProfMucWinJames Booth2015-11-021-4/+5
|
* mucwin_requires_config takes ProfMucWinJames Booth2015-11-021-1/+3
|
* mucwin_message takes ProfMucWinJames Booth2015-11-021-1/+4
|
* mucwin_history takes ProfMucWinJames Booth2015-11-021-1/+4
|
* mucwin_nick_change takes ProfMucWinJames Booth2015-11-021-1/+4
|
* mucwin_occupant_nick_change takes ProfMucWinJames Booth2015-11-021-1/+4
|
* mucwin_occupant_presence takes ProfMucWinJames Booth2015-11-021-2/+3
|
* mucwin_occupant_online takes ProfMucWinJames Booth2015-11-011-2/+3
|
* mucwin_occupant_banned takes ProfMucWinJames Booth2015-11-011-1/+4
|
* mucwin_occupant_kicked takes ProfMucWinJames Booth2015-11-011-1/+4
|
* mucwin_occupant_offline takes ProfMucWinJames Booth2015-11-011-2/+3
|
* mucwin_roster takes ProfMucWinJames Booth2015-11-011-2/+3
|
* Tidy sv_ev_muc_occupant_onlineJames Booth2015-11-011-13/+5
|
* mucwin_occupant_role_and_affiliation_change takes ProfMucWinJames Booth2015-11-011-1/+4
|
* mucwin_occupant_affiliation_change takes ProfMucWinJames Booth2015-11-011-1/+4
|
* mucwin_occupant_role_change takes ProfMucWinJames Booth2015-11-011-1/+4
|
* Tidy sv_ev_muc_self_onlineJames Booth2015-11-011-13/+5
|
* mucwin_role_and_affiliation_change takes ProfMucWinJames Booth2015-11-011-1/+4
|
* mucwin_affiliation_change takes ProfMucWinJames Booth2015-11-011-1/+4
|
* mucwin_role_change takes ProfMucWinJames Booth2015-11-011-1/+4
|
* Renamed ui_room_broadcast -> mucwin_broadcastJames Booth2015-11-011-2/+2
|
* Renamed ui_room_subject -> mucwin_subjectJames Booth2015-11-011-2/+2
|
* Renamed ui_room_requires_config -> mucwin_requires_configJames Booth2015-11-011-1/+1
|
* Renamed ui_room_message -> mucwin_messageJames Booth2015-11-011-1/+1
|
* Renamed ui_room_history -> mucwin_historyJames Booth2015-11-011-1/+1
|
* Renamed ui_room_nick_change -> mucwin_nick_changeJames Booth2015-11-011-1/+1
|
* Renamed ui_room_member_nick_change -> mucwin_occupant_nick_changeJames Booth2015-11-011-1/+1
|
* Renamed ui_room_member_presence -> mucwin_occupant_presenceJames Booth2015-11-011-1/+1
|
* Renamed ui_room_member_online -> mucwin_occupant_onlineJames Booth2015-11-011-1/+1
|
* Renamed ui_room_member_banned -> mucwin_occupant_bannedJames Booth2015-11-011-1/+1
|
* Renamed ui_room_member_kicked -> mucwin_occupant_kickedJames Booth2015-11-011-1/+1
|
) if SetConsoleCursorPosition(conHandle, origin) == 0: OSError() else: stdout.write("\e[" & $x & 'G') when defined(windows): proc setCursorYPos*(y: int) = ## sets the terminal's cursor to the y position. The x position is ## not changed. **Warning**: This is not supported on UNIX! when defined(windows): var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO var hStdout = conHandle if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError() var origin = scrbuf.dwCursorPosition origin.y = int16(y) if SetConsoleCursorPosition(conHandle, origin) == 0: OSError() else: nil proc CursorUp*(count=1) = ## Moves the cursor up by `count` rows. when defined(windows): var p = getCursorPos() dec(p.y, count) setCursorPos(p.x, p.y) else: stdout.write("\e[" & $count & 'A') proc CursorDown*(count=1) = ## Moves the cursor down by `count` rows. when defined(windows): var p = getCursorPos() inc(p.y, count) setCursorPos(p.x, p.y) else: stdout.write("\e[" & $count & 'B') proc CursorForward*(count=1) = ## Moves the cursor forward by `count` columns. when defined(windows): var p = getCursorPos() inc(p.x, count) setCursorPos(p.x, p.y) else: stdout.write("\e[" & $count & 'C') proc CursorBackward*(count=1) = ## Moves the cursor backward by `count` columns. when defined(windows): var p = getCursorPos() dec(p.x, count) setCursorPos(p.x, p.y) else: stdout.write("\e[" & $count & 'D') when true: nil else: proc EraseLineEnd* = ## Erases from the current cursor position to the end of the current line. when defined(windows): nil else: stdout.write("\e[K") proc EraseLineStart* = ## Erases from the current cursor position to the start of the current line. when defined(windows): nil else: stdout.write("\e[1K") proc EraseDown* = ## Erases the screen from the current line down to the bottom of the screen. when defined(windows): nil else: stdout.write("\e[J") proc EraseUp* = ## Erases the screen from the current line up to the top of the screen. when defined(windows): nil else: stdout.write("\e[1J") proc EraseLine* = ## Erases the entire current line. when defined(windows): var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO var numwrote: DWORD var hStdout = conHandle if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError() var origin = scrbuf.dwCursorPosition origin.x = 0'i16 if SetConsoleCursorPosition(conHandle, origin) == 0: OSError() var ht = scrbuf.dwSize.Y - origin.Y var wt = scrbuf.dwSize.X - origin.X if FillConsoleOutputCharacter(hStdout,' ', ht*wt, origin, addr(numwrote)) == 0: OSError() if FillConsoleOutputAttribute(hStdout, scrbuf.wAttributes, ht * wt, scrbuf.dwCursorPosition, addr(numwrote)) == 0: OSError() else: stdout.write("\e[2K") setCursorXPos(0) proc EraseScreen* = ## Erases the screen with the background colour and moves the cursor to home. when defined(windows): var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO var numwrote: DWORD var origin: TCoord # is inititalized to 0, 0 var hStdout = conHandle if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError() if FillConsoleOutputCharacter(hStdout, ' ', scrbuf.dwSize.X*scrbuf.dwSize.Y, origin, addr(numwrote)) == 0: OSError() if FillConsoleOutputAttribute(hStdout, scrbuf.wAttributes, scrbuf.dwSize.X * scrbuf.dwSize.Y, origin, addr(numwrote)) == 0: OSError() setCursorXPos(0) else: stdout.write("\e[2J") proc ResetAttributes* {.noconv.} = ## resets all attributes; it is advisable to register this as a quit proc ## with ``system.addQuitProc(resetAttributes)``. when defined(windows): discard SetConsoleTextAttribute(conHandle, oldAttr) else: stdout.write("\e[0m") type TStyle* = enum ## different styles for text output styleBright = 1, ## bright text styleDim, ## dim text styleUnknown, ## unknown styleUnderscore = 4, ## underscored text styleBlink, ## blinking/bold text styleReverse, ## unknown styleHidden ## hidden text when not defined(windows): var gFG = 0 gBG = 0 proc WriteStyled*(txt: string, style: set[TStyle] = {styleBright}) = ## writes the text `txt` in a given `style`. when defined(windows): var a = 0'i16 if styleBright in style: a = a or int16(FOREGROUND_INTENSITY) if styleBlink in style: a = a or int16(BACKGROUND_INTENSITY) if styleReverse in style: a = a or 0x4000'i16 # COMMON_LVB_REVERSE_VIDEO if styleUnderscore in style: a = a or 0x8000'i16 # COMMON_LVB_UNDERSCORE var old = getAttributes() discard SetConsoleTextAttribute(conHandle, old or a) stdout.write(txt) discard SetConsoleTextAttribute(conHandle, old) else: for s in items(style): stdout.write("\e[" & $ord(s) & 'm') stdout.write(txt) resetAttributes() if gFG != 0: stdout.write("\e[" & $ord(gFG) & 'm') if gBG != 0: stdout.write("\e[" & $ord(gBG) & 'm') type TForegroundColor* = enum ## terminal's foreground colors fgBlack = 30, ## black fgRed, ## red fgGreen, ## green fgYellow, ## yellow fgBlue, ## blue fgMagenta, ## magenta fgCyan, ## cyan fgWhite ## white TBackgroundColor* = enum ## terminal's background colors bgBlack = 40, ## black bgRed, ## red bgGreen, ## green bgYellow, ## yellow bgBlue, ## blue bgMagenta, ## magenta bgCyan, ## cyan bgWhite ## white proc setForegroundColor*(fg: TForegroundColor, bright=false) = ## sets the terminal's foreground color when defined(windows): var old = getAttributes() and not 0x0007 if bright: old = old or FOREGROUND_INTENSITY const lookup: array [TForegroundColor, int] = [ 0, (FOREGROUND_RED), (FOREGROUND_GREEN), (FOREGROUND_RED or FOREGROUND_GREEN), (FOREGROUND_BLUE), (FOREGROUND_RED or FOREGROUND_BLUE), (FOREGROUND_BLUE or FOREGROUND_GREEN), (FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED)] discard SetConsoleTextAttribute(conHandle, toU16(old or lookup[fg])) else: gFG = ord(fg) if bright: inc(gFG, 60) stdout.write("\e[" & $gFG & 'm') proc setBackgroundColor*(bg: TBackgroundColor, bright=false) = ## sets the terminal's background color when defined(windows): var old = getAttributes() and not 0x0070 if bright: old = old or BACKGROUND_INTENSITY const lookup: array [TBackgroundColor, int] = [ 0, (BACKGROUND_RED), (BACKGROUND_GREEN), (BACKGROUND_RED or BACKGROUND_GREEN), (BACKGROUND_BLUE), (BACKGROUND_RED or BACKGROUND_BLUE), (BACKGROUND_BLUE or BACKGROUND_GREEN), (BACKGROUND_BLUE or BACKGROUND_GREEN or BACKGROUND_RED)] discard SetConsoleTextAttribute(conHandle, toU16(old or lookup[bg])) else: gBG = ord(bg) if bright: inc(gBG, 60) stdout.write("\e[" & $gBG & 'm') when isMainModule: system.addQuitProc(resetAttributes) write(stdout, "never mind") eraseLine() #setCursorPos(2, 2) writeStyled("styled text ", {styleBright, styleBlink, styleUnderscore}) setBackGroundColor(bgCyan, true) setForeGroundColor(fgBlue) writeln(stdout, "ordinary text")