initial committal (8.2.0.03)

This commit is contained in:
joten 2011-07-27 19:43:34 +02:00
commit aeaa677f95
13 changed files with 2977 additions and 0 deletions

2
.hgignore Normal file
View file

@ -0,0 +1,2 @@
syntax: glob
src/Session.ini

652
src/Bar.ahk Normal file
View file

@ -0,0 +1,652 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.2.0.03 (27.07.2011)
*/
Bar_init(m) {
Local appBarMsg, GuiN, h1, h2, i, text, trayWndId, w, wndId, wndTitle, wndWidth, x1, x2, y1, y2
If (SubStr(Config_barWidth, 0) = "%") {
StringTrimRight, Config_barWidth, Config_barWidth, 1
wndWidth := Monitor_#%m%_width * Config_barWidth / 100
} Else
wndWidth := Config_barWidth
Monitor_#%m%_barWidth := wndWidth
Bar_titleWidth := wndWidth
h1 := Bar_ctrlHeight
x1 := 0
x2 := wndWidth
y1 := 0
y2 := (Bar_ctrlHeight - Bar_textHeight) / 2
h2 := Bar_ctrlHeight - 2 * y2
; Create the GUI window
wndTitle := "bug.n_BAR_" m
GuiN := (m - 1) + 1
Gui, %GuiN%: Default
IfWinExist, %wndTitle%
Gui, Destroy
Gui, +LastFound -Caption +ToolWindow +AlwaysOnTop
Gui, Color, %Config_normBgColor2%
Gui, Font, c%Config_normFgColor1% s%Config_fontSize%, %Config_fontName%
; tags
Loop, % Config_viewCount {
i := A_Index
text := " " i " "
w := Bar_getTextWidth(text)
If (w <= h1)
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Vertical vBar_#%m%_#%i%_progress
Else
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% vBar_#%m%_#%i%_progress
Gui, Add, Text, x%x1% y%y2% w%w% h%h2% -Wrap Center BackgroundTrans vBar_#%m%_#%i% gBar_tagGuiClick, %text%
Bar_titleWidth -= w
x1 += w
}
; layout
i := Config_viewCount + 1
text := " ??? "
w := Bar_getTextWidth(text)
Gui, Font, c%Config_normFgColor2%
Gui, Add, Text, x%x1% y%y2% w%w% h%h2% -Wrap Center vBar_#%m%_#%i% gBar_layoutGuiClick, %text%
Bar_titleWidth -= w
x1 += w
; The x-position and width of the sub-windows right of the window title are set from the right.
Loop, 4 {
i := Config_viewCount + 7 - A_Index
w := 0
If (i = Config_viewCount + 6) { ; command gui
Gui, -Disabled
w := Bar_getTextWidth(" ?? ")
x2 -= w
Bar_titleWidth -= w
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center gBar_toggleCommandGui vBar_#%m%_#%i%, #!
} Else If (i = Config_viewCount + 5) And Config_readinTime { ; time
w := Bar_getTextWidth(" ??:?? ")
x2 -= w
Bar_titleWidth -= w
If Config_readinAny() Or Config_readinBat {
Gui, Font, c%Config_normFgColor1%
Gui, Add, Text, x%x2% y%y1% w%w% h%h1% -Background,
}
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, ??:??
} Else If (i = Config_viewCount + 4) And Config_readinAny() { ; any
text := Config_readinAny()
w += Bar_getTextWidth(text)
x2 -= w
Bar_titleWidth -= w
Gui, Font, c%Config_normFgColor2%
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center vBar_#%m%_#%i%, %text%
} Else If (i = Config_viewCount + 3) And Config_readinBat { ; battery level
w := Bar_getTextWidth(" BAT: ???% ")
x2 -= w
Bar_titleWidth -= w
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2% c%Config_normFgColor3% vBar_#%m%_#%i%_progress
Gui, Font, c%Config_normFgColor2%
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, BAT: ???`%
}
}
; window title (remaining space)
Gui, Add, Text, x%x1% y%y1% w%Bar_titleWidth% h%h1% -Background,
If Not Config_singleRowBar {
Bar_titleWidth := wndWidth
x1 := 0
y1 += h1
y2 += h1
}
i := Config_viewCount + 2
Gui, Font, c%Config_normFgColor1%
Gui, Add, Text, x%x1% y%y1% w%Bar_titleWidth% h%h1% -Background,
Gui, Add, Text, x%x1% y%y2% w%Bar_titleWidth% h%h2% BackgroundTrans Center vBar_#%m%_#%i%,
If (Config_horizontalBarPos = "left")
x1 := Monitor_#%m%_x
Else If (Config_horizontalBarPos = "right")
x1 := Monitor_#%m%_x + Monitor_#%m%_width - wndWidth
Else If (Config_horizontalBarPos = "center")
x1 := Monitor_#%m%_x + (Monitor_#%m%_width - wndWidth) / 2
Else If (Config_horizontalBarPos => 0)
x1 := Monitor_#%m%_x + Config_horizontalBarPos
Else If (Config_horizontalBarPos < 0)
x1 := Monitor_#%m%_x + Monitor_#%m%_width - wndWidth + Config_horizontalBarPos
Monitor_#%m%_barX := x1
y1 := Monitor_#%m%_barY
If Monitor_#%m%_showBar
Gui, Show, +NoActivate x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
Else
Gui, Show, +NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
wndId := WinExist(wndTitle)
If (Config_verticalBarPos = "tray") {
trayWndId := WinExist("ahk_class Shell_TrayWnd")
DllCall("SetParent", "UInt", wndId, "UInt", trayWndId)
} Else {
appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg")
; appBarData: http://msdn2.microsoft.com/en-us/library/ms538008.aspx
VarSetCapacity(Bar_appBarData, 36, 0)
offset := NumPut( 36, Bar_appBarData)
offset := NumPut( wndId, offset+0)
offset := NumPut( appBarMsg, offset+0)
offset := NumPut( 1, offset+0)
offset := NumPut( x1, offset+0)
offset := NumPut( y1, offset+0)
offset := NumPut( wndWidth, offset+0)
offset := NumPut(Bar_height, offset+0)
offset := NumPut( 1, offset+0)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_NEW := 0x0) , "UInt", &Bar_appBarData)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_QUERYPOS := 0x2), "UInt", &Bar_appBarData)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETPOS := 0x3) , "UInt", &Bar_appBarData)
; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
}
}
Bar_initCmdGui() {
Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_cmdGuiIsVisible, Config_fontName, Config_fontSize, Config_normBgColor1, Config_normFgColor1
Bar_cmdGuiIsVisible := False
wndTitle := "bug.n_BAR_0"
Gui, 99: Default
Gui, +LabelBar_cmdGui
IfWinExist, %wndTitle%
Gui, Destroy
Gui, +LastFound -Caption +ToolWindow +AlwaysOnTop
Gui, Color, Default
Gui, Font, s%Config_fontSize%, %Config_fontName%
Gui, Add, TreeView, x0 y0 r23 w300 Background%Config_normBgColor1% c%Config_normFgColor1% -ReadOnly vBar_#0_#0 gBar_cmdGuiEnter
GuiControl, -Redraw, Bar_#0_#0
itemId10 := TV_Add("Window")
itemId11 := TV_Add("set tag", itemId10)
TV_Add("all", itemId11)
TV_Add("Press <F2> to enter a number.", itemId11)
itemId12 := TV_Add("toggle tag", itemId10)
TV_Add("Press <F2> to enter a number.", itemId12)
TV_Add("move to top", itemId10)
TV_Add("move up", itemId10)
TV_Add("move down", itemId10)
TV_Add("toggle floating", itemId10)
TV_Add("toggle decor", itemId10)
TV_Add("close", itemId10)
TV_Add("maximize", itemId10)
TV_Add("move by key", itemId10)
TV_Add("resize by key", itemId10)
TV_Add("activate next", itemId10)
TV_Add("activate prev", itemId10)
TV_Add("move to next monitor", itemId10)
TV_Add("move to prev monitor", itemId10)
itemId20 := TV_Add("Layout")
TV_Add("set last", itemId20)
TV_Add("set 1st (tile)", itemId20)
TV_Add("set 2nd (monocle)", itemId20)
TV_Add("set 3rd (floating)", itemId20)
TV_Add("rotate layout axis", itemId20)
TV_Add("rotate master axis", itemId20)
TV_Add("rotate stack axis", itemId20)
TV_Add("mirror tile layout", itemId20)
TV_Add("increase master split", itemId20)
TV_Add("decrease master split", itemId20)
TV_Add("increase master factor", itemId20)
TV_Add("decrease master factor", itemId20)
itemId30 := TV_Add("View")
itemId31 := TV_Add("activate", itemId30)
TV_Add("last", itemId31)
TV_Add("Press <F2> to enter a number.", itemId31)
TV_Add("move to next monitor", itemId30)
TV_Add("move to prev monitor", itemId30)
itemId40 := TV_Add("Monitor")
TV_Add("toggle bar", itemId40)
TV_Add("toggle task bar", itemId40)
TV_Add("activate next", itemId40)
TV_Add("activate prev", itemId40)
TV_Add("Reload")
TV_Add("Quit")
GuiControl, +Redraw, Bar_#0_#0
Gui, Add, Button, Y0 Hidden Default gBar_cmdGuiEnter, OK
GuiControlGet, Bar_#0_#0, Pos
Gui, Show, Hide w%Bar_#0_#0W% h%Bar_#0_#0H%, %wndTitle%
}
Bar_cmdGuiEscape:
Bar_cmdGuiIsVisible := False
Gui, Cancel
WinActivate, ahk_id %Bar_aWndId%
Return
Bar_cmdGuiEnter:
If (A_GuiControl = "OK") Or (A_GuiControl = "BAR_#0_#0" And A_GuiControlEvent = "DoubleClick") {
Bar_selItemId_#1 := TV_GetSelection()
If Not TV_GetChild(Bar_selItemId_#1) {
Bar_selItemId_#2 := TV_GetParent(Bar_selItemId_#1)
Bar_selItemId_#3 := TV_GetParent(Bar_selItemId_#2)
TV_GetText(Bar_command_#1, Bar_selItemId_#1)
TV_GetText(Bar_command_#2, Bar_selItemId_#2)
TV_GetText(Bar_command_#3, Bar_selItemId_#3)
} Else
Bar_command_#1 := ""
Bar_cmdGuiIsVisible := False
Gui, Cancel
WinActivate, ahk_id %Bar_aWndId%
Bar_evaluateCommand()
}
Return
Bar_evaluateCommand() {
Global Bar_command_#1, Bar_command_#2, Bar_command_#3, Config_viewCount
If (Bar_command_#1) {
If (Bar_command_#2 = "Run")
Run, %Bar_command_#1%
Else If (Bar_command_#3 = "Window") {
If (Bar_command_#2 = "set tag") {
If (Bar_command_#1 = "all")
Monitor_setWindowTag(0)
Else If (RegExMatch(Bar_command_#1, "[0-9]+") And Bar_command_#1 <= Config_viewCount)
Monitor_setWindowTag(Bar_command_#1)
} Else If (Bar_command_#2 = "toggle tag")
If (RegExMatch(Bar_command_#1, "[0-9]+") And Bar_command_#1 <= Config_viewCount)
Monitor_toggleWindowTag(Bar_command_#1)
} Else If (Bar_command_#2 = "Window") {
If (Bar_command_#1 = "move to top")
View_shuffleWindow(0)
Else If (Bar_command_#1 = "move up")
View_shuffleWindow(-1)
Else If (Bar_command_#1 = "move down")
View_shuffleWindow(+1)
Else If (Bar_command_#1 = "toggle floating")
View_toggleFloating()
Else If (Bar_command_#1 = "toggle decor")
Manager_toggleDecor()
Else If (Bar_command_#1 = "close")
Manager_closeWindow()
Else If (Bar_command_#1 = "move by key")
Manager_moveWindow()
Else If (Bar_command_#1 = "resize by key")
Manager_sizeWindow()
Else If (Bar_command_#1 = "maximize")
Manager_maximizeWindow()
Else If (Bar_command_#1 = "activate next")
View_activateWindow(+1)
Else If (Bar_command_#1 = "activate prev")
View_activateWindow(-1)
Else If (Bar_command_#1 = "move to next monitor")
Manager_setWindowMonitor(+1)
Else If (Bar_command_#1 = "move to prev monitor")
Manager_setWindowMonitor(-1)
} Else If (Bar_command_#2 = "Layout") {
If (Bar_command_#1 = "set last")
View_setLayout(-1)
Else If (Bar_command_#1 = "set 1st (tile)")
View_setLayout(1)
Else If (Bar_command_#1 = "set 2nd (monocle)")
View_setLayout(2)
Else If (Bar_command_#1 = "set 3rd (floating)")
View_setLayout(3)
Else If (Bar_command_#1 = "rotate layout axis")
View_rotateLayoutAxis(1, +1)
Else If (Bar_command_#1 = "rotate master axis")
View_rotateLayoutAxis(2, +1)
Else If (Bar_command_#1 = "rotate stack axis")
View_rotateLayoutAxis(3, +1)
Else If (Bar_command_#1 = "mirror tile layout")
View_rotateLayoutAxis(1, +2)
Else If (Bar_command_#1 = "increase master split")
View_setMSplit(+1)
Else If (Bar_command_#1 = "decrease master split")
View_setMSplit(-1)
Else If (Bar_command_#1 = "increase master factor")
View_setMFactor(+0.05)
Else If (Bar_command_#1 = "decrease master factor")
View_setMFactor(-0.05)
} Else If (Bar_command_#3 = "View") {
If (Bar_command_#2 = "activate") {
If (Bar_command_#1 = "last")
Monitor_activateView(-1)
Else If (RegExMatch(Bar_command_#1, "[0-9]+") And Bar_command_#1 <= Config_viewCount)
Monitor_activateView(Bar_command_#1)
}
} Else If (Bar_command_#2 = "View") {
If (Bar_command_#1 = "move to next monitor")
Manager_setViewMonitor(+1)
Else If (Bar_command_#1 = "move to prev monitor")
Manager_setViewMonitor(-1)
} Else If (Bar_command_#2 = "Monitor") {
If (Bar_command_#1 = "toggle bar")
Monitor_toggleBar()
Else If (Bar_command_#1 = "toggle task bar")
Monitor_toggleTaskBar()
Else If (Bar_command_#1 = "activate next")
Manager_activateMonitor(+1)
Else If (Bar_command_#1 = "activate prev")
Manager_activateMonitor(-1)
} Else If (Bar_command_#1 = "Reload")
Reload
Else If (Bar_command_#1 = "Quit")
ExitApp
Bar_command_#1 := ""
Bar_command_#2 := ""
Bar_command_#3 := ""
}
}
Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) {
VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4))
success := DllCall("GetSystemPowerStatus", "UInt", &powerStatus)
If (ErrorLevel != 0 OR success = 0) {
MsgBox 16, Power Status, Can't get the power status...
Return
}
acLineStatus := Bar_getInteger(powerStatus, 0, false, 1)
batteryLifePercent := Bar_getInteger(powerStatus, 2, false, 1)
If acLineStatus = 0
acLineStatus = off
Else If acLineStatus = 1
acLineStatus = on
Else If acLineStatus = 255
acLineStatus = ?
If batteryLifePercent = 255
batteryLifePercent = ???
}
; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html)
Bar_getHeight() {
Global Bar_#0_#1, Bar_#0_#1H, Bar_#0_#2, Bar_#0_#2H, Bar_ctrlHeight, Bar_height, Bar_textHeight
Global Config_fontName, Config_fontSize, Config_singleRowBar, Config_spaciousBar, Config_verticalBarPos
wndTitle := "bug.n_BAR_0"
Gui, 99: Default
Gui, Font, s%Config_fontSize%, %Config_fontName%
Gui, Add, Text, x0 y0 vBar_#0_#1, |
GuiControlGet, Bar_#0_#1, Pos
Bar_textHeight := Bar_#0_#1H
If Config_spaciousBar {
Gui, Add, ComboBox, r9 x0 y0 vBar_#0_#2, |
GuiControlGet, Bar_#0_#2, Pos
Bar_ctrlHeight := Bar_#0_#2H
} Else
Bar_ctrlHeight := Bar_textHeight
Gui, Destroy
Bar_height := Bar_ctrlHeight
If Not Config_singleRowBar
Bar_height *= 2
If (Config_verticalBarPos = "tray") {
WinGetPos, , , , buttonH, Start ahk_class Button
WinGetPos, , , , barH, ahk_class Shell_TrayWnd
If (buttonH < barH)
Bar_height := buttonH
Else
Bar_height := barH
Bar_ctrlHeight := Bar_height
If Not Config_singleRowBar
Bar_ctrlHeight := Bar_height / 2
}
}
Bar_getInteger(ByRef @source, _offset = 0, _bIsSigned = false, _size = 4) {
Loop %_size% ; Build the integer by adding up its bytes.
result += *(&@source + _offset + A_Index-1) << 8*(A_Index-1)
If (!_bIsSigned OR _size > 4 OR result < 0x80000000)
Return result ; Signed vs. unsigned doesn't matter in these cases.
; Otherwise, convert the value (now known to be 32-bit & negative) to its signed counterpart:
return -(0xFFFFFFFF - result + 1)
}
; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html)
Bar_getSystemTimes() { ; Total CPU Load
Static oldIdleTime, oldKrnlTime, oldUserTime
Static newIdleTime, newKrnlTime, newUserTime
oldIdleTime := newIdleTime
oldKrnlTime := newKrnlTime
oldUserTime := newUserTime
DllCall("GetSystemTimes", "int64P", newIdleTime, "int64P", newKrnlTime, "int64P", newUserTime)
sysTime := SubStr(" " . Round((1-(newIdleTime-oldIdleTime)/(newKrnlTime-oldKrnlTime+newUserTime-oldUserTime))*100), -2)
Return, sysTime ; system time in percent
}
; Sean: CPU LoadTimes (http://www.autohotkey.com/forum/topic18913.html)
Bar_getTextWidth(x, reverse=False) {
Global Config_fontSize
If reverse { ; "reverse" calculates the number of characters to a given width.
w := x
i := w / (Config_fontSize - 1)
If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13))
i := w / (Config_fontSize - 2)
Else If (Config_fontSize > 12 And Config_fontSize < 18)
i := w / (Config_fontSize - 3)
Else If (Config_fontSize > 17)
i := w / (Config_fontSize - 4)
textWidth := i
} Else { ; "else" calculates the width to a given string.
textWidth := StrLen(x) * (Config_fontSize - 1)
If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13))
textWidth := StrLen(x) * (Config_fontSize - 2)
Else If (Config_fontSize > 12 And Config_fontSize < 18)
textWidth := StrLen(x) * (Config_fontSize - 3)
Else If (Config_fontSize > 17)
textWidth := StrLen(x) * (Config_fontSize - 4)
}
Return, textWidth
}
Bar_layoutGuiClick:
Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "Normal") {
If Not (SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) - Manager_aMonitor)
View_setLayout(-1)
}
Return
Bar_layoutGuiContextMenu:
Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "RightClick") {
If Not (SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) - Manager_aMonitor)
View_setLayout(">")
}
Return
Bar_loop:
Bar_updateStatus()
Return
Bar_move(m) {
Local wndTitle, x, y
x := Monitor_#%m%_barX
y := Monitor_#%m%_barY
wndTitle := "bug.n_BAR_" m
WinMove, %wndTitle%, , %x%, %y%
}
Bar_tagGuiClick:
Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "Normal") {
If Not (SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) - Manager_aMonitor)
Monitor_activateView(SubStr(A_GuiControl, InStr(A_GuiControl, "][")+2, 1))
}
Return
Bar_tagGuiContextMenu:
Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "RightClick") {
If Not (SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) = Manager_aMonitor)
Manager_setWindowMonitor(SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) - Manager_aMonitor)
Monitor_setWindowTag(SubStr(A_GuiControl, InStr(A_GuiControl, "][")+2, 1))
}
Return
Bar_toggleCommandGui:
If Not Bar_cmdGuiIsVisible
If Not (SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 5, InStr(A_GuiControl, "][")-5) - Manager_aMonitor)
Bar_toggleCommandGui()
Return
Bar_toggleCommandGui() {
Local wndId, x, y
Gui, 99: Default
If Bar_cmdGuiIsVisible {
Bar_cmdGuiIsVisible := False
Gui, Cancel
Manager_winActivate(Bar_aWndId)
} Else {
Bar_cmdGuiIsVisible := True
x := Monitor_#%Manager_aMonitor%_barX + Monitor_#%Manager_aMonitor%_barWidth - Bar_#0_#0W
If (Config_verticalBarPos = "top")
y := Monitor_#%Manager_aMonitor%_y
Else
y := Monitor_#%Manager_aMonitor%_barY + Bar_#0_#0H
Gui, Show
WinMove, bug.n_BAR_0, , %x%, %y%
WinGet, wndId, ID, bug.n_BAR_0
Manager_winActivate(wndId)
GuiControl, Focus, % Bar_#0_#0
}
}
Bar_toggleVisibility(m) {
Local GuiN
GuiN := (m - 1) + 1
If Monitor_#%m%_showBar {
If Not (GuiN = 99) Or Bar_cmdGuiIsVisible
Gui, %GuiN%: Show
} Else
Gui, %GuiN%: Cancel
}
Bar_updateLayout(m) {
Local aView, GuiN, i
aView := Monitor_#%m%_aView_#1
i := Config_viewCount + 1
GuiN := (m - 1) + 1
GuiControl, %GuiN%: , Bar_#%m%_#%i%, % View_#%m%_#%aView%_layoutSymbol
}
Bar_updateStatus() {
Local anyContent, anyText, b1, b2, b3, GuiN, i, m
Loop, % Manager_monitorCount {
m := A_Index
GuiN := (m - 1) + 1
Gui, %GuiN%: Default
If Config_readinBat {
Bar_getBatteryStatus(b1, b2)
b3 := SubStr(" " b1, -2)
i := Config_viewCount + 3
If (b1 < 10) And (b2 = "off") { ; change the color, if the battery level is below 10%
GuiControl, +Background%Config_normBgColor4% +c%Config_normBgColor2%, Bar_#%m%_#%i%_progress
GuiControl, +c%Config_selFgColor6%, Bar_#%m%_#%i%
} Else If (b2 = "off") { ; change the color, if the pc is not plugged in
GuiControl, +Background%Config_normBgColor2% +c%Config_normFgColor5%, Bar_#%m%_#%i%_progress
GuiControl, +c%Config_normFgColor4%, Bar_#%m%_#%i%
} Else {
GuiControl, +Background%Config_normBgColor3% +c%Config_normFgColor3%, Bar_#%m%_#%i%_progress
GuiControl, +c%Config_normFgColor2%, Bar_#%m%_#%i%
}
GuiControl, , Bar_#%m%_#%i%_progress, %b3%
GuiControl, , Bar_#%m%_#%i%, % " BAT: " b3 "% "
}
anyText := Config_readinAny()
If anyText {
i := Config_viewCount + 4
GuiControlGet, anyContent, , Bar_#%m%_#%i%
If Not (anyText = anyContent)
GuiControl, Bar_#%m%_#%i%, % anyText
}
If Config_readinTime {
i := Config_viewCount + 5
GuiControl, , Bar_#%m%_#%i%, % " " A_Hour ":" A_Min " "
}
}
}
Bar_updateTitle() {
Local aWndId, aWndTitle, content, GuiN, i, title
WinGet, aWndId, ID, A
WinGetTitle, aWndTitle, ahk_id %aWndId%
If InStr(Bar_hideTitleWndIds, aWndId . ";")
aWndTitle := ""
If Manager_#%aWndId%_isFloating
aWndTitle := "~ " aWndTitle
If (Manager_monitorCount > 1)
aWndTitle := "[" Manager_aMonitor "] " aWndTitle
title := " " . aWndTitle . " "
If (Bar_getTextWidth(title) > Bar_titleWidth) { ; shorten the window title if its length exceeds the width of the bar
i := Bar_getTextWidth(Bar_titleWidth, True) - 6
StringLeft, title, aWndTitle, i
title := " " . title . " ... "
}
i := Config_viewCount + 2
Loop, % Manager_monitorCount {
GuiN := (A_Index - 1) + 1
Gui, %GuiN%: Default
If (A_Index = Manager_aMonitor) {
GuiControlGet, content, , Bar_#%A_Index%_#%i%
If Not (title = content)
GuiControl, , Bar_#%A_Index%_#%i%, % title
} Else
GuiControl, , Bar_#%A_Index%_#%i%,
}
Bar_aWndId := aWndId
}
Bar_updateView(m, v) {
Local managedWndId0, wndId0, wndIds
StringTrimRight, wndIds, Manager_managedWndIds, 1
StringSplit, managedWndId, wndIds, `;
GuiN := (m - 1) + 1
Gui, %GuiN%: Default
Loop, %Config_viewCount% {
StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1
StringSplit, wndId, wndIds, `;
If (A_Index = v)
If (v = Monitor_#%m%_aView_#1) {
GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_progress
GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v%
} Else If wndId0 {
GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_progress
GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v%
} Else {
GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_progress
GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v%
}
GuiControl, , Bar_#%m%_#%A_Index%_progress, % wndId0 / managedWndId0 * 100
GuiControl, , Bar_#%m%_#%A_Index%, %A_Index%
}
}

332
src/Config.ahk Normal file
View file

@ -0,0 +1,332 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.2.0.03 (27.07.2011)
*/
Config_init() {
Local i, key, layout0, layout1, layout2, layout_#1, layout_#2, layout_#3
; status bar
Config_showBar := True ; If false, the bar is hidden. It can be made visible or hidden by hotkey (see below).
Config_horizontalBarPos := "left" ; The horizontal position of the bar: "center", "left" or "right" side of the monitor or an offset in pixel (px) from the left (>= 0) or right (< 0).
Config_verticalBarPos := "top" ; The vertical position of the bar: "top" or "bottom" of the monitor, "tray" = sub-window of the task bar.
Config_barWidth := "100%" ; The width of the bar in pixel (px) or with a per cent sign (%) as a percentage.
Config_singleRowBar := True ; If false, the bar will have to rows, one for the window title and one for all other GUI controls.
Config_spaciousBar := False ; If true, the height of the bar will be set to a value equal to the height of an edit control, else it will be set to the text height.
Config_fontName := "Lucida Console" ; A monospace font is preferable for bug.n to calculate the correct width of the bar and its elements (sub-windows).
Config_readinBat := False ; If true, the system battery status is read in and displayed in the status bar. This only makes sense, if you have a system battery (notebook).
Config_readinCpu := False ; If true, the current CPU load is read in and displayed in the status bar.
Config_readinDate := True ; If true, the current date is read in (format: "WW, DD. MMM. YYYY") and displayed in the status bar.
Config_readinTime := True ; If true, the current time is read in (format: "HH:MM") and displayed in the status bar.
Config_readinInterval := 30000 ; Time in milliseconds after which the above status values are refreshed.
; Windows ui elements
Config_bbCompatibility := False ; If true, bug.n looks for BlackBox components (bbLeanBar, bbSlit and SystemBarEx) when calculating the work area. It is assumed that the virtual desktop functionality of BlackBox and NOT bug.n is used (=> Hiding and showing windows is detected and acted upon).
Config_borderWidth := 0 ; If > 0, the window border width is set to the integer value Config_borderWidth.
Config_borderPadding := -1 ; If >= 0, the window border padding is set to the integer value Config_borderPadding (only for Windows >= Vista).
Config_showTaskBar := False ; If false, the task bar is hidden. It can be made visible or hidden by hotkey (see below).
Config_showBorder := True ; If false, the window borders are hidden; therefor windows cannot be resized manually by dragging the border, even if using the according hotkey.
Config_selBorderColor := "" ; Border colour of the active window; format: 0x00BBGGRR (e. g. "0x006A240A", if = "", the system's window border colour is not changed).
; Config_borderWidth, Config_borderPadding and Config_selBorderColor are especially usefull, if you are not allowed to set the design in the system settings.
; window arrangement
Config_viewCount := 9 ; The total number of views. This has effects on the displayed groups in the bar, and should not be exceeded in the hotkeys below.
layout_#1 := "[]=;tile" ; The layout symbol and arrange function (the first entry is set as the default layout, no layout function means floating behavior)
layout_#2 := "[M];monocle"
layout_#3 := "><>;"
Config_layoutCount := 3 ; Total number of layouts defined above.
Config_layoutAxis_#1 := 1 ; The layout axis: 1 = x, 2 = y; negative values mirror the layout, setting the master area to the right / bottom instead of left / top.
Config_layoutAxis_#2 := 2 ; The master axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle).
Config_layoutAxis_#3 := 2 ; The stack axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle).
Config_layoutMFactor := 0.6 ; The factor for the size of the master area, which is multiplied by the monitor size.
Config_monitorFollowsMouse := False ; If true, the active monitor is determined by the position of the mouse pointer, if a window is opened; therefor the newly opened window will be moved there by default.
Config_mouseFollowsFocus := True ; If true, the mouse pointer is set over the focused window, if a window is activated by bug.n.
Config_shellMsgDelay := 350 ; The time bug.n waits after a shell message (a window is opened, closed or the focus has been changed); if there are any problems recognizing, when windows are opened or closed, try to increase this number.
Config_viewFollowsTagged := False ; If true, the view is set to, if a window is tagged with a single tag.
; Config_rules_#i := "<class (regular expression string)>;<title (regular expression string)>;<window style (hexadecimal number or blank)>;<is managed (1 = True or 0 = False)>;<monitor (0 <= integer <= total number of monitors, 0 means the currently active monitor)>;<tags (binary mask as integer >= 0, e. g. 17 for 1 and 5, 0 means the currently active tag)>;<is floating (1 = True or 0 = False)>;<is decorated (1 = True or 0 = False)>;<hide title (1 = True or 0 = False)>" (";" is not allowed as a character)
Config_rules_#1 := ".*;.*;;1;0;0;0;0;0" ; At first you may set a default rule (.*;.*;) for a default monitor, view and / or showing window title bars.
Config_rules_#2 := ".*;.*;0x80000000;0;0;0;1;1;1" ; Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are floating and the titles are hidden.
Config_rules_#3 := "SWT_Window0;.*;;1;0;0;0;0;0" ; Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP, but should excluded from the above rule.
Config_rules_#4 := "Xming;.*;;1;0;0;0;0;0" ; Xming windows have the style WS_POPUP, but should be excluded from the above rule.
Config_rules_#5 := "_sp;_sp;;1;0;0;1;0;1"
Config_rules_#6 := "MozillaDialogClass;.*;;1;0;0;1;1;0"
Config_rules_#7 := "MsiDialog(No)?CloseClass;.*;;1;0;0;1;1;0"
Config_rules_#8 := "gdkWindowToplevel;GIMP-Start;;1;0;0;1;1;0"
Config_rules_#9 := "gdkWindowToplevel;GNU Image Manipulation Program;;1;0;0;1;1;0"
Config_rules_#10 := "gdkWindowToplevel;Werkzeugkasten;;1;0;0;1;1;0"
Config_rules_#11 := "gdkWindowToplevel;Ebenen, .* - Pinsel, Muster, .*;;1;0;0;1;1;0"
Config_rules_#12 := "gdkWindowToplevel;Toolbox;;1;0;0;1;1;0"
Config_rules_#13 := "gdkWindowToplevel;Layers, Channels, Paths, .*;;1;0;0;1;1;0"
Config_rules_#14 := "CalcFrame;.*;;1;0;0;1;1;0"
Config_rulesCount := 14 ; This variable has to be set to the total number of active rules above.
; session management
Config_autoSaveSession := False ; Automatically save the current state of monitors, views, layouts (active view, layout, axes, mfact and msplit) to te session file (set below) when quitting bug.n.
If Not Config_sessionFilePath ; The file path, to which the session is saved. This target directory must be writable by the user (%A_ScriptDir% is the diretory, in which "Main.ahk" or the executable of bug.n is saved).
Config_sessionFilePath := A_ScriptDir "\Session.ini"
Session_restore("Config")
Config_getSystemSettings()
Config_initColors()
Loop, % Config_hotkeyCount {
i := InStr(Config_hotkey_#%A_Index%, "::")
Config_hotkey_#%A_index%_key := SubStr(Config_hotkey_#%A_Index%, 1, i - 1)
Config_hotkey_#%A_index%_command := SubStr(Config_hotkey_#%A_Index%, i + 2)
key := Config_hotkey_#%A_index%_key
If Not Config_hotkey_#%A_index%_command
Hotkey, %key%, Off
Else
Hotkey, %key%, Config_hotkeyLabel
}
Loop, % Config_layoutCount {
StringSplit, layout, layout_#%A_Index%, `;
Config_layoutFunction_#%A_Index% := layout2
Config_layoutSymbol_#%A_Index% := layout1
}
If (Config_viewCount > 9)
Config_viewCount := 9
}
Config_initColors() {
Global
StringReplace, Config_normBgColor, Config_normBgColor, `;0`;, `;000000`;, All
Config_normBgColor := RegExReplace(Config_normBgColor, "^0;", "000000;")
Config_normBgColor := RegExReplace(Config_normBgColor, ";0$", ";000000")
StringSplit, Config_normBgColor, Config_normBgColor, `;
StringReplace, Config_normFgColor, Config_normFgColor, `;0`;, `;000000`;, All
Config_normFgColor := RegExReplace(Config_normFgColor, "^0;", "000000;")
Config_normFgColor := RegExReplace(Config_normFgColor, ";0$", ";000000")
StringSplit, Config_normFgColor, Config_normFgColor, `;
StringReplace, Config_selBgColor, Config_selBgColor, `;0`;, `;000000`;, All
Config_selBgColor := RegExReplace(Config_selBgColor, "^0;", "000000;")
Config_selBgColor := RegExReplace(Config_selBgColor, ";0$", ";000000")
StringSplit, Config_selBgColor, Config_selBgColor, `;
StringReplace, Config_selFgColor, Config_selFgColor, `;0`;, `;000000`;, All
Config_selFgColor := RegExReplace(Config_selFgColor, "^0;", "000000;")
Config_selFgColor := RegExReplace(Config_selFgColor, ";0$", ";000000")
StringSplit, Config_selFgColor, Config_selFgColor, `;
}
Config_convertSystemColor(systemColor) { ; systemColor format: 0xBBGGRR
rr := SubStr(systemColor, 7, 2)
gg := SubStr(systemColor, 5, 2)
bb := SubStr(systemColor, 3, 2)
Return, rr gg bb
}
Config_getSystemSettings() {
Global Config_fontName, Config_fontSize, Config_normBgColor, Config_normFgColor, Config_selBgColor, Config_selFgColor
If Not Config_fontName {
ncmSize := VarSetCapacity(ncm, 44 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
VarSetCapacity(Config_fontName, 32 * (A_IsUnicode ? 2 : 1), 0)
DllCall("RtlMoveMemory", "Str", Config_fontName, "UInt", &lf + 28, "UInt", 32 * (A_IsUnicode ? 2 : 1))
; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
}
If Not Config_fontSize {
ncmSize := VarSetCapacity(ncm, 44 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
lfSize := VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
NumPut(lfSize, lf, 0, "UInt")
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
lfHeightSize := VarSetCapacity(lfHeight, 4, 0)
NumPut(lfHeightSize, lfHeight, 0, "Int")
lfHeight := NumGet(lf, 0, "Int")
lfPixelsY := DllCall("GetDeviceCaps", "UInt", DllCall("GetDC", "UInt", 0), "UInt", 90) ; LOGPIXELSY
Config_fontSize := -DllCall("MulDiv", "Int", lfHeight, "Int", 72, "Int", lfPixelsY)
; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
}
SetFormat, Integer, hex
If Not Config_normBgColor {
Config_normBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 4)) ; COLOR_MENU
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ; COLOR_INACTIVECAPTION
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ; COLOR_GRADIENTINACTIVECAPTION
Config_normBgColor .= ";Red"
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ; COLOR_GRADIENTINACTIVECAPTION
}
If Not Config_normFgColor {
Config_normFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 7)) ; COLOR_MENUTEXT
Config_normFgColor .= ";Default"
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ; COLOR_INACTIVECAPTION
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 19)) ; COLOR_INACTIVECAPTIONTEXT
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 13)) ; COLOR_HIGHLIGHT
Config_normFgColor .= ";White"
Config_normFgColor .= ";Default"
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ; COLOR_INACTIVECAPTION
}
If Not Config_selBgColor {
Config_selBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 27)) ; COLOR_GRADIENTACTIVECAPTION
}
If Not Config_selFgColor {
Config_selFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 9)) ; COLOR_CAPTIONTEXT
Config_selFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 2)) ; COLOR_ACTIVECAPTION
}
SetFormat, Integer, d
}
Config_hotkeyLabel:
Config_redirectHotkey(A_ThisHotkey)
Return
Config_readinAny() { ; Add information to the variable "text" in this function to display it in the status bar.
Global Config_readinCpu, Config_readinDate
text := ""
If Config_readinCpu
text .= " CPU: " Bar_getSystemTimes() "% "
If Config_readinDate And Config_readinCpu
text .= "|"
If Config_readinDate
text .= " " A_DDD ", " A_DD ". " A_MMM ". " A_YYYY " "
Return, text
}
Config_redirectHotkey(key) {
Local functionArgument0, functionArgument1, functionArgument2, functionArguments, functionName, i, j, parameter0, parameter1, parameter2, parameter3, parameters, type
Loop, % Config_hotkeyCount
If (key = Config_hotkey_#%A_index%_key) {
type := SubStr(Config_hotkey_#%A_index%_command, 1, 5)
If (type = "Run, ") {
parameters := SubStr(Config_hotkey_#%A_index%_command, 6)
If InStr(parameters, ", ") {
StringSplit, parameter, parameters, `,
If (parameter0 = 2) {
StringTrimLeft, parameter2, parameter2, 1
Run, %parameter1%, %parameter2%
} Else If (parameter0 > 2) {
StringTrimLeft, parameter2, parameter2, 1
StringTrimLeft, parameter3, parameter3, 1
Run, %parameter1%, %parameter2%, %parameter3%
}
} Else
Run, %parameters%
} Else If (type = "Send ")
Send % SubStr(Config_hotkey_#%A_index%_command, 6)
Else {
i := InStr(Config_hotkey_#%A_index%_command, "(")
j := InStr(Config_hotkey_#%A_index%_command, ")", False, i)
If i And j {
functionName := SubStr(Config_hotkey_#%A_index%_command, 1, i - 1)
functionArguments := SubStr(Config_hotkey_#%A_index%_command, i + 1, j - (i + 1))
StringSplit, functionArgument, functionArguments, `,
If (functionArgument0 < 2)
%functionName%(functionArguments)
Else If (functionArgument0 = 2) {
StringTrimLeft, functionArgument2, functionArgument2, 1
%functionName%(functionArgument1, functionArgument2)
}
}
}
Break
}
}
/**
* key definitions
*
* format: <modifier><key>::<function>(<argument>)
* modifier: ! = Alt (Mod1Mask), ^ = Ctrl (ControlMask), + = Shift (ShiftMask), # = LWin (Mod4Mask)
*/
#Down::View_activateWindow(+1) ; Activate the next window in the active view.
#Up::View_activateWindow(-1) ; Activate the previous window in the active view.
#+Down::View_shuffleWindow(+1) ; Move the active window to the next position in the window list of the view.
#+Up::View_shuffleWindow(-1) ; Move the active window to the previous position in the window list of the view.
#+Enter::View_shuffleWindow(0) ; Move the active window to the first position in the window list of the view.
#c::Manager_closeWindow() ; Close the active window.
#+d::Manager_toggleDecor() ; Show / Hide the title bar of the active window.
#+f::View_toggleFloating() ; Toggle the floating status of the active window (i. e. dis- / regard it when tiling).
#+m::Manager_moveWindow() ; Move the active window by key (only floating windows).
#+s::Manager_sizeWindow() ; Resize the active window by key (only floating windows).
#+x::Manager_maximizeWindow() ; Move and resize the active window to the size of the work area (only floating windows).
#i::Manager_getWindowInfo() ; Get information for the active window (id, title, class, process name, style, geometry, tags and floating state).
#+i::Manager_getWindowList() ; Get a window list for the active view (id, title and class).
#Tab::View_setLayout(-1) ; Set the previously set layout. You may also use View_setLayout(">") for setting the next layout in the layout array.
#f::View_setLayout(3) ; Set the 3rd defined layout (i. e. floating layout in the default configuration).
#m::View_setLayout(2) ; Set the 2nd defined layout (i. e. monocle layout in the default configuration).
#t::View_setLayout(1) ; Set the 1st defined layout (i. e. tile layout in the default configuration).
#Left::View_setMFactor(-0.05) ; Reduce the size of the master area in the active view (only for the "tile" layout).
#Right::View_setMFactor(+0.05) ; Enlarge the size of the master area in the active view (only for the "tile" layout).
#^t::View_rotateLayoutAxis(1, +1) ; Rotate the layout axis (i. e. 2 -> 1 = vertical layout, 1 -> 2 = horizontal layout, only for the "tile" layout).
#^Enter::View_rotateLayoutAxis(1, +2) ; Mirror the layout axis (i. e. -1 -> 1 / 1 -> -1 = master on the left / right side, -2 -> 2 / 2 -> -2 = master at top / bottom, only for the "tile" layout).
#^Tab::View_rotateLayoutAxis(2, +1) ; Rotate the master axis (i. e. 3 -> 1 = x-axis = horizontal stack, 1 -> 2 = y-axis = vertical stack, 2 -> 3 = z-axis = monocle, only for the "tile" layout).
#^+Tab::View_rotateLayoutAxis(3, +1) ; Rotate the stack axis (i. e. 3 -> 1 = x-axis = horizontal stack, 1 -> 2 = y-axis = vertical stack, 2 -> 3 = z-axis = monocle, only for the "tile" layout).
#^Left::View_setMSplit(+1) ; Move the master splitter, i. e. decrease the number of windows in the master area (only for the "tile" layout).
#^Right::View_setMSplit(-1) ; Move the master splitter, i. e. increase the number of windows in the master area (only for the "tile" layout).
#BackSpace::Monitor_activateView(-1) ; Activate the previously activated view. You may also use Monitor_activateView("<") or Monitor_activateView(">") for activating the previous or next adjacent view.
#+0::Monitor_setWindowTag(0) ; Tag the active window with all tags (1 ... Config_viewCount). You may also use Monitor_setWindowTag("<") or Monitor_setWindowTag(">") for setting the tag of the previous or next adjacent to the current view.
#1::Monitor_activateView(1) ; Activate the view (choose one out of 1 ... Config_viewCount).
#+1::Monitor_setWindowTag(1) ; Tag the active window (choose one tag out of 1 ... Config_viewCount).
#^1::Monitor_toggleWindowTag(1) ; Add / Remove the tag (1 ... Config_viewCount) for the active window, if it is not / is already set.
#2::Monitor_activateView(2)
#+2::Monitor_setWindowTag(2)
#^2::Monitor_toggleWindowTag(2)
#3::Monitor_activateView(3)
#+3::Monitor_setWindowTag(3)
#^3::Monitor_toggleWindowTag(3)
#4::Monitor_activateView(4)
#+4::Monitor_setWindowTag(4)
#^4::Monitor_toggleWindowTag(4)
#5::Monitor_activateView(5)
#+5::Monitor_setWindowTag(5)
#^5::Monitor_toggleWindowTag(5)
#6::Monitor_activateView(6)
#+6::Monitor_setWindowTag(6)
#^6::Monitor_toggleWindowTag(6)
#7::Monitor_activateView(7)
#+7::Monitor_setWindowTag(7)
#^7::Monitor_toggleWindowTag(7)
#8::Monitor_activateView(8)
#+8::Monitor_setWindowTag(8)
#^8::Monitor_toggleWindowTag(8)
#9::Monitor_activateView(9)
#+9::Monitor_setWindowTag(9)
#^9::Monitor_toggleWindowTag(9)
#.::Manager_activateMonitor(+1) ; Activate the next monitor in a multi-monitor environment.
#,::Manager_activateMonitor(-1) ; Activate the previous monitor in a multi-monitor environment.
#+.::Manager_setWindowMonitor(+1) ; Set the active window to the active view on the next monitor in a multi-monitor environment.
#+,::Manager_setWindowMonitor(-1) ; Set the active window to the active view on the previous monitor in a multi-monitor environment.
#^+.::Manager_setViewMonitor(+1) ; Set all windows of the active view on the active view of the next monitor in a multi-monitor environment.
#^+,::Manager_setViewMonitor(-1) ; Set all windows of the active view on the active view of the previous monitor in a multi-monitor environment.
#+Space::Monitor_toggleBar() ; Hide / Show the bar (bug.n status bar) on the active monitor.
#Space::Monitor_toggleTaskBar() ; Hide / Show the task bar.
#y::Bar_toggleCommandGui() ; Open the command GUI for executing programmes or bug.n functions.
#^e::Run, edit, %Config_sessionFilePath% ; Open the session file in the standard text editor.
#^s::Session_save() ; Save the current state of monitors, views, layouts.
#^r::Reload ; For resetting the confguration, if running bug.n as an Autohotkey script.
#^q::ExitApp ; Quit bug.n, restore the default Windows UI and show all windows.

77
src/Main.ahk Normal file
View file

@ -0,0 +1,77 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.2.0.01 (16.02.2011)
*/
NAME := "bug.n"
VERSION := "8.2.0"
; script settings
OnExit, Main_cleanup
SetBatchLines, -1
SetTitleMatchMode, 3
SetTitleMatchMode, fast
SetWinDelay, 10
#NoEnv
#SingleInstance force
#WinActivateForce
; pseudo main function
If 0 = 1
Config_sessionFilePath = %1%
Config_init()
Menu, Tray, Tip, %NAME% %VERSION%
IfExist %A_ScriptDir%\images\kfm.ico
Menu, Tray, Icon, %A_ScriptDir%\images\kfm.ico
Menu, Tray, NoStandard
Menu, Tray, Add, Toggle bar, Main_toggleBar
Menu, Tray, Add, Help, Main_help
Menu, Tray, Add,
Menu, Tray, Add, Exit, Main_quit
Manager_init()
Return ; end of the auto-execute section
/**
* function & label definitions
*/
Main_cleanup: ; The labels with "ExitApp" or "Return" at the end and hotkeys have to be after the auto-execute section.
If Config_autoSaveSession
Session_save()
Manager_cleanup()
ExitApp
Main_help:
Run, explore %A_ScriptDir%\docs
Return
Main_quit:
ExitApp
Return
Main_toggleBar:
Monitor_toggleBar()
Return
#Include Bar.ahk
#Include Config.ahk
#Include Manager.ahk
#Include Monitor.ahk
#Include Session.ahk
#Include View.ahk

560
src/Manager.ahk Normal file
View file

@ -0,0 +1,560 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.2.0.03 (27.07.2011)
*/
Manager_init() {
Local ncm, ncmSize
; Windows UI
If Config_selBorderColor {
SetFormat, Integer, hex
Manager_normBorderColor := DllCall("GetSysColor", "Int", 10)
SetFormat, Integer, d
DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Config_selBorderColor)
}
If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) {
ncmSize := VarSetCapacity(ncm, 44 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
Manager_borderWidth := NumGet(ncm, 4, "Int")
Manager_borderPadding := NumGet(ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
If (Config_borderWidth > 0)
NumPut(Config_borderWidth, ncm, 4, "Int")
If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
NumPut(Config_borderPadding, ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
}
Bar_getHeight()
Manager_aMonitor := 1
Manager_taskBarMonitor := ""
Manager_showTaskBar := True
SysGet, Manager_monitorCount, MonitorCount
Loop, % Manager_monitorCount
Monitor_init(A_Index)
Bar_initCmdGui()
If Not Config_showTaskBar
Monitor_toggleTaskBar()
Manager_focus := False
Manager_hideShow := False
Bar_hideTitleWndIds := ""
Manager_allWndIds := ""
Manager_managedWndIds := ""
Manager_sync()
Bar_updateStatus()
Bar_updateTitle()
Loop, % Manager_monitorCount {
View_arrange(A_Index, Monitor_#%A_Index%_aView_#1)
Bar_updateView(A_Index, Monitor_#%A_Index%_aView_#1)
}
Manager_registerShellHook()
SetTimer, Bar_loop, %Config_readinInterval%
}
Manager_activateMonitor(d) {
Local aView, aWndClass, aWndId, v, wndId
If (Manager_monitorCount > 1) {
aView := Monitor_#%Manager_aMonitor%_aView_#1
WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) {
WinGetClass, aWndClass, ahk_id %aWndId%
If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui") And Not (aWndClass = "DesktopBackgroundClass")
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
}
Manager_aMonitor := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount)
v := Monitor_#%Manager_aMonitor%_aView_#1
wndId := View_#%Manager_aMonitor%_#%v%_aWndId
If Not (wndId And WinExist("ahk_id" wndId)) {
If View_#%Manager_aMonitor%_#%v%_wndIds
wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";")-1)
Else
wndId := 0
}
Manager_winActivate(wndId)
}
}
Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating, ByRef isDecorated, ByRef hideTitle) {
Local mouseX, mouseY, wndClass, wndHeight, wndStyle, wndTitle, wndWidth, wndX, wndY
Local rule0, rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9
isManaged := True
m := 0
tags := 0
isFloating := False
isDecorated := False
hideTitle := False
WinGetClass, wndClass, ahk_id %wndId%
WinGetTitle, wndTitle, ahk_id %wndId%
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
WinGet, wndStyle, Style, ahk_id %wndId%
If wndClass And wndTitle And Not (wndX < -4999) And Not (wndY < -4999) {
Loop, % Config_rulesCount {
StringSplit, rule, Config_rules_#%A_index%, `;
If RegExMatch(wndClass . ";" . wndTitle, rule1 . ";" . rule2) And (rule3 = "" Or wndStyle & rule3) { ; The last matching rule is returned.
isManaged := rule4
m := rule5
tags := rule6
isFloating := rule7
isDecorated := rule8
hideTitle := rule9
}
}
If (m = 0) {
If Config_monitorFollowsMouse {
MouseGetPos, mouseX, mouseY
m := Monitor_get(mouseX, mouseY)
} Else
m := Manager_aMonitor
}
If (m > Manager_monitorCount) ; If the specified monitor is out of scope, set it to the max. monitor.
m := Manager_monitorCount
If (tags = 0)
tags := 1 << Monitor_#%m%_aView_#1 - 1
} Else {
isManaged := False
If wndTitle
hideTitle := True
}
}
Manager_cleanup() {
Local aWndId, m, ncmSize, ncm, wndIds
WinGet, aWndId, ID, A
; Reset border color, padding and witdh.
If Config_selBorderColor
DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Manager_normBorderColor)
If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) {
ncmSize := VarSetCapacity(ncm, 44 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
If (Config_borderWidth > 0)
NumPut(Manager_borderWidth, ncm, 4, "Int")
If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
NumPut(Manager_borderPadding, ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
}
; Show borders and title bars.
StringTrimRight, wndIds, Manager_managedWndIds, 1
Manager_hideShow := True
Loop, PARSE, wndIds, `;
{
WinShow, ahk_id %A_LoopField%
If Not Config_showBorder
WinSet, Style, +0x40000, ahk_id %A_LoopField%
WinSet, Style, +0xC00000, ahk_id %A_LoopField%
}
; Show the task bar.
WinShow, Start ahk_class Button
WinShow, ahk_class Shell_TrayWnd
Manager_hideShow := False
; Reset windows position and size.
Manager_showTaskBar := True
Loop, % Manager_monitorCount {
m := A_Index
Monitor_#%m%_showBar := False
Monitor_getWorkArea(m)
Loop, % Config_viewCount
View_arrange(m, A_Index)
}
WinSet, AlwaysOnTop, On, ahk_id %aWndId%
WinSet, AlwaysOnTop, Off, ahk_id %aWndId%
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_REMOVE := 0x1), "UInt", &Bar_appBarData)
; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
}
Manager_closeWindow() {
WinGet, aWndId, ID, A
WinGetClass, aWndClass, ahk_id %aWndId%
WinGetTitle, aWndTitle, ahk_id %aWndId%
If Not (aWndClass = "AutoHotkeyGUI" And RegExMatch(aWndTitle, "BUGN_BAR_[0-9]+_[0-9]+"))
WinClose, ahk_id %aWndId%
}
Manager_getWindowInfo() {
Local text, v, aWndClass, aWndHeight, aWndId, aWndProcessName, aWndStyle, aWndTitle, aWndWidth, aWndX, aWndY
WinGet, aWndId, ID, A
WinGetClass, aWndClass, ahk_id %aWndId%
WinGetTitle, aWndTitle, ahk_id %aWndId%
WinGet, aWndProcessName, ProcessName, ahk_id %aWndId%
WinGet, aWndStyle, Style, ahk_id %aWndId%
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
text := "ID: " aWndId "`nclass:`t" aWndClass "`ntitle:`t" aWndTitle
If InStr(Bar_hiddenWndIds, aWndId)
text .= " (hidden)"
text .= "`nprocess:`t" aWndProcessName "`nstyle:`t" aWndStyle "`nmetrics:`tx: " aWndX ", y: " aWndY ", width: " aWndWidth ", height: " aWndHeight "`ntags:`t" Manager_#%aWndId%_tags
If Manager_#%aWndId%_isFloating
text .= " (floating)"
MsgBox, , bug.n: Window Information, % text
}
Manager_getWindowList() {
Local text, v, aWndId, wndIds, aWndTitle
v := Monitor_#%Manager_aMonitor%_aView_#1
aWndId := View_#%Manager_aMonitor%_#%v%_aWndId
WinGetTitle, aWndTitle, ahk_id %aWndId%
text := "Active Window`n" aWndId ":`t" aWndTitle
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
text .= "`n`nWindow List"
Loop, PARSE, wndIds, `;
{
WinGetTitle, wndTitle, ahk_id %A_LoopField%
text .= "`n" A_LoopField ":`t" wndTitle
}
MsgBox, , bug.n: Window List, % text
}
Manager_loop(index, increment, lowerBound, upperBound) {
index += increment
If (index > upperBound)
index := lowerBound
If (index < lowerBound)
index := upperBound
If (upperBound = 0)
index := 0
Return, index
}
Manager_manage(wndId) {
Local a, c0, hideTitle, isDecorated, isFloating, isManaged, m, tags, wndControlList0, wndX, wndY, wndWidth, wndHeight, wndProcessName
If Not InStr(Manager_allWndIds, wndId ";")
Manager_allWndIds .= wndId ";"
Manager_applyRules(wndId, isManaged, m, tags, isFloating, isDecorated, hideTitle)
WinGet, wndProcessName, ProcessName, ahk_id %wndId%
If (wndProcessName = "chrome.exe") {
WinGet, wndControlList, ControlList, ahk_id %wndId%
StringSplit, c, wndControlList, `n
If (c0 <= 1)
isManaged := False
}
If isManaged {
Monitor_moveWindow(m, wndId)
Manager_managedWndIds .= wndId ";"
Manager_#%wndId%_tags := tags
Manager_#%wndId%_isDecorated := isDecorated
Manager_#%wndId%_isFloating := isFloating
Loop, % Config_viewCount
If (Manager_#%wndId%_tags & 1 << A_Index - 1) {
View_#%m%_#%A_Index%_wndIds := wndId ";" View_#%m%_#%A_Index%_wndIds
Bar_updateView(m, A_Index)
}
If Not Config_showBorder
WinSet, Style, -0x40000, ahk_id %wndId%
If Not Manager_#%wndId%_isDecorated
WinSet, Style, -0xC00000, ahk_id %wndId%
a := Manager_#%wndId%_tags & 1 << Monitor_#%m%_aView_#1 - 1
If a {
Manager_aMonitor := m
Manager_winActivate(wndId)
} Else {
Manager_hideShow := True
WinHide, ahk_id %wndId%
Manager_hideShow := False
}
}
If hideTitle And Not InStr(Bar_hideTitleWndIds, wndId)
Bar_hideTitleWndIds .= wndId . ";"
Else If Not hideTitle
StringReplace, Bar_hideTitleWndIds, Bar_hideTitleWndIds, %wndId%`;,
Return, a
}
Manager_maximizeWindow() {
Local aWndId, l, v
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating()
WinSet, Top,, ahk_id %aWndId%
Manager_winMove(aWndId, Monitor_#%Manager_aMonitor%_x, Monitor_#%Manager_aMonitor%_y, Monitor_#%Manager_aMonitor%_width, Monitor_#%Manager_aMonitor%_height)
}
Manager_moveWindow() {
Local aWndId, l, SC_MOVE, v, WM_SYSCOMMAND
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating()
WinSet, Top,, ahk_id %aWndId%
WM_SYSCOMMAND = 0x112
SC_MOVE = 0xF010
SendMessage, WM_SYSCOMMAND, SC_MOVE, , , ahk_id %aWndId%
}
Manager_onShellMessage(wParam, lParam) {
Local a, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, flag, m, tags, wndClass, wndPName, wndTitle
SetFormat, Integer, hex
lParam := lParam+0
SetFormat, Integer, d
WinGetClass, wndClass, ahk_id %lParam%
WinGetTitle, wndTitle, ahk_id %lParam%
WinGet, wndPName, ProcessName, ahk_id %lParam%
If (wParam = 1 Or wParam = 2 Or wParam = 4 Or wParam = 6 Or wParam = 32772) And lParam And Not Manager_hideShow And Not Manager_focus {
If Not (wParam = 4 Or wParam = 32772) {
If Not wndClass And Not (wParam = 2) {
;Loop {
WinGetClass, wndClass, ahk_id %lParam%
If wndClass {
If (wndClass = "Emacs")
Sleep, % 12 * Config_shellMsgDelay
; Break
} Else
Sleep, %Config_shellMsgDelay%
}
}
If (wParam = 1 Or wParam = 6) And Not InStr(Manager_allWndIds, lParam . ";")
a := Manager_manage(lParam)
Else {
flag := True
a := Manager_sync(tags)
If tags
a := False
}
If a {
View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
Bar_updateView(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
}
If flag {
WinGet, aWndId, ID, A
If (Manager_monitorCount > 1) {
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
m := Monitor_get(aWndX+aWndWidth/2, aWndY+aWndHeight/2)
If m
Manager_aMonitor := m
}
}
If tags
Loop, % Config_viewCount
If (tags & 1 << A_Index - 1) {
Monitor_activateView(A_Index)
Break
}
Bar_updateTitle()
}
}
Manager_registerShellHook() {
Gui, +LastFound
hWnd := WinExist()
DllCall("RegisterShellHookWindow", "UInt", hWnd) ; Minimum operating systems: Windows 2000 (http://msdn.microsoft.com/en-us/library/ms644989(VS.85).aspx)
msgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK")
OnMessage(msgNum, "Manager_onShellMessage")
}
; SKAN: How to Hook on to Shell to receive its messages? (http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323)
Manager_setViewMonitor(d) {
Local aView, m, v, wndIds
If (Manager_monitorCount > 1) {
m := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount)
v := Monitor_#%m%_aView_#1
aView := Monitor_#%Manager_aMonitor%_aView_#1
If View_#%Manager_aMonitor%_#%aView%_wndIds {
View_#%m%_#%v%_wndIds := View_#%Manager_aMonitor%_#%aView%_wndIds View_#%m%_#%v%_wndIds
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `;
{
Loop, % Config_viewCount {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %A_LoopField%`;,
View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0
}
Monitor_moveWindow(m, A_LoopField)
Manager_#%A_LoopField%_tags := 1 << v - 1
}
View_arrange(Manager_aMonitor, aView)
Loop, % Config_viewCount
Bar_updateView(Manager_aMonitor, A_Index)
Manager_aMonitor := m
View_arrange(m, v)
Bar_updateTitle()
Bar_updateView(m, v)
}
}
}
Manager_setWindowMonitor(d) {
Local aWndId, v
WinGet, aWndId, ID, A
If (Manager_monitorCount > 1 And InStr(Manager_managedWndIds, aWndId ";")) {
Loop, % Config_viewCount {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
If (aWndId = View_#%Manager_aMonitor%_#%A_Index%_aWndId)
View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0
Bar_updateView(Manager_aMonitor, A_Index)
}
View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
Manager_aMonitor := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount)
Monitor_moveWindow(Manager_aMonitor, aWndId)
v := Monitor_#%Manager_aMonitor%_aView_#1
Manager_#%aWndId%_tags := 1 << v - 1
View_#%Manager_aMonitor%_#%v%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%v%_wndIds
View_#%Manager_aMonitor%_#%v%_aWndId := aWndId
View_arrange(Manager_aMonitor, v)
Bar_updateTitle()
Bar_updateView(Manager_aMonitor, v)
}
}
Manager_sizeWindow() {
Local aWndId, l, SC_SIZE, v, WM_SYSCOMMAND
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating()
WinSet, Top,, ahk_id %aWndId%
WM_SYSCOMMAND = 0x112
SC_SIZE = 0xF000
SendMessage, WM_SYSCOMMAND, SC_SIZE, , , ahk_id %aWndId%
}
Manager_sync(ByRef tags = 0) {
Local a, aWndId, flag, shownWndIds, v, visibleWndIds, wndId
Loop, % Manager_monitorCount {
v := Monitor_#%A_Index%_aView_#1
shownWndIds .= View_#%A_Index%_#%v%_wndIds
}
; check all visible windows against the known windows
WinGet, wndId, List, , ,
Loop, % wndId {
If Not InStr(shownWndIds, wndId%A_Index% ";") {
If Not InStr(Manager_managedWndIds, wndId%A_Index% ";") {
flag := Manager_manage(wndId%A_Index%)
If flag
a := flag
} Else {
aWndId := wndId%A_Index%
tags := Manager_#%aWndId%_tags
}
}
visibleWndIds := visibleWndIds wndId%A_Index% ";"
}
; check, if a window, that is known to be visible, is actually not visible
StringTrimRight, shownWndIds, shownWndIds, 1
Loop, PARSE, shownWndIds, `;
{
If Not InStr(visibleWndIds, A_LoopField) {
flag := Manager_unmanage(A_LoopField)
If flag
a := flag
}
}
Return, a
}
Manager_toggleDecor() {
Local aWndId
WinGet, aWndId, ID, A
Manager_#%aWndId%_isDecorated := Not Manager_#%aWndId%_isDecorated
If Manager_#%aWndId%_isDecorated
WinSet, Style, +0xC00000, ahk_id %aWndId%
Else
WinSet, Style, -0xC00000, ahk_id %aWndId%
}
Manager_unmanage(wndId) {
Local a
a := Manager_#%wndId%_tags & 1 << Monitor_#%Manager_aMonitor%_aView_#1 - 1
Loop, % Config_viewCount
If (Manager_#%wndId%_tags & 1 << A_Index - 1) {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %wndId%`;,
Bar_updateView(Manager_aMonitor, A_Index)
}
Manager_#%wndId%_tags :=
Manager_#%wndId%_isDecorated :=
Manager_#%wndId%_isFloating :=
StringReplace, Bar_hideTitleWndIds, Bar_hideTitleWndIds, %wndId%`;, , All
StringReplace, Manager_allWndIds, Manager_allWndIds, %wndId%`;,
StringReplace, Manager_managedWndIds, Manager_managedWndIds, %wndId%`;, , All
Return, a
}
Manager_winActivate(wndId) {
Local wndHeight, wndWidth, wndX, wndY
If Config_mouseFollowsFocus {
If wndId {
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
DllCall("SetCursorPos", "Int", Round(wndX + wndWidth / 2), "Int", Round(wndY + wndHeight / 2))
} Else
DllCall("SetCursorPos", "Int", Round(Monitor_#%Manager_aMonitor%_x + Monitor_#%Manager_aMonitor%_width / 2), "Int", Round(Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height / 2))
}
WinActivate, ahk_id %wndId%
Bar_updateTitle()
}
Manager_winMove(wndId, x, y, width, height) {
WinRestore, ahk_id %wndId%
WM_ENTERSIZEMOVE = 0x0231
WM_EXITSIZEMOVE = 0x0232
SendMessage, WM_ENTERSIZEMOVE, , , , ahk_id %wndId%
WinMove, ahk_id %wndId%, , %x%, %y%, %width%, %height%
SendMessage, WM_EXITSIZEMOVE, , , , ahk_id %wndId%
}

275
src/Monitor.ahk Normal file
View file

@ -0,0 +1,275 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.2.0.03 (27.07.2011)
*/
Monitor_init(m) {
Global
Monitor_#%m%_aView_#1 := 1
Monitor_#%m%_aView_#2 := 1
Monitor_#%m%_showBar := Config_showBar
Loop, % Config_viewCount
View_init(m, A_Index)
Session_restore("Monitor", m)
Monitor_getWorkArea(m)
Bar_init(m)
}
Monitor_activateView(v) {
Local aView, aWndClass, aWndId, wndId, wndIds
If (v = -1)
v := Monitor_#%Manager_aMonitor%_aView_#2
Else If (v = ">")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount)
Else If (v = "<")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount)
If (v > 0) And (v <= Config_viewCount) And Not Manager_hideShow And Not (v = Monitor_#%Manager_aMonitor%_aView_#1) {
aView := Monitor_#%Manager_aMonitor%_aView_#1
WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) {
WinGetClass, aWndClass, ahk_id %aWndId%
If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui") And Not (aWndClass = "DesktopBackgroundClass")
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
}
Monitor_#%Manager_aMonitor%_aView_#2 := aView
Monitor_#%Manager_aMonitor%_aView_#1 := v
Manager_hideShow := True
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `;
If Not (Manager_#%A_LoopField%_tags & (1 << v - 1))
WinHide, ahk_id %A_LoopField%
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
WinShow, ahk_id %A_LoopField%
Manager_hideShow := False
Bar_updateView(Manager_aMonitor, aView)
Bar_updateView(Manager_aMonitor, v)
View_arrange(Manager_aMonitor, v)
wndId := View_#%Manager_aMonitor%_#%v%_aWndId
If Not (wndId And WinExist("ahk_id" wndId)) {
If View_#%Manager_aMonitor%_#%v%_wndIds
wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";")-1)
Else
wndId := 0
}
Manager_winActivate(wndId)
}
}
Monitor_get(x, y) {
Local m
m := 0
Loop, % Manager_monitorCount ; Check if the window is on this monitor.
If (x >= Monitor_#%A_Index%_x && x <= Monitor_#%A_Index%_x+Monitor_#%A_Index%_width && y >= Monitor_#%A_Index%_y && y <= Monitor_#%A_Index%_y+Monitor_#%A_Index%_height) {
m := A_Index
Break
}
Return, m
}
Monitor_getWorkArea(m) {
Local bTop, x, y
Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop
Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY
SysGet, monitor, Monitor, %m%
wndClasses := "Shell_TrayWnd"
If Config_bbCompatibility
wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx"
Loop, PARSE, wndClasses, `;
{
wndId := WinExist("ahk_class " A_LoopField)
If wndId {
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
x := wndX + wndWidth / 2
y := wndY + wndHeight / 2
If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) {
If (A_LoopField = "Shell_TrayWnd")
Manager_taskBarMonitor := m
If (wndHeight < wndWidth) { ; Horizontal
If (wndY <= monitorTop) { ; Top
wndHeight += wndY - monitorTop
monitorTop += wndHeight
} Else { ; Bottom
wndHeight := monitorBottom - wndY
monitorBottom -= wndHeight
}
} Else { ; Vertical
If (wndX <= monitorLeft) { ; Left
wndWidth += wndX
monitorLeft += wndWidth
} Else { ; Right
wndWidth := monitorRight - wndX
monitorRight -= wndWidth
}
}
}
}
}
If Monitor_#%m%_showBar {
If (Config_verticalBarPos = "top") {
bTop := monitorTop
monitorTop += Bar_height
} Else If (Config_verticalBarPos = "bottom") {
bTop := monitorBottom - Bar_height
monitorBottom -= Bar_height
}
}
Monitor_#%m%_height := monitorBottom - monitorTop
Monitor_#%m%_width := monitorRight - monitorLeft
Monitor_#%m%_x := monitorLeft
Monitor_#%m%_y := monitorTop
Monitor_#%m%_barY := bTop
}
Monitor_moveWindow(m, wndId) {
Local fX, fY, monitor, wndHeight, wndWidth, wndX, wndY
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
monitor := Monitor_get(wndX+wndWidth/2, wndY+wndHeight/2)
If Not (m = monitor) {
; move the window to the target monitor and scale it, if it does not fit on the monitor
fX := Monitor_#%m%_width / Monitor_#%monitor%_width
fY := Monitor_#%m%_height / Monitor_#%monitor%_height
If (wndX-Monitor_#%monitor%_x+wndWidth > Monitor_#%m%_width) Or (wndY-Monitor_#%monitor%_y+wndHeight > Monitor_#%m%_height)
Manager_winMove(wndId, Monitor_#%m%_x+fX*(wndX-Monitor_#%monitor%_x), Monitor_#%m%_y+fY*(wndY-Monitor_#%monitor%_y), fX*wndWidth, fY*wndHeight)
Else
Manager_winMove(wndId, Monitor_#%m%_x+(wndX-Monitor_#%monitor%_x), Monitor_#%m%_y+(wndY-Monitor_#%monitor%_y), wndWidth, wndHeight)
}
}
Monitor_setWindowTag(t) {
Local aView, aWndId, wndId
If (t = ">")
t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount)
Else If (t = "<")
t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount)
WinGet, aWndId, ID, A
If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount) {
If (t = 0) {
Loop, % Config_viewCount
If Not (Manager_#%aWndId%_tags & (1 << A_Index - 1)) {
View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds
View_#%Manager_aMonitor%_#%A_Index%_aWndId := aWndId
Bar_updateView(Manager_aMonitor, A_Index)
Manager_#%aWndId%_tags += 1 << A_Index - 1
}
} Else {
Loop, % Config_viewCount
If Not (A_index = t) {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0
Bar_updateView(Manager_aMonitor, A_Index)
}
If Not (Manager_#%aWndId%_tags & (1 << t - 1))
View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds
View_#%Manager_aMonitor%_#%t%_aWndId := aWndId
Manager_#%aWndId%_tags := 1 << t - 1
aView := Monitor_#%Manager_aMonitor%_aView_#1
If Not (t = aView) {
Manager_hideShow := True
wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";")-1)
Manager_winActivate(wndId)
Manager_hideShow := False
If Config_viewFollowsTagged
Monitor_activateView(t)
Else {
Manager_hideShow := True
WinHide, ahk_id %aWndId%
Manager_hideShow := False
View_arrange(Manager_aMonitor, aView)
Bar_updateView(Manager_aMonitor, t)
}
}
}
}
}
Monitor_toggleBar() {
Global
Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar
Bar_toggleVisibility(Manager_aMonitor)
Monitor_getWorkArea(Manager_aMonitor)
View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
Manager_winActivate(Bar_aWndId)
}
Monitor_toggleTaskBar() {
Local m
m := Manager_aMonitor
If (m = Manager_taskBarMonitor) {
Manager_showTaskBar := Not Manager_showTaskBar
Manager_hideShow := True
If Not Manager_showTaskBar {
WinHide, Start ahk_class Button
WinHide, ahk_class Shell_TrayWnd
} Else {
WinShow, Start ahk_class Button
WinShow, ahk_class Shell_TrayWnd
}
Manager_hideShow := False
Monitor_getWorkArea(m)
Bar_move(m)
View_arrange(m, Monitor_#%m%_aView_#1)
}
}
Monitor_toggleWindowTag(t) {
Local aWndId, wndId
WinGet, aWndId, ID, A
If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount) {
If (Manager_#%aWndId%_tags & (1 << t - 1)) {
If Not ((Manager_#%aWndId%_tags - (1 << t - 1)) = 0) {
Manager_#%aWndId%_tags -= 1 << t - 1
StringReplace, View_#%Manager_aMonitor%_#%t%_wndIds, View_#%Manager_aMonitor%_#%t%_wndIds, %aWndId%`;,
Bar_updateView(Manager_aMonitor, t)
If (t = Monitor_#%Manager_aMonitor%_aView_#1) {
Manager_hideShow := True
WinHide, ahk_id %aWndId%
Manager_hideShow := False
wndId := SubStr(View_#%Manager_aMonitor%_#%t%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%t%_wndIds, ";")-1)
Manager_winActivate(wndId)
View_arrange(Manager_aMonitor, t)
}
}
} Else {
View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds
View_#%Manager_aMonitor%_#%t%_aWndId := aWndId
Bar_updateView(Manager_aMonitor, t)
Manager_#%aWndId%_tags += 1 << t - 1
}
}
}

91
src/Session.ahk Normal file
View file

@ -0,0 +1,91 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.2.0.03 (24.07.2011)
*/
Session_restore(section, m=0) {
Local i, type, var, var0, var1, var2
If FileExist(Config_sessionFilePath) {
If (section = "Config") {
Loop, READ, %Config_sessionFilePath%
If (SubStr(A_LoopReadLine, 1, 7) = "Config_") {
StringSplit, var, A_LoopReadLine, =
type := SubStr(var1, 1, 13)
If (type = "Config_hotkey")
Config_hotkeyCount += 1
Else If (type = "Config_rules_") {
i := SubStr(var1, 14)
If (i > Config_rulesCount) {
Config_rulesCount += 1
i := Config_rulesCount
var1 := "Config_rules_#" i
}
}
%var1% := var2
}
} Else If (section = "Monitor") {
Loop, READ, %Config_sessionFilePath%
If (SubStr(A_LoopReadLine, 1, 10+StrLen(m)) = "Monitor_#" m "_" Or SubStr(A_LoopReadLine, 1, 8+StrLen(m)) = "View_#" m "_#") {
StringSplit, var, A_LoopReadLine, =
%var1% := var2
}
}
}
}
Session_save() {
Local m, text
text := "; bug.n - tiling window management`n; @version " VERSION " (" A_DD "." A_MM "." A_YYYY ")`n`n"
If FileExist(Config_sessionFilePath) {
Loop, READ, %Config_sessionFilePath%
If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
text .= A_LoopReadLine "`n"
text .= "`n"
}
FileDelete, %Config_sessionFilePath%
Loop, % Manager_monitorCount {
m := A_Index
If Not (Monitor_#%m%_aView_#1 = 1)
text .= "Monitor_#" m "_aView_#1=" Monitor_#%m%_aView_#1 "`n"
If Not (Monitor_#%m%_aView_#2 = 1)
text .= "Monitor_#" m "_aView_#2=" Monitor_#%m%_aView_#2 "`n"
If Not (Monitor_#%m%_showBar = Config_showBar)
text .= "Monitor_#" m "_showBar=" Monitor_#%m%_showBar "`n"
Loop, % Config_viewCount {
If Not (View_#%m%_#%A_Index%_layout_#1 = 1)
text .= "View_#" m "_#" A_Index "_layout_#1=" View_#%m%_#%A_Index%_layout_#1 "`n"
If Not (View_#%m%_#%A_Index%_layout_#2 = 1)
text .= "View_#" m "_#" A_Index "_layout_#2=" View_#%m%_#%A_Index%_layout_#2 "`n"
If Not (View_#%m%_#%A_Index%_layoutAxis_#1 = Config_layoutAxis_#1)
text .= "View_#" m "_#" A_Index "_layoutAxis_#1=" View_#%m%_#%A_Index%_layoutAxis_#1 "`n"
If Not (View_#%m%_#%A_Index%_layoutAxis_#2 = Config_layoutAxis_#2)
text .= "View_#" m "_#" A_Index "_layoutAxis_#2=" View_#%m%_#%A_Index%_layoutAxis_#2 "`n"
If Not (View_#%m%_#%A_Index%_layoutAxis_#3 = Config_layoutAxis_#3)
text .= "View_#" m "_#" A_Index "_layoutAxis_#3=" View_#%m%_#%A_Index%_layoutAxis_#3 "`n"
If Not (View_#%m%_#%A_Index%_layoutMFact = Config_layoutMFactor)
text .= "View_#" m "_#" A_Index "_layoutMFact=" View_#%m%_#%A_Index%_layoutMFact "`n"
If Not (View_#%m%_#%A_Index%_layoutMSplit = 1)
text .= "View_#" m "_#" A_Index "_layoutMSplit=" View_#%m%_#%A_Index%_layoutMSplit "`n"
}
}
FileAppend, %text%, %Config_sessionFilePath%
}

325
src/View.ahk Normal file
View file

@ -0,0 +1,325 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.2.0.03 (24.07.2011)
*/
View_init(m, v) {
Global
View_#%m%_#%v%_aWndId := 0
View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#2 := 1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2
View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3
View_#%m%_#%v%_layoutMFact := Config_layoutMFactor
View_#%m%_#%v%_layoutMSplit := 1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_wndIds := ""
}
View_activateWindow(d) {
Local aWndId, i, j, v, wndId, wndId0, wndIds
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `;
If (wndId0 > 1) {
Loop, % wndId0
If (wndId%A_Index% = aWndId) {
i := A_Index
Break
}
j := Manager_loop(i, d, 1, wndId0)
wndId := wndId%j%
WinSet, AlwaysOnTop, On, ahk_id %wndId%
WinSet, AlwaysOnTop, Off, ahk_id %wndId%
If Manager_#%aWndId%_isFloating
WinSet, Bottom, , ahk_id %aWndId%
Manager_winActivate(wndId)
}
}
View_arrange(m, v) {
Local fn, l, wndIds
l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l%
If fn And (View_getTiledWndIds(m, v, wndIds) Or fn = "tile")
View_%fn%(m, v, wndIds)
Else
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l%
Bar_updateLayout(m)
}
View_getTiledWndIds(m, v, ByRef tiledWndIds) {
Local n, wndIds
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
If Not Manager_#%A_LoopField%_isFloating {
n += 1
tiledWndIds .= A_LoopField ";"
}
}
Return, n
}
View_monocle(m, v, wndIds) {
Local wndId0
StringTrimRight, wndIds, wndIds, 1
StringSplit, wndId, wndIds, `;
Loop, % wndId0
Manager_winMove(wndId%A_Index%, Monitor_#%m%_x, Monitor_#%m%_y, Monitor_#%m%_width, Monitor_#%m%_height)
View_#%m%_#%v%_layoutSymbol := "[" wndId0 "]"
}
View_rotateLayoutAxis(i, d) {
Local f, l, v
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile") And (i = 1 Or i = 2 Or i = 3) {
If (i = 1) {
If (d = +2)
View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% *= -1
Else {
f := View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% / Abs(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%)
View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% := f * Manager_loop(Abs(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%), d, 1, 2)
}
} Else
View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% := Manager_loop(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%, d, 1, 3)
View_arrange(Manager_aMonitor, v)
}
}
View_setLayout(l) {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If (l = -1)
l := View_#%Manager_aMonitor%_#%v%_layout_#2
If (l = ">")
l := Manager_loop(View_#%Manager_aMonitor%_#%v%_layout_#1, +1, 1, Config_layoutCount)
If (l > 0) And (l <= Config_layoutCount) {
If Not (l = View_#%Manager_aMonitor%_#%v%_layout_#1) {
View_#%Manager_aMonitor%_#%v%_layout_#2 := View_#%Manager_aMonitor%_#%v%_layout_#1
View_#%Manager_aMonitor%_#%v%_layout_#1 := l
}
View_arrange(Manager_aMonitor, v)
}
}
View_setMFactor(d) {
Local l, mfact, v
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile") {
mfact := 0
If (d >= 1.05)
mfact := d
Else
mfact := View_#%Manager_aMonitor%_#%v%_layoutMFact + d
If (mfact >= 0.05 And mfact <= 0.95) {
View_#%Manager_aMonitor%_#%v%_layoutMFact := mfact
View_arrange(Manager_aMonitor, v)
}
}
}
View_setMSplit(d) {
Local l, n, v, wndIds
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile") {
n := View_getTiledWndIds(Manager_aMonitor, v, wndIds)
View_#%Manager_aMonitor%_#%v%_layoutMSplit := Manager_loop(View_#%Manager_aMonitor%_#%v%_layoutMSplit, d, 1, n)
View_arrange(Manager_aMonitor, v)
}
}
View_shuffleWindow(d) {
Local aWndHeight, aWndId, aWndWidth, aWndX, aWndY, i, j, l, search, v, wndId0, wndIds
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile" And InStr(Manager_managedWndIds, aWndId ";")) {
View_getTiledWndIds(Manager_aMonitor, v, wndIds)
StringTrimRight, wndIds, wndIds, 1
StringSplit, wndId, wndIds, `;
If (wndId0 > 1) {
Loop, % wndId0
If (wndId%A_Index% = aWndId) {
i := A_Index
Break
}
If (d = 0 And i = 1)
j := 2
Else
j := Manager_loop(i, d, 1, wndId0)
If (j > 0 And j <= wndId0) {
If (j = i) {
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %aWndId%`;,
View_#%Manager_aMonitor%_#%v%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%v%_wndIds
} Else {
search := wndId%j%
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %aWndId%, SEARCH
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %search%, %aWndId%
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, SEARCH, %search%
}
View_arrange(Manager_aMonitor, v)
If Config_mouseFollowsFocus {
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
DllCall("SetCursorPos", "Int", Round(aWndX + aWndWidth / 2), "Int", Round(aWndY + aWndHeight / 2))
}
}
}
}
}
View_tile(m, v, wndIds) {
Local axis1, axis2, axis3, h1, h2, i, mfact, msplit, n1, n2, sym1, sym3, w1, w2, wndId0, x1, x2, y1, y2
axis1 := View_#%m%_#%v%_layoutAxis_#1
axis2 := View_#%m%_#%v%_layoutAxis_#2
axis3 := View_#%m%_#%v%_layoutAxis_#3
mfact := View_#%m%_#%v%_layoutMFact
msplit := View_#%m%_#%v%_layoutMSplit
StringTrimRight, wndIds, wndIds, 1
StringSplit, wndId, wndIds, `;
If (msplit > wndId0) {
If (wndId0 < 1)
View_#%m%_#%v%_layoutMSplit := 1
Else
View_#%m%_#%v%_layoutMSplit := wndId0
msplit := View_#%m%_#%v%_layoutMSplit
}
; layout symbol
sym1 := "="
If (axis2 = Abs(axis1))
sym1 := "|"
If (axis2 = 3)
If (wndId0 = 0)
sym1 := 0
Else
sym1 := msplit
sym3 := "="
If (axis3 = Abs(axis1))
sym3 := "|"
If (axis3 = 3)
If (wndId0 = 0)
sym3 := 0
Else
sym3 := wndId0 - msplit
If (axis1 < 0)
If (msplit = 1)
View_#%m%_#%v%_layoutSymbol := sym3 "[]"
Else
View_#%m%_#%v%_layoutSymbol := sym3 "[" sym1
Else
If (msplit = 1)
View_#%m%_#%v%_layoutSymbol := "[]" sym3
Else
View_#%m%_#%v%_layoutSymbol := sym1 "]" sym3
If (wndId0 > 0) {
; master and stack area
h1 := Monitor_#%m%_height
h2 := Monitor_#%m%_height
w1 := Monitor_#%m%_width
w2 := Monitor_#%m%_width
x1 := Monitor_#%m%_x
x2 := Monitor_#%m%_x
y1 := Monitor_#%m%_y
y2 := Monitor_#%m%_y
If (Abs(axis1) = 1 And wndId0 > msplit) {
w1 *= mfact
w2 -= w1
If (axis1 < 0)
x1 += w2
Else
x2 += w1
} Else If (Abs(axis1) = 2 And wndId0 > msplit) {
h1 *= mfact
h2 -= h1
If (axis1 < 0)
y1 += h2
Else
y2 += h1
}
; master
If (axis2 != 1 Or w1 / msplit < 161)
n1 := 1
Else
n1 := msplit
If (axis2 != 2 Or h1 / msplit < Bar_height)
n2 := 1
Else
n2 := msplit
Loop, % msplit {
Manager_winMove(wndId%A_Index%, x1, y1, w1 / n1, h1 / n2)
If (n1 > 1)
x1 += w1 / n1
If (n2 > 1)
y1 += h1 / n2
}
; stack
If (wndId0 > msplit) {
If (axis3 != 1 Or w2 / (wndId0 - msplit) < 161)
n1 := 1
Else
n1 := wndId0 - msplit
If (axis3 != 2 Or h2 / (wndId0 - msplit) < Bar_height)
n2 := 1
Else
n2 := wndId0 - msplit
Loop, % wndId0 - msplit {
i := msplit + A_Index
Manager_winMove(wndId%i%, x2, y2, w2 / n1, h2 / n2)
If (n1 > 1)
x2 += w2 / n1
If (n2 > 1)
y2 += h2 / n2
}
}
}
}
View_toggleFloating() {
Local aWndId, l, v
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% And InStr(Manager_managedWndIds, aWndId ";")) {
Manager_#%aWndId%_isFloating := Not Manager_#%aWndId%_isFloating
View_arrange(Manager_aMonitor, v)
}
}

239
src/docs/configuration.t2t Normal file
View file

@ -0,0 +1,239 @@
%!encoding: iso-8859-1
%!options(html): --css-sugar -o configuration.html
%!style(html): ../styles.css
%!preproc(html): '%%html: ' ''
%!postproc(html): '<HEAD>' '<HEAD>\n<TITLE>joten @ AutoHotkey</TITLE>'
%!postproc(html): '<HEAD>' '<HEAD>\n<LINK REL="icon" HREF="../images/jn.ico" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="author" CONTENT="joten" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="keywords" CONTENT="AutoHotkey, joten, bug.n, tiling, window management" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="description" CONTENT="AutoHotkey scripts by joten" />'
%!postproc(html): '<H1>' '<H1 ID="bugn">'
%!postproc(html): '\(c\)' '&copy;'
%!options(txt): -o configuration.txt
%!preproc(txt): '%%txt: ' ''
%!postproc(txt): '<BR>' ''
= bug.n/configuration =
------------------------------------------------------------------------
=== bug.n GUI ===
: **Config_showBar**=1
If false (=0), the bar is hidden. It can be made visible or hidden by hotkey.
: **Config_topBar**=1
If false (=0), the bar is at the bottom.
: **Config_fontName**=Lucida Console
A monospace font is preferable for bug.n to calculate the correct width
of the bar and its elements (sub-windows).
: **Config_fontSize**=
Font size in pixel. The default value is retrieved from the "Window
Color and Appearance" settings for the "Active Title Bar".
: **Config_normBgColor**=
Normal background color of bar elements. The first color is the color
for views without windows and the title bar (default: COLOR_MENU), the
second color is the first for the 'window count gradient' (default:
COLOR_INACTIVECAPTION) indicating one window on a view, the third color
is the second for the 'window count gradient' (default:
COLOR_GRADIENTINACTIVECAPTION) indicating ten or more windows, the color
indicating two to nine windows is calculated by bug.n. Beside defining
those three colors in the format "RRGGBB;RRGGBB;RRGGBB", you may also
explicitly define all ten colors. The default values are retrieved from
the "Window Color and Appearance" settings for the "Inactive Title
Bar".
: **Config_normFgColor**=
Normal foreground (i. e. text) color of bar elements as described
above. The default values are retrieved from the "Window Color and
Appearance" settings for the "Inactive Title Bar".
: **Config_selBgColor**=
Background colour of 'selected' or highlighted bar elements. The first
colour is used for the active view (default: COLOR_HIGHLIGHT), the
second color is used for the first status information field (default:
COLOR_ACTIVECAPTION), the third color is used for the status information
indicating a decreasing battery level, the layout symbol and the command
symbol, which is the last field in the status bar (default:
COLOR_GRADIENTACTIVECAPTION), the fourth color is used for an alarming
battery level (default: inverted COLOR_ACTIVECAPTION). The additional
status information fields get colors from the gradient calculated by
bug.n from the first and last status information field. The default
values are retrieved from the "Window Color and Appearance" settings for
the "Active Title Bar" and "Selected Items".
: **Config_selFgColor**=
Foreground colour of 'selected' or highlighted bar elements as described
above. The default values are retrieved from the "Window Color and
Appearance" settings for the "Active Title Bar" and "Selected Items".
: **Config_readinBat**=0
If true (=1), the system battery status is read in and displayed in
the status bar. This only makes sense, if you have a system battery
(notebook).
: **Config_readinCpu**=0
If true (=1), the current CPU load is read in and displayed in the status bar.
: **Config_readinDate**=1
If true (=1), the current date is read in (format: "WW, DD. MMM.
YYYY") and displayed in the status bar.
: **Config_readinTime**=1
If true (=1), the current time is read in (format: "HH:MM") and
displayed in the status bar.
: **Config_readinInterval**=30000
Time in milliseconds after which the above status values are refreshed.
=== Windows UI ===
: **Config_bbCompatibility**=0
If true (=1), bug.n looks for BlackBox components (bbLeanBar, bbSlit
and SystemBarEx) when calculating the work area. It is assumed that
the virtual desktop functionality of BlackBox and NOT bug.n is used
(**=> Hiding and showing windows is detected and acted upon).
: **Config_borderWidth**=0
If > 0, the window border width is set to the integer value
Config_borderWidth.
: **Config_borderPadding**=-1
If >= 0, the window border padding is set to the integer value
Config_borderPadding (only for Windows >**= Vista).
: **Config_showTaskBar**=0
If false (=0), the task bar is hidden. It can be made visible or
hidden by hotkey (see below).
: **Config_showBorder**=1
If false (=0), the window borders are hidden; therefor windows cannot
be resized manually by dragging the border, even if using the
according hotkey.
: **Config_selBorderColor**=
Border colour of the active window; format: 0x00BBGGRR (e. g.
"0x006A240A", if empty, the system's window border colour is not
changed).
=== View / Layout ===
: **Config_viewCount**=9
The total number of views. This has effects on the displayed groups in
the bar, and should not be exceeded in the hotkeys below.
: **Config_layoutAxis[1]**=1
The layout axis: 1 = x, 2 = y; negative values mirror the layout,
setting the master area to the right / bottom instead of left / top.
: **Config_layoutAxis[2]**=2
The master axis: 1 = x (from left to right), 2 = y (from top to
bottom), 3 = z (monocle).
: **Config_layoutAxis[3]**=2
The stack axis: 1 = x (from left to right), 2 = y (from top to
bottom), 3 = z (monocle).
: **Config_layoutMFactor**=0.6
The factor for the size of the master area, which is multiplied by the
monitor size.
=== Runtime ===
: **Config_mouseFollowsFocus**=1
If true (=1), the mouse pointer is set over the focused window, if a
window is activated by bug.n.
: **Config_shellMsgDelay**=350
The time bug.n waits after a shell message (a window is opened, closed
or the focus has been changed); if there are any problems recognizing,
when windows are opened or closed, try to increase this number.
: **Config_viewFollowsTagged**=0
If true (=1), the view is set to, if a window is tagged with a single
tag.
=== Rules ===
: **Config_rules[1]**=.*;.*;;1;0;0;0;0;0
At first you may set a default rule (.*;.*;) for a default monitor,
view and / or showing window title bars. General format:
Config_rules[i]=<class (regular expression string)>;<title (regular
expression string)>;<window style (hexadecimal number or blank)>;<is
managed (1 = True or 0 = False)>;<monitor (0 <= integer <= total number
of monitors, 0 means the currently active monitor)>;<tags (binary mask
as integer >= 0, e. g. 17 for 1 and 5, 0 means the currently active
tag)>;<is floating (1 = True or 0 = False)>;<is decorated (1 = True or
0 = False)>;<hide title (1 = True or 0 = False)>" (";" is not allowed
as a character).
: **Config_rules[2]**=.*;.*;0x80000000;0;0;0;1;1;1
Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are
floating and the titles are hidden.
: **Config_rules[3]**=SWT_Window0;.*;;1;0;0;0;0;0
Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP,
but should excluded from the above rule.
: **Config_rules[4]**=Xming;.*;;1;0;0;0;0;0
Xming windows have the style WS_POPUP, but should be excluded from the
above rule.
: **Config_rules[5]**=_sp;_sp;;1;0;0;1;0;1
: **Config_rules[6]**=MozillaDialogClass;.*;;1;0;0;1;1;0
: **Config_rules[7]**=MsiDialog(No)?CloseClass;.*;;1;0;0;1;1;0
: **Config_rules[8]**=gdkWindowToplevel;GIMP-Start;;1;0;0;1;1;0
: **Config_rules[9]**=gdkWindowToplevel;GNU Image Manipulation Program;;1;0;0;1;1;0
: **Config_rules[10]**=gdkWindowToplevel;Werkzeugkasten;;1;0;0;1;1;0
: **Config_rules[11]**=gdkWindowToplevel;Ebenen, .* - Pinsel, Muster, .*;;1;0;0;1;1;0
: **Config_rules[12]**=gdkWindowToplevel;Toolbox;;1;0;0;1;1;0
: **Config_rules[13]**=gdkWindowToplevel;Layers, Channels, Paths, .*;;1;0;0;1;1;0
: **Config_rules[14]**=CalcFrame;.*;;1;0;0;1;1;0
: **Config_rulesCount**=14
The total number of active rules above.
Using an indexing number less or equal to "Config_rulesCount" replaces
this rule. Additional rules need an increasing indexing number higher
than the value for "Config_rulesCount".
=== Session management ===
: **Config_autoSaveSession**=0
Automatically save the current state of monitors, views, layouts
(active view, layout, axes, mfact and msplit) to te session file (set
below) when quitting bug.n.
=== Hotkeys ===
: **Config_hotkey[i]**=<key name>::<command or function name>
You may overwrite default or add new hotkeys by using the above
format. The indexing numbers ("i") should start with 1 and be
sequential. "<key name>::<command or function name>" is the original
syntax from AutoHotkey as described in
http://www.autohotkey.com/docs/Hotkeys.htm.
- To deacivate a default hotkey as listed in %%LINK_hotkeys, add a new
line in the format "Config_hotkey[i]=<key name>::" (without a
function name).
- To assign an internal function of bug.n to a new hotkey, add a line
as documented in %%LINK_hotkeys, but with the new key name.
- To assign an external program to a new hotkey, add a line in the
general format using the "Run" command of AutoHotkey as described in
http://www.autohotkey.com/docs/commands/Run.htm ("Run, Target [,
WorkingDir, Max|Min|Hide]").
- You may also use the "Send" command of AutoHotkey as described in
http://www.autohotkey.com/docs/commands/Send.htm
''<BR>''
------------------------------------------------------------------------
%%html: (c) 2010-2011 joten, last modified %%date(%d.%m.%Y) ([View txt2tags source %%infile]) [../images/jn.png]
%%txt: (c) 2010-2011 joten, last modified %%date(%d.%m.%Y)

212
src/docs/help.t2t Normal file
View file

@ -0,0 +1,212 @@
%!encoding: iso-8859-1
%!options(html): --css-sugar -o help.html
%!style(html): ../styles.css
%!preproc(html): '%%html: ' ''
%!postproc(html): '<HEAD>' '<HEAD>\n<TITLE>joten @ AutoHotkey</TITLE>'
%!postproc(html): '<HEAD>' '<HEAD>\n<LINK REL="icon" HREF="../images/jn.ico" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="author" CONTENT="joten" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="keywords" CONTENT="AutoHotkey, joten, bug.n, tiling, window management" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="description" CONTENT="AutoHotkey scripts by joten" />'
%!postproc(html): '<H1>' '<H1 ID="bugn">'
%!postproc(html): '">http://www.autohotkey.com/' '" TARGET="_blank">http://www.autohotkey.com/'
%!postproc(html): '%%LINK_configuration' '<A HREF="configuration.html">bug.n/configuration</A>'
%!postproc(html): '%%LINK_hotkeys' '<A HREF="hotkeys.html">bug.n/hotkeys</A>'
%!postproc(html): '\(c\)' '&copy;'
%!options(txt): -o help.txt
%!preproc(txt): '%%txt: ' ''
%!postproc(txt): '<BR>' ''
%!postproc(txt): '%%LINK_configuration' 'docs/configuration.txt'
%!postproc(txt): '%%LINK_hotkeys' 'docs/hotkeys.txt'
= bug.n/help =
------------------------------------------------------------------------
bug.n is a tiling window manager for Microsoft Windows.''<BR>''
The advantages of tiling window management over the standard stacking
window management of Microsoft Windows are as follows:
- You do not have to move and resize windows manually by mouse.
- Windows are positioned and sized applying a layout, which utilizes all
available screen estate.
Additionally bug.n increases the available screen estate by freeing up
the space occupied by
- the Microsoft Windows Taskbar
- the title bar for every single window
by hiding and replacing all with a single slim status bar (but bug.n is
not a shell replacement).
This status bar may show the following:
- system information
- time
- date
- CPU usage
- battery level
- active window title
- layout
- []= (tile)
- [M] (monocle)
- ><> (floating)
- up to nine views indicating
- the active view
- how many windows are tagged with and shown on the view with the same
number
=== Layouts ===
There are three layouts.
+ **tile**''<BR>''
A master area for the main window(s) and a stacking area for the rest,
all windows are shown at any time. This layout can be further changed
in the following respects:
- the number of windows in the master area (1 ... all)
- the stacking direction of the master and stacking area (from left to
right, from top to bottom or monocle)
- the position of the master area (left, top, right or bottom)
- the witdh or height of the master area (depending on its position)
+ **monocle**''<BR>''
All windows are maximized and only one is shown at any time.
+ **floating**''<BR>''
Do not tile any window.
=== Tagging ===
bug.n features an extended implementation of virtual desktops:
tagging.''<BR>''
Windows are tagged with one or more numbers, which determine on which
views they are shown. Selecting a view shows the windows tagged with the
same number and hides all other windows.
=== Session Management ===
bug.n features a session management, which is used for saving
configuration variables of bug.n, but not for restoring applications.
The configuration variables may include those listed
in %%LINK_configuration, hotkeys as listed in %%LINK_hotkeys and
internal variables for the current state of bug.n, e. g. the active view
(saved for each monitor) and layout (saved for each view).
== Preliminary note ==
There are two forms in which you can run bug.n:
+ the compiled executable
+ the AutoHotkey script
Depending on which form you choose, the following procedures
(installing, running and customizing) are different. Using the compiled
executable may be easier but is also less flexible for customization.
== Installing and running bug.n ==
There is no installation wizard for bug.n. If you downloaded this
package and unpacked it, it should be in a directory, where you have
read and write access. This is the only requirement for using bug.n (at
least for saving the bug.n session file). Apart from that you may copy
bug.n to any directory.
+ If you choose to use the executable and want to save it to a
directory, to which you do not have write access, you will have to run
bug.n with a parameter indicating the file path to the session file
(<file path to the bug.n executable> <file path to the session file>),
e. g. "C:\Program Files\bugn\bugn.exe C:\Users\joten\bugn.ini".
+ If you choose to use the AutoHotkey script, you will need a version of
AutoHotkey (available from http://www.autohotkey.com/download) and a
file association for AutoHotkey scripts to the AutoHotkey executable
(*.ahk -> <file path to AutoHotkey.exe>). You will than have to run
"Main.ahk" from within the "source" directory of bug.n.
=== Microsoft Windows Vista / 7 and UAC ===
If you are using bug.n on Microsoft Windows Vista or 7 you may use
applications, which run with administrator privileges e. g.
administrative tools and therefor are not managed by bug.n. If you want
those applications to be managed, you need to run bug.n with
administrator privileges, too.
+ If you choose to use the executable, you can set the option "Run this
program as an administrator" on the "Compatiblity" tab, section
"Privilege level" of the bug.n executable file properties.
+ If you choose to use the AutoHotkey script, you will have to use a
command script like "run.cmd" provided in the "source" directory of
bug.n. Please adjust the file pathes in this file depending on your
working environment and than create a link to the file. In the file
properties of this link you can set the option "Run this program as an
administrator" on the "Compatiblity" tab, section "Privilege level".
You will than have to run bug.n through this link.
== Customization ==
Customization can be done
- with configuration variables for
- the appearance of the bug.n status bar (font, colour and content)
- controlling Windows UI elements (border width and colour, hiding
elements)
- default values (number of tags, layouts, runtime and session
management)
- rules controlling specific windows (i. a. exclusions)
- for hotkeys (the key bindings for the bug.n functions)
%%html: ''<P></P>''
+ If you use the executable, you can not change the layout symbols and
the order of the layouts. The available configuration variables are
listed in %%LINK_configuration.''<BR>''
To change these, first create a session file by using the hotkey
"WIN+CTRL+S". The file is either saved in the directory you specified
with the parameter to the executable, or in the same directory where the
executable is saved. You may then edit the file with a text editor
("WIN+CTRL+E" opens the file for editing) and add a new line for each
configuration variable with its value (format: <variable>=<value>, use
no quotation marks, 1 for true and 0 for false), e. g.
"Config_showBar=0". You will have to quit and run bug.n again for the
changes to take effect.
+ If you use the AutoHotkey script you can directly edit the file
"Config.ahk" in the "source" directory of bug.n and reload the script
with the hotkey "WIN+CTRL+R". You can additionally use the
configuration file as described above. Please refer to the
documentation of AutoHotkey for more information about writing an
AutoHotkey script, especially
- http://www.autohotkey.com/docs/Hotkeys.htm
- http://www.autohotkey.com/docs/Variables.htm
You may find a sample session file (Session_sample.ini) in the main
directory of bug.n.
== Usage ==
bug.n is mostly controlled with hotkeys. The available hotkeys are
listed in %%LINK_hotkeys. A list of all functions is available through
the command GUI. For a quick help there are the following hotkeys:
- WIN+Y: Show the command GUI.
- WIN+Space: Show / Hide the Windows Taskbar.
- WIN+CTRL+Q: Quit bug.n and restore all windows and Windows UI
elements.
The following functions can also be controlled with the mouse:
- With a click on a tag (a number on the left end of the status bar) you
can change the view and show only the windows associated with that tag.
- With a right-click on a tag you can tag the active window with that
tag.
- With a click on the layout symbol in the status bar you can toggle the
layout to the last used.
- With a right-click on the layout symbol you can set the layout to the
next in the list.
- A function can be selected from a list in the command GUI, which is
accessible by cklickig on "#!" on the right end of the status bar.
''<BR>''
------------------------------------------------------------------------
%%html: (c) 2010-2011 joten, last modified %%date(%d.%m.%Y) ([View txt2tags source %%infile]) [../images/jn.png]
%%txt: (c) 2010-2011 joten, last modified %%date(%d.%m.%Y)

212
src/docs/hotkeys.t2t Normal file
View file

@ -0,0 +1,212 @@
%!encoding: iso-8859-1
%!options(html): --css-sugar -o hotkeys.html
%!style(html): ../styles.css
%!preproc(html): '%%html: ' ''
%!postproc(html): '<HEAD>' '<HEAD>\n<TITLE>joten @ AutoHotkey</TITLE>'
%!postproc(html): '<HEAD>' '<HEAD>\n<LINK REL="icon" HREF="../images/jn.ico" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="author" CONTENT="joten" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="keywords" CONTENT="AutoHotkey, joten, bug.n, tiling, window management" />'
%!postproc(html): '<HEAD>' '<HEAD>\n<META NAME="description" CONTENT="AutoHotkey scripts by joten" />'
%!postproc(html): '<H1>' '<H1 ID="bugn">'
%!postproc(html): '\(c\)' '&copy;'
%!options(txt): -o hotkeys.txt
%!preproc(txt): '%%txt: ' ''
%!postproc(txt): '<BR>' ''
= bug.n/hotkeys =
------------------------------------------------------------------------
=== General description ===
**format**: <modifier><key>::<function>(<argument>)''<BR>''
**modifier**:
- ! = Alt (Mod1Mask)
- ^ = Ctrl (ControlMask)
- + = Shift (ShiftMask)
- # = LWin (Mod4Mask)
You will have to press all keys of a hotkey at the same time beginning
with the modifier for calling the associated function, e. g. "#^q" means
pressing the left Windows key and the shift key and the q key
(WIN+CTRL+Q) for quitting bug.n.
=== Window related hotkeys ===
: #Down::**View_activateWindow(+1)**
Activate the next window in the active view.
: #Up::**View_activateWindow(-1)**
Activate the previous window in the active view.
: #+Down::**View_shuffleWindow(+1)**
Move the active window to the next position in the window list of the
view.
: #+Up::**View_shuffleWindow(-1)**
Move the active window to the previous position in the window list of
the view.
: #+Enter::**View_shuffleWindow(0)**
Move the active window to the first position in the window list of the
view.
: #c::**Manager_closeWindow()**
Close the active window.
: #+d::**Manager_toggleDecor()**
Show / Hide the title bar of the active window.
: #+f::**View_toggleFloating()**
Toggle the floating status of the active window (i. e. dis- / regard
it when tiling).
: #+m::**Manager_moveWindow()**
Move the active window by key (only floating windows).
: #+s::**Manager_sizeWindow()**
Resize the active window by key (only floating windows).
: #+x::**Manager_maximizeWindow()**
Move and resize the active window to the size of the work area (only
floating windows).
: #i::**Manager_getWindowInfo()**
Get information for the active window (id, title, class, process name,
style, geometry, tags and floating state).
: #+i::**Manager_getWindowList()**
Get a window list for the active view (id, title and class).
=== Layout related hotkeys ===
: #Tab::**View_setLayout(-1)**
Set the previously set layout. You may also use View_setLayout(">")
for setting the next layout in the layout array.
: #f::**View_setLayout(3)**
Set the 3rd defined layout (i. e. floating layout in the default
configuration).
: #m::**View_setLayout(2)**
Set the 2nd defined layout (i. e. monocle layout in the default
configuration).
: #t::**View_setLayout(1)**
Set the 1st defined layout (i. e. tile layout in the default
configuration).
: #Left::**View_setMFactor(-0.05)**
Reduce the size of the master area in the active view (only for the
"tile" layout).
: #Right::**View_setMFactor(+0.05)**
Enlarge the size of the master area in the active view (only for the
"tile" layout).
: #^t::**View_rotateLayoutAxis(1, +1)**
Rotate the layout axis (i. e. 2 -> 1 = vertical layout, 1 -> 2 =
horizontal layout, only for the "tile" layout).
: #^Enter::**View_rotateLayoutAxis(1, +2)**
Mirror the layout axis (i. e. -1 -> 1 / 1 -> -1 = master on the left /
right side, -2 -> 2 / 2 -> -2 = master at top / bottom, only for the
"tile" layout).
: #^Tab::**View_rotateLayoutAxis(2, +1)**
Rotate the master axis (i. e. 3 -> 1 = x-axis = horizontal stack, 1 ->
2 = y-axis = vertical stack, 2 -> 3 = z-axis = monocle, only for the
"tile" layout).
: #^+Tab::**View_rotateLayoutAxis(3, +1)**
Rotate the stack axis (i. e. 3 -> 1 = x-axis = horizontal stack, 1 ->
2 = y-axis = vertical stack, 2 -> 3 = z-axis = monocle, only for the
"tile" layout).
: #^Left::**View_setMSplit(+1)**
Move the master splitter, i. e. decrease the number of windows in the
master area (only for the "tile" layout).
: #^Right::**View_setMSplit(-1)**
Move the master splitter, i. e. increase the number of windows in the
master area (only for the "tile" layout).
=== Tag / View related hotkeys ===
: #BackSpace::**Monitor_activateView(-1)**
Activate the previously activated view. You may also use
Monitor_activateView(">") for activating the next / adjacent view.
: #+0::**Monitor_setWindowTag(0)**
Tag the active window with all tags (1 ... 9).
: #<tag>::**Monitor_activateView(<tag>)**
Activate the view indicated by "<tag>" (choose one out of 1 ... 9), e.
g. #1::Monitor_activateView(1).
: #+<tag>::**Monitor_setWindowTag(<tag>)**
Tag the active window indicated by "<tag>" (choose one tag out of 1
... 9), e. g. #+1::Monitor_setWindowTag(1).
: #^<tag>::**Monitor_toggleWindowTag(<tag>)**
Add / Remove the tag indicated by "<tag>" (1 ... 9) for the active
window, if it is not / is already set, e. g.
#^1::Monitor_toggleWindowTag(1).
=== Monitor related hotkeys ===
: #.::**Manager_activateMonitor(+1)**
Activate the next monitor in a multi-monitor environment.
: #,::**Manager_activateMonitor(-1)**
Activate the previous monitor in a multi-monitor environment.
: #+.::**Manager_setWindowMonitor(+1)**
Set the active window to the active view on the next monitor in a
multi-monitor environment.
: #+,::**Manager_setWindowMonitor(-1)**
Set the active window to the active view on the previous monitor in a
multi-monitor environment.
: #^+.::**Manager_setViewMonitor(+1)**
Set all windows of the active view on the active view of the next
monitor in a multi-monitor environment.
: #^+,::**Manager_setViewMonitor(-1)**
Set all windows of the active view on the active view of the previous
monitor in a multi-monitor environment.
: #+Space::**Monitor_toggleBar()**
Hide / Show the bar (bug.n status bar) on the active monitor.
: #Space::**Monitor_toggleTaskBar()**
Hide / Show the task bar.
=== Application related hotkeys ===
: #y::**Bar_toggleCommandGui()**
Open the command GUI for executing programmes or bug.n functions.
: #^e::**Run, edit, %Config_sessionFilePath%**
Open the session file in the standard text editor.
: #^s::**Session_save()**
Save the current state of monitors, views, layouts.
: #^r::**Reload**
For resetting the confguration, if running bug.n as an Autohotkey script.
: #^q::**ExitApp**
Quit bug.n, restore the default Windows UI and show all windows.
''<BR>''
------------------------------------------------------------------------
%%html: (c) 2010-2011 joten, last modified %%date(%d.%m.%Y) ([View txt2tags source %%infile]) [../images/jn.png]
%%txt: (c) 2010-2011 joten, last modified %%date(%d.%m.%Y)

BIN
src/images/kfm.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/images/kfm.xcf Normal file

Binary file not shown.