//-------------------------------------------------------------------- // STATUS.AML // -- modified by Jim Wilson // -- further additions by Glenn Tarigan 1997.04 // Custom Status Line Example, (C) 1993-1996 by nuText Systems // // This macro adds a customized status line to all edit windows on the // desktop, and also to new edit windows as they are opened. The status // line can be customized by modifying the event below. // // North title bar: // - type, width and length of the existing mark // - current position in file expressed as a percentage: // adjusts to 3 sig-figs for files with <100 lines, and changes to // 2 decimal places of accuracy for larger files // - the usual settings info, column and line number // // South title bar: (this is updated separately via a timer) // - hex and decimal ASCII value of char, with extended EOL indication // (shows "EL+" if you go past linelength+1) // - line length of current line // - current right_margin // - width and height of the current window's editing area // - position in the virtual screen (in relation to 16000,16000) // - whether or not the current line has been modified // - size of closed fold // - which of the shift-keys are currently being pressed // - date and time // // Usage: // Select this macro from the Macro List (on the Macro menu), or run it // from the macro picklist . Run this macro again to remove // the custom status line. //-------------------------------------------------------------------- include bootpath "define.aml" // status line update delay in milliseconds constant update_delay = 250 constant timer_id = "status" // check for a previous install if prf.altstatus then destroytimer timer_id settitle (upcase (getbufname)) 'dnl' '1' //** destroyobject prf.altstatus prf.altstatus = '' return end // install this object prf.altstatus = getcurrobj resident ON // set flags for edit windows private function setflags (flags) for window = getcurrwin to getbotwin by getprevwin window do if wintype? "edit" window then windowflag flags window end end end // remove custom status for all edit windows // when this object is destroyed event setflags '-s' end // turn on custom status for all existing edit windows setflags '+s' object edit // add custom status to new edit windows function onopen passprev windowflag '+s' end // Modify the south title bar to simulate an additional status line function southtitle HexChar = (bin2hex (getchar)) DecChar = (bin2int (getchar)) // Decimal ASCII value if HexChar == '' then if getcol > (getlinesize + 1) then HexChar = 'E+' // beyond the EOL DecChar = 'EL+' else HexChar = 'EL' // End-of-line char DecChar = 'EOL' end end today = case getrawtime [9] // abbreviate day of week to a single letter when '0' (char 15) when '4' "R" when '1' "M" when '5' "F" when '2' "T" when '6' "S" when '3' "W" end // The right side of the south title bar: farstat = "Aurora v" + getversion + " " + (upcase (getbootpath)) + "A.EXE " // current hour => a letter from A to X (eg, 16:00:00 => Q) + (char (getrawtime [10..11]) + 65) + ': 19' + getdate + today + ' ' + getrawtime [10..13] + '.' + getrawtime [14..15] // The left side of the south title bar: stat = '[' + HexChar + '] [' + DecChar:3:"0" + ']' + ' &L ' + getlinesize:-3 + ' R' + _RMargin + (char 32 16) + (getcoord "1x") // width of text area + (char 32 31) + (getcoord "1y") // height of text area + " x" + ((getcoord "l") - 16000) // virtual coord: left side + " y" + ((getcoord "t") - 16000) // virtual coord: top side + (if? (lineflag '?') " MOD" '') // modified line + (if? (getfold) 'f'+(getfold 's') '') // #lines in fold + ' ' + (if? (shiftkey? 02h) "#" '') // left shift is being pressed + (if? (shiftkey? 01h) "$" '') // right shift + (if? (shiftkey? 04h) "^" '') // ctrl + (if? (shiftkey? 08h) (char 21) '') // alt + (if? (shiftkey? 10h) "S" '') // scroll lock + (if? (shiftkey? 40h) "C" '') // caps lock + (if? (shiftkey? 20h) "N" '') // num lock + (char 222 32) // pad with spaces so that farstat appears on far right side buttons = 8 // this is the width of the button icons // the above line might not be necessary for other people num1 = getviewcols - (length stat) - buttons if length farstat > num1 then // trim left side to fit (the right side of farstat is more important) farstat = farstat [(length farstat) - num1 + 1:-1] end settitle stat + farstat:num1 'lhs' '3' end // return custom status line // (modify this function to suit your own preferences) event //** whole procedure changed FileName = gettitle '1' if FileName[2] == ':' then //** only change status line for file names! if bufchanged? then BufferFlag = '*' else BufferFlag = ' ' end Size = length FileName if Size > 23 then FileName = concat FileName [1..2] '..' FileName [(Size-19)..-1] //** end // Width and length of the existing mark if getmarkcols == 0 then thecols = char 249 249 249 // blank filler elseif getmarkcols > 999 then thecols = (getmarkcols:-2) + "K" // truncate to nearest thousand else thecols = getmarkcols end if getmarkrows == 0 then therows = char 249 249 249 // blank filler else therows = getmarkrows end // Calculate current position within the file as a percentage: percent = (getrow * 10000 / getlines):5 // raw format: xxxxx percent = ( percent [1..(if? (getlines > 9) (length getlines)+1 3)] ) // ^^^ adjust sig_figs based on size of file percent [4:0] = '.' // change to xxx.xx percent = (sub '. ' '.0' percent):6 + '% ' // add a zero if necessary settitle FileName 'dnl' '1' return (if mark? then getmarktype else '-' end) + (char 32 29) + thecols:3 + (char 32 18) + therows:(if? (therows < 999) 3 (length therows)) + ' ' + percent + getsettings + BufferFlag + ' C ' + getcol:-3 + ' L ' + getrow:(length getlines) + ' / ' + getlines end end // create timer to update status line time every second // (only needed if the time is displayed on the status line) setrepeat timer_id update_delay '' "southtitle"