/*
bug.n -- tiling window management
Copyright (c) 2010-2015 Joshua Fuhs, joten
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.
@license GNU General Public License version 3
../LICENSE.md or
@version 9.0.0
*/
Config_init() {
Local i, key, layout0, layout1, layout2, vNames0, vNames1, vNames2, vNames3, vNames4, vNames5, vNames6, vNames7, vNames8, vNames9
;; Status bar
Config_showBar := True
Config_horizontalBarPos := "left"
Config_verticalBarPos := "top"
Config_barWidth := "100%"
Config_singleRowBar := True
Config_spaciousBar := False
Config_fontName := "Lucida Console"
Config_fontSize :=
Config_largeFontSize := 24
Loop, 3 {
Config_backColor_#%A_Index% :=
Config_foreColor_#%A_Index% :=
Config_fontColor_#%A_Index% :=
}
Config_barTransparency := "off"
Config_barCommands := "Run, explore " Main_docDir ";Monitor_toggleBar();Main_reload();Reload;ExitApp"
Config_readinBat := False
Config_readinCpu := False
Config_readinDate := True
Config_readinDiskLoad := False
Config_readinMemoryUsage := False
Config_readinNetworkLoad := False
Config_readinTime := True
Config_readinVolume := False
Config_readinInterval := 30000
;; Windows ui elements
Config_bbCompatibility := False
Config_borderWidth := 0
Config_borderPadding := -1
Config_showTaskBar := False
Config_showBorder := True
Config_selBorderColor := ""
Config_scalingFactor := 1 ;; Undocumented. The value is retrieved by `Config_getSystemSettings()` from the registry.
;; It should not be set manually by the user,
;; but is dependant on the setting in the `Display control panel` of Windows under `Appearance and Personalization`.
;; Window arrangement
Config_viewNames := "1;2;3;4;5;6;7;8;9"
Config_layout_#1 := "[]=;tile"
Config_layout_#2 := "[M];monocle"
Config_layout_#3 := "><>;"
Config_layoutCount := 3
Config_layoutAxis_#1 := 1
Config_layoutAxis_#2 := 2
Config_layoutAxis_#3 := 2
Config_layoutGapWidth := 0
Config_layoutMFactor := 0.6
Config_areaTraceTimeout := 1000
Config_continuouslyTraceAreas := False
Config_dynamicTiling := True
Config_ghostWndSubString := " (Not Responding)"
Config_mFactCallInterval := 700
Config_mouseFollowsFocus := True
Config_newWndPosition := "top"
Config_onActiveHiddenWnds := "view"
Config_shellMsgDelay := 350
Config_syncMonitorViews := 0
Config_viewFollowsTagged := False
Config_viewMargins := "0;0;0;0"
;; Config_rule_# := ';;;;;;;;;'
Config_rule_#1 := ".*;.*;;1;0;0;0;0;0;" ;; default rule
Config_rule_#2 := ".*;.*;Window_isPopup;0;0;0;1;1;1;" ;; Pop-up windows (style WS_POPUP) will not be managed, are floating and the titles are hidden.
Config_rule_#3 := "SWT_Window0;.*;;1;0;0;0;0;0;" ;; Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP, but should be excluded from the second rule.
Config_rule_#4 := "QWidget;.*;;1;0;0;0;0;0;" ;; ... also windows created by QT (QWidget)
Config_rule_#5 := "Xming;.*;;1;0;0;0;0;0;" ;; ... and Xming windows
Config_rule_#6 := "MsiDialog(No)?CloseClass;.*;;1;0;0;1;1;0;"
Config_rule_#7 := "AdobeFlashPlayerInstaller;.*;;1;0;0;1;0;1;"
Config_rule_#8 := "CalcFrame;.*;;1;0;0;1;1;0;"
Config_rule_#9 := "MozillaDialogClass;.*;;1;0;0;1;1;0;"
Config_rule_#10 := "_sp;_sp;;1;0;0;1;0;1;"
Config_rule_#11 := "MozillaWindowClass;.*Mozilla Firefox;;1;0;0;0;1;0;maximize"
Config_rule_#12 := "Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;maximize"
;; @TODO [v9] Config_rule_#13 := "Chrome_WidgetWin_1;.*;0x80000000;0;0;0;1;1;0;" -- else pop-up windows are treated as new main windows, since #12 overrides #2
Config_ruleCount := 12 ;; This variable has to be set to the total number of active rules above.
;; Configuration management
Config_autoSaveSession := "auto" ;; "off" | "auto" | "ask"
Config_maintenanceInterval := 5000
Config_restoreConfig(Config_filePath)
Config_getSystemSettings()
Config_initColors()
Loop, % Config_layoutCount {
StringSplit, layout, Config_layout_#%A_Index%, `;
Config_layoutFunction_#%A_Index% := layout2
Config_layoutSymbol_#%A_Index% := layout1
}
StringSplit, vNames, Config_viewNames, `;
If vNames0 > 9
Config_viewCount := 9
Else
Config_viewCount := vNames0
Loop, % Config_viewCount
Config_viewNames_#%A_Index% := vNames%A_Index%
}
Config_initColors() {
Global
Loop, 3 {
StringReplace, Config_backColor_#%A_Index%, Config_backColor_#%A_Index%, `;0`;, `;000000`;, All
Config_backColor_#%A_Index% := RegExReplace(Config_backColor_#%A_Index%, "^0;", "000000;")
Config_backColor_#%A_Index% := RegExReplace(Config_backColor_#%A_Index%, ";0$", ";000000")
StringSplit, Config_backColor_#%A_Index%_#, Config_backColor_#%A_Index%, `;
StringReplace, Config_foreColor_#%A_Index%, Config_foreColor_#%A_Index%, `;0`;, `;000000`;, All
Config_foreColor_#%A_Index% := RegExReplace(Config_foreColor_#%A_Index%, "^0;", "000000;")
Config_foreColor_#%A_Index% := RegExReplace(Config_foreColor_#%A_Index%, ";0$", ";000000")
StringSplit, Config_foreColor_#%A_Index%_#, Config_foreColor_#%A_Index%, `;
StringReplace, Config_fontColor_#%A_Index%, Config_fontColor_#%A_Index%, `;0`;, `;000000`;, All
Config_fontColor_#%A_Index% := RegExReplace(Config_fontColor_#%A_Index%, "^0;", "000000;")
Config_fontColor_#%A_Index% := RegExReplace(Config_fontColor_#%A_Index%, ";0$", ";000000")
StringSplit, Config_fontColor_#%A_Index%_#, Config_fontColor_#%A_Index%, `;
}
}
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_backColor_#1, Config_foreColor_#1, Config_fontColor_#1
Global Config_backColor_#2, Config_foreColor_#2, Config_fontColor_#2
Global Config_backColor_#3, Config_foreColor_#3, Config_fontColor_#3
Global Config_fontName, Config_fontSize, Config_scalingFactor
If Not Config_fontName {
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 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, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 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_backColor_#1 And Config_foreColor_#1 And Config_fontColor_#1
And Config_backColor_#2 And Config_foreColor_#2 And Config_fontColor_#2
And Config_backColor_#3 And Config_foreColor_#3 And Config_fontColor_#3) {
COLOR_ACTIVECAPTION := Config_convertSystemColor(DllCall("GetSysColor", "Int", 2))
COLOR_CAPTIONTEXT := Config_convertSystemColor(DllCall("GetSysColor", "Int", 9))
COLOR_GRADIENTACTIVECAPTION := Config_convertSystemColor(DllCall("GetSysColor", "Int", 27))
COLOR_GRADIENTINACTIVECAPTION := Config_convertSystemColor(DllCall("GetSysColor", "Int", 28))
COLOR_HIGHLIGHT := Config_convertSystemColor(DllCall("GetSysColor", "Int", 13))
COLOR_INACTIVECAPTION := Config_convertSystemColor(DllCall("GetSysColor", "Int", 3))
COLOR_INACTIVECAPTIONTEXT := Config_convertSystemColor(DllCall("GetSysColor", "Int", 19))
COLOR_MENU := Config_convertSystemColor(DllCall("GetSysColor", "Int", 4))
COLOR_MENUTEXT := Config_convertSystemColor(DllCall("GetSysColor", "Int", 7))
;; ;;;;