2012-11-26 23:52:18 +00:00
|
|
|
/*
|
|
|
|
bug.n -- tiling window management
|
2015-01-25 12:07:37 +00:00
|
|
|
Copyright (c) 2010-2015 Joshua Fuhs, joten
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-01-25 12:07:37 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-11-26 23:52:18 +00:00
|
|
|
GNU General Public License for more details.
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-25 12:07:37 +00:00
|
|
|
@license GNU General Public License version 3
|
|
|
|
../LICENSE.md or <http://www.gnu.org/licenses/>
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-25 13:04:17 +00:00
|
|
|
@version 9.0.0
|
2012-11-26 23:52:18 +00:00
|
|
|
*/
|
2011-07-27 17:43:34 +00:00
|
|
|
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_init() {
|
2012-11-26 23:52:18 +00:00
|
|
|
Local i, key, layout0, layout1, layout2, vNames0, vNames1, vNames2, vNames3, vNames4, vNames5, vNames6, vNames7, vNames8, vNames9
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Status bar
|
|
|
|
Config_showBar := True
|
|
|
|
Config_horizontalBarPos := "left"
|
|
|
|
Config_verticalBarPos := "top"
|
|
|
|
Config_barWidth := "100%"
|
|
|
|
Config_singleRowBar := True
|
|
|
|
Config_spaciousBar := False
|
|
|
|
Config_fontName := "Lucida Console"
|
2012-12-05 12:39:51 +00:00
|
|
|
Config_fontSize :=
|
2014-03-03 10:56:37 +00:00
|
|
|
Config_largeFontSize := 24
|
2015-01-30 19:13:10 +00:00
|
|
|
Loop, 3 {
|
|
|
|
Config_backColor_#%A_Index% :=
|
|
|
|
Config_foreColor_#%A_Index% :=
|
|
|
|
Config_fontColor_#%A_Index% :=
|
|
|
|
}
|
2014-09-30 11:08:48 +00:00
|
|
|
Config_barTransparency := "off"
|
2015-03-07 13:10:00 +00:00
|
|
|
Config_barCommands := "Run, explore " Main_docDir ";Monitor_toggleBar();Reload;ExitApp"
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_readinBat := False
|
|
|
|
Config_readinCpu := False
|
|
|
|
Config_readinDate := True
|
|
|
|
Config_readinDiskLoad := False
|
|
|
|
Config_readinMemoryUsage := False
|
|
|
|
Config_readinNetworkLoad := False
|
|
|
|
Config_readinTime := True
|
2014-10-01 21:20:32 +00:00
|
|
|
Config_readinVolume := False
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_readinInterval := 30000
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Windows ui elements
|
|
|
|
Config_bbCompatibility := False
|
|
|
|
Config_borderWidth := 0
|
|
|
|
Config_borderPadding := -1
|
|
|
|
Config_showTaskBar := False
|
|
|
|
Config_showBorder := True
|
|
|
|
Config_selBorderColor := ""
|
2014-12-13 15:12:38 +00:00
|
|
|
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`.
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; 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
|
2014-03-03 10:56:37 +00:00
|
|
|
Config_areaTraceTimeout := 1000
|
|
|
|
Config_continuouslyTraceAreas := False
|
|
|
|
Config_dynamicTiling := True
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_ghostWndSubString := " (Not Responding)"
|
2014-04-29 13:43:17 +00:00
|
|
|
Config_mFactCallInterval := 700
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_mouseFollowsFocus := True
|
|
|
|
Config_newWndPosition := "top"
|
|
|
|
Config_onActiveHiddenWnds := "view"
|
|
|
|
Config_shellMsgDelay := 350
|
|
|
|
Config_syncMonitorViews := 0
|
|
|
|
Config_viewFollowsTagged := False
|
2014-04-29 13:43:17 +00:00
|
|
|
Config_viewMargins := "0;0;0;0"
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-02-14 12:32:08 +00:00
|
|
|
;; Config_rule_#<i> := "<class>;<title>;<function name>;<is managed>;<m>;<tags>;<is floating>;<is decorated>;<hide title>;<action>"
|
2015-02-01 20:13:48 +00:00
|
|
|
Config_rule_#1 := ".*;.*;;1;0;0;0;0;0;"
|
2015-02-27 20:57:32 +00:00
|
|
|
Config_rule_#2 := ".*;.*;Window_isChild;0;0;0;1;1;1;"
|
|
|
|
Config_rule_#3 := ".*;.*;Window_isPopup;0;0;0;1;1;1;"
|
|
|
|
Config_rule_#4 := "QWidget;.*;;1;0;0;0;0;0;"
|
|
|
|
Config_rule_#5 := "SWT_Window0;.*;;1;0;0;0;0;0;"
|
|
|
|
Config_rule_#6 := "Xming;.*;;1;0;0;0;0;0;"
|
|
|
|
Config_rule_#7 := "MsiDialog(No)?CloseClass;.*;;1;0;0;1;1;0;"
|
|
|
|
Config_rule_#8 := "AdobeFlashPlayerInstaller;.*;;1;0;0;1;0;0;"
|
|
|
|
Config_rule_#9 := "CalcFrame;.*;;1;0;0;1;1;0;"
|
|
|
|
Config_rule_#10 := "CabinetWClass;.*;;1;0;0;0;1;0;"
|
|
|
|
Config_rule_#11 := "OperationStatusWindow;.*;;0;0;0;1;1;0;"
|
|
|
|
Config_rule_#12 := "Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;"
|
|
|
|
Config_rule_#13 := "Chrome_WidgetWin_1;.*;Window_isPopup;0;0;0;1;1;0;"
|
|
|
|
Config_rule_#14 := "Chrome_RenderWidgetHostHWND;.*;;0;0;0;1;1;0;"
|
|
|
|
Config_rule_#15 := "IEFrame;.*Internet Explorer;;1;0;0;0;1;0;"
|
|
|
|
Config_rule_#16 := "MozillaWindowClass;.*Mozilla Firefox;;1;0;0;0;1;0;"
|
|
|
|
Config_rule_#17 := "MozillaDialogClass;.*;;1;0;0;1;1;0;"
|
|
|
|
Config_ruleCount := 17 ;; This variable has to be set to the total number of active rules above.
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Configuration management
|
2012-12-05 23:55:38 +00:00
|
|
|
Config_autoSaveSession := "auto" ;; "off" | "auto" | "ask"
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_maintenanceInterval := 5000
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_restoreConfig(Config_filePath)
|
|
|
|
Config_getSystemSettings()
|
|
|
|
Config_initColors()
|
2015-01-30 22:38:40 +00:00
|
|
|
Loop, % Config_layoutCount {
|
2012-11-26 23:52:18 +00:00
|
|
|
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%
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:13:10 +00:00
|
|
|
Config_initColors() {
|
2012-11-26 23:52:18 +00:00
|
|
|
Global
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-30 19:13:10 +00:00
|
|
|
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%, `;
|
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Config_convertSystemColor(systemColor)
|
2012-11-26 23:52:18 +00:00
|
|
|
{ ;; systemColor format: 0xBBGGRR
|
|
|
|
rr := SubStr(systemColor, 7, 2)
|
|
|
|
gg := SubStr(systemColor, 5, 2)
|
|
|
|
bb := SubStr(systemColor, 3, 2)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
Return, rr gg bb
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:13:10 +00:00
|
|
|
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
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-30 19:13:10 +00:00
|
|
|
If Not Config_fontName {
|
2012-11-26 23:52:18 +00:00
|
|
|
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)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
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/)
|
|
|
|
}
|
2015-01-30 19:13:10 +00:00
|
|
|
If Not Config_fontSize {
|
2012-11-26 23:52:18 +00:00
|
|
|
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)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
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))
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
lfHeightSize := VarSetCapacity(lfHeight, 4, 0)
|
|
|
|
NumPut(lfHeightSize, lfHeight, 0, "Int")
|
|
|
|
lfHeight := NumGet(lf, 0, "Int")
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
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
|
2015-01-30 19:13:10 +00:00
|
|
|
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))
|
2015-01-30 22:38:40 +00:00
|
|
|
;; <view>;<layout>;<title>;<shebang>;<time>;<date>;<anyText>;<batteryStatus>;<volumeLevel>
|
2015-01-30 19:13:10 +00:00
|
|
|
If Not Config_backColor_#1 {
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_backColor_#1 := COLOR_GRADIENTINACTIVECAPTION ";" COLOR_ACTIVECAPTION ";" COLOR_MENU ";" COLOR_ACTIVECAPTION ";" COLOR_MENU ";" COLOR_ACTIVECAPTION ";"
|
|
|
|
Config_backColor_#1 .= COLOR_GRADIENTINACTIVECAPTION ";" COLOR_GRADIENTACTIVECAPTION ";" COLOR_GRADIENTACTIVECAPTION
|
2015-01-30 19:13:10 +00:00
|
|
|
}
|
|
|
|
If Not Config_backColor_#2
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_backColor_#2 := COLOR_GRADIENTACTIVECAPTION ";;;;;;;" COLOR_MENU ";" COLOR_MENU
|
2015-01-30 19:13:10 +00:00
|
|
|
If Not Config_backColor_#3
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_backColor_#3 := ";;;;;;;ff8040;"
|
2015-01-30 19:13:10 +00:00
|
|
|
|
|
|
|
If Not Config_foreColor_#1 {
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_foreColor_#1 := COLOR_INACTIVECAPTION ";" COLOR_ACTIVECAPTION ";" COLOR_MENU ";" COLOR_ACTIVECAPTION ";" COLOR_MENU ";" COLOR_ACTIVECAPTION ";"
|
|
|
|
Config_foreColor_#1 .= COLOR_INACTIVECAPTION ";" COLOR_ACTIVECAPTION ";" COLOR_GRADIENTINACTIVECAPTION
|
2015-01-30 19:13:10 +00:00
|
|
|
}
|
|
|
|
If Not Config_foreColor_#2
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_foreColor_#2 := COLOR_ACTIVECAPTION ";;;;;;;" COLOR_HIGHLIGHT ";" COLOR_HIGHLIGHT
|
2015-01-30 19:13:10 +00:00
|
|
|
If Not Config_foreColor_#3
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_foreColor_#3 := ";;;;;;;" COLOR_INACTIVECAPTION ";"
|
2015-01-30 19:13:10 +00:00
|
|
|
|
2015-01-30 22:38:40 +00:00
|
|
|
If Not Config_fontColor_#1 {
|
|
|
|
Config_fontColor_#1 := COLOR_INACTIVECAPTIONTEXT ";" COLOR_CAPTIONTEXT ";" COLOR_MENUTEXT ";" COLOR_CAPTIONTEXT ";" COLOR_MENUTEXT ";" COLOR_CAPTIONTEXT ";"
|
|
|
|
Config_fontColor_#1 .= COLOR_INACTIVECAPTIONTEXT ";" COLOR_CAPTIONTEXT ";" COLOR_INACTIVECAPTIONTEXT
|
|
|
|
}
|
2015-01-30 19:13:10 +00:00
|
|
|
If Not Config_fontColor_#2
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_fontColor_#2 := COLOR_CAPTIONTEXT ";;;;;;;" COLOR_MENUTEXT ";" COLOR_MENUTEXT
|
2015-01-30 19:13:10 +00:00
|
|
|
If Not Config_fontColor_#3
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_fontColor_#3 := ";;;;;;;" COLOR_INACTIVECAPTIONTEXT ";"
|
2012-11-26 23:52:18 +00:00
|
|
|
}
|
|
|
|
SetFormat, Integer, d
|
2014-12-13 15:12:38 +00:00
|
|
|
|
|
|
|
RegRead, appliedDPI, HKEY_CURRENT_USER, Control Panel\Desktop\WindowMetrics, AppliedDPI
|
|
|
|
If (ErrorLevel = 0)
|
|
|
|
Config_scalingFactor := 96 / appliedDPI
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Config_hotkeyLabel:
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_redirectHotkey(A_ThisHotkey)
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
2015-01-30 22:38:40 +00:00
|
|
|
Config_readinAny() {
|
|
|
|
;; Add information to the variable 'text' in this function to display it in the status bar.
|
|
|
|
Global Config_readinCpu, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
text := ""
|
2015-01-30 22:38:40 +00:00
|
|
|
If (Config_readinCpu Or Config_readinDiskLoad Or Config_readinMemoryUsage Or Config_readinNetworkLoad)
|
|
|
|
text .= ResourceMonitor_getText()
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
Return, text
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Config_redirectHotkey(key)
|
2012-11-26 23:52:18 +00:00
|
|
|
{
|
|
|
|
Global
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
Loop, % Config_hotkeyCount
|
|
|
|
{
|
2012-12-05 12:39:51 +00:00
|
|
|
If (key = Config_hotkey_#%A_index%_key)
|
2012-11-26 23:52:18 +00:00
|
|
|
{
|
2015-03-21 10:34:15 +00:00
|
|
|
Debug_logMessage("DEBUG[1] Config_redirectHotkey: Found " Config_hotkey_#%A_index%_key " -> " Config_hotkey_#%A_index%_command, 1)
|
2012-11-26 23:52:18 +00:00
|
|
|
Main_evalCommand(Config_hotkey_#%A_index%_command)
|
|
|
|
Break
|
|
|
|
}
|
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Config_restoreConfig(filename)
|
2012-09-29 20:07:18 +00:00
|
|
|
{
|
2012-11-26 23:52:18 +00:00
|
|
|
Local cmd, i, key, type, val, var
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
If Not FileExist(filename)
|
|
|
|
Return
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
Loop, READ, %filename%
|
2012-12-05 12:39:51 +00:00
|
|
|
If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
2012-11-26 23:52:18 +00:00
|
|
|
;Log_msg("Processing line: " . A_LoopReadLine)
|
|
|
|
i := InStr(A_LoopReadLine, "=")
|
|
|
|
var := SubStr(A_LoopReadLine, 1, i - 1)
|
|
|
|
val := SubStr(A_LoopReadLine, i + 1)
|
|
|
|
type := SubStr(var, 1, 13)
|
2012-12-05 12:39:51 +00:00
|
|
|
If (type = "Config_hotkey")
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
Debug_logMessage("Processing configured hotkey: " . A_LoopReadLine, 0)
|
2012-11-26 23:52:18 +00:00
|
|
|
i := InStr(val, "::")
|
|
|
|
key := SubStr(val, 1, i - 1)
|
|
|
|
cmd := SubStr(val, i + 2)
|
|
|
|
If Not cmd
|
|
|
|
Hotkey, %key%, Off
|
2012-12-05 12:39:51 +00:00
|
|
|
Else
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
Debug_logMessage(" Hotkey: " . key . " -> " . cmd, 0)
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_hotkeyCount += 1
|
|
|
|
Config_hotkey_#%Config_hotkeyCount%_key := key
|
|
|
|
Config_hotkey_#%Config_hotkeyCount%_command := cmd
|
|
|
|
Hotkey, %key%, Config_hotkeyLabel
|
|
|
|
}
|
2012-12-04 03:18:19 +00:00
|
|
|
}
|
2012-12-05 12:39:51 +00:00
|
|
|
Else If (type = "Config_rule")
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
2012-11-26 23:52:18 +00:00
|
|
|
i := 0
|
|
|
|
If InStr(var, "Config_rule_#")
|
|
|
|
i := SubStr(var, 14)
|
2012-12-05 12:39:51 +00:00
|
|
|
If (i = 0 Or i > Config_ruleCount)
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_ruleCount += 1
|
|
|
|
i := Config_ruleCount
|
|
|
|
}
|
|
|
|
var := "Config_rule_#" i
|
|
|
|
}
|
|
|
|
%var% := val
|
|
|
|
}
|
2011-09-02 17:46:07 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
Config_restoreLayout(filename, m) {
|
|
|
|
Local i, var, val
|
|
|
|
|
|
|
|
If Not FileExist(filename)
|
|
|
|
Return
|
|
|
|
|
|
|
|
Loop, READ, %filename%
|
|
|
|
If (SubStr(A_LoopReadLine, 1, 10 + StrLen(m)) = "Monitor_#" m "_" Or SubStr(A_LoopReadLine, 1, 8 + StrLen(m)) = "View_#" m "_#") {
|
|
|
|
i := InStr(A_LoopReadLine, "=")
|
|
|
|
var := SubStr(A_LoopReadLine, 1, i - 1)
|
|
|
|
val := SubStr(A_LoopReadLine, i + 1)
|
|
|
|
%var% := val
|
|
|
|
}
|
2012-11-25 13:56:35 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Config_saveSession(original, target)
|
2012-11-26 23:52:18 +00:00
|
|
|
{
|
|
|
|
Local m, text, tmpfilename
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
tmpfilename := target . ".tmp"
|
|
|
|
FileDelete, %tmpfilename%
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
text := "; bug.n - tiling window management`n; @version " VERSION "`n`n"
|
2012-12-05 12:39:51 +00:00
|
|
|
If FileExist(original)
|
2012-11-26 23:52:18 +00:00
|
|
|
{
|
|
|
|
Loop, READ, %original%
|
|
|
|
{
|
|
|
|
If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
|
|
|
|
text .= A_LoopReadLine "`n"
|
|
|
|
}
|
|
|
|
text .= "`n"
|
|
|
|
}
|
2012-12-05 12:39:51 +00:00
|
|
|
|
|
|
|
Loop, % Manager_monitorCount
|
2012-11-26 23:52:18 +00:00
|
|
|
{
|
|
|
|
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"
|
2012-12-05 12:39:51 +00:00
|
|
|
Loop, % Config_viewCount
|
2012-11-26 23:52:18 +00:00
|
|
|
{
|
|
|
|
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%_layoutGapWidth = Config_layoutGapWidth)
|
|
|
|
text .= "View_#" m "_#" A_Index "_layoutGapWidth=" View_#%m%_#%A_Index%_layoutGapWidth "`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%_layoutMX = 1)
|
|
|
|
text .= "View_#" m "_#" A_Index "_layoutMX=" View_#%m%_#%A_Index%_layoutMX "`n"
|
|
|
|
If Not (View_#%m%_#%A_Index%_layoutMY = 1)
|
|
|
|
text .= "View_#" m "_#" A_Index "_layoutMY=" View_#%m%_#%A_Index%_layoutMY "`n"
|
|
|
|
}
|
|
|
|
}
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; The FileMove below is an all-or-nothing replacement of the file.
|
|
|
|
;; We don't want to leave this half-finished.
|
|
|
|
FileAppend, %text%, %tmpfilename%
|
2012-12-05 12:39:51 +00:00
|
|
|
If ErrorLevel
|
2012-12-04 03:18:19 +00:00
|
|
|
{
|
2012-11-26 23:52:18 +00:00
|
|
|
If FileExist(tmpfilename)
|
|
|
|
FileDelete, %tmpfilename%
|
|
|
|
}
|
|
|
|
Else
|
|
|
|
FileMove, %tmpfilename%, %target%, 1
|
2011-09-02 17:46:07 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
Config_UI_saveSession() {
|
2015-02-01 20:13:48 +00:00
|
|
|
Global Config_filePath
|
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
Config_saveSession(Config_filePath, Config_filePath)
|
|
|
|
}
|
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Key definitions
|
|
|
|
;; Window management
|
2015-01-28 18:42:07 +00:00
|
|
|
#Down::View_activateWindow(0, +1)
|
|
|
|
#Up::View_activateWindow(0, -1)
|
2015-01-27 23:02:37 +00:00
|
|
|
#+Down::View_shuffleWindow(0, +1)
|
|
|
|
#+Up::View_shuffleWindow(0, -1)
|
|
|
|
#+Enter::View_shuffleWindow(1)
|
2012-11-26 23:52:18 +00:00
|
|
|
#c::Manager_closeWindow()
|
2015-01-25 18:16:30 +00:00
|
|
|
#+d::Window_toggleDecor()
|
2015-01-25 19:28:40 +00:00
|
|
|
#+f::View_toggleFloatingWindow()
|
2012-11-26 23:52:18 +00:00
|
|
|
#+m::Manager_moveWindow()
|
2015-03-07 21:49:17 +00:00
|
|
|
#^m::Manager_minimizeWindow()
|
2012-11-26 23:52:18 +00:00
|
|
|
#+s::Manager_sizeWindow()
|
|
|
|
#+x::Manager_maximizeWindow()
|
|
|
|
#i::Manager_getWindowInfo()
|
|
|
|
#+i::Manager_getWindowList()
|
2014-03-03 10:56:37 +00:00
|
|
|
!Down::View_moveWindow(0, +1)
|
|
|
|
!Up::View_moveWindow(0, -1)
|
|
|
|
!+Enter::Manager_maximizeWindow()
|
|
|
|
!1::View_moveWindow(1)
|
|
|
|
!2::View_moveWindow(2)
|
|
|
|
!3::View_moveWindow(3)
|
|
|
|
!4::View_moveWindow(4)
|
|
|
|
!5::View_moveWindow(5)
|
|
|
|
!6::View_moveWindow(6)
|
|
|
|
!7::View_moveWindow(7)
|
|
|
|
!8::View_moveWindow(8)
|
|
|
|
!9::View_moveWindow(9)
|
|
|
|
!0::View_moveWindow(10)
|
|
|
|
!BackSpace::View_toggleStackArea()
|
2011-07-27 17:43:34 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Window debugging
|
2012-11-27 03:13:38 +00:00
|
|
|
#^i::Debug_logViewWindowList()
|
2015-07-15 20:46:00 +00:00
|
|
|
#^+i::Debug_logManagedWindowList()
|
2012-11-27 03:13:38 +00:00
|
|
|
#^h::Debug_logHelp()
|
2015-01-27 21:33:13 +00:00
|
|
|
#^d::Debug_setLogLevel(0, -1)
|
|
|
|
#^+d::Debug_setLogLevel(0, +1)
|
2011-07-27 17:43:34 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Layout management
|
|
|
|
#Tab::View_setLayout(-1)
|
|
|
|
#f::View_setLayout(3)
|
|
|
|
#m::View_setLayout(2)
|
|
|
|
#t::View_setLayout(1)
|
2015-01-26 21:51:19 +00:00
|
|
|
#Left::View_setLayoutProperty("MFactor", 0, -0.05)
|
|
|
|
#Right::View_setLayoutProperty("MFactor", 0, +0.05)
|
|
|
|
#^t::View_setLayoutProperty("Axis", 0, +1, 1)
|
|
|
|
#^Enter::View_setLayoutProperty("Axis", 0, +2, 1)
|
|
|
|
#^Tab::View_setLayoutProperty("Axis", 0, +1, 2)
|
|
|
|
#^+Tab::View_setLayoutProperty("Axis", 0, +1, 3)
|
|
|
|
#^Up::View_setLayoutProperty("MY", 0, +1)
|
|
|
|
#^Down::View_setLayoutProperty("MY", 0, -1)
|
|
|
|
#^Right::View_setLayoutProperty("MX", 0, +1)
|
|
|
|
#^Left::View_setLayoutProperty("MX", 0, -1)
|
2015-01-27 20:30:10 +00:00
|
|
|
#+Left::View_setLayoutProperty("GapWidth", 0, -2)
|
|
|
|
#+Right::View_setLayoutProperty("GapWidth", 0, +2)
|
2011-07-27 17:43:34 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; View/Tag management
|
2012-12-04 03:18:19 +00:00
|
|
|
#+n::View_toggleMargins()
|
2012-11-26 23:52:18 +00:00
|
|
|
#BackSpace::Monitor_activateView(-1)
|
2015-01-28 17:11:47 +00:00
|
|
|
#+0::Monitor_setWindowTag(10)
|
2012-11-26 23:52:18 +00:00
|
|
|
#1::Monitor_activateView(1)
|
|
|
|
#+1::Monitor_setWindowTag(1)
|
|
|
|
#^1::Monitor_toggleWindowTag(1)
|
2011-07-27 17:43:34 +00:00
|
|
|
#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)
|
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Monitor management
|
2015-01-28 19:12:57 +00:00
|
|
|
#.::Manager_activateMonitor(0, +1)
|
|
|
|
#,::Manager_activateMonitor(0, -1)
|
2015-01-28 19:26:43 +00:00
|
|
|
#+.::Manager_setWindowMonitor(0, +1)
|
|
|
|
#+,::Manager_setWindowMonitor(0, -1)
|
2015-01-28 19:49:03 +00:00
|
|
|
#^+.::Manager_setViewMonitor(0, +1)
|
|
|
|
#^+,::Manager_setViewMonitor(0, -1)
|
2012-11-26 23:52:18 +00:00
|
|
|
|
|
|
|
;; GUI management
|
|
|
|
#+Space::Monitor_toggleBar()
|
|
|
|
#Space::Monitor_toggleTaskBar()
|
|
|
|
#y::Bar_toggleCommandGui()
|
2013-03-25 21:30:12 +00:00
|
|
|
#+y::Monitor_toggleNotifyIconOverflowWindow()
|
2014-03-03 10:56:37 +00:00
|
|
|
!+y::View_traceAreas()
|
2011-07-27 17:43:34 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Administration
|
|
|
|
#^e::Run, edit %Config_filePath%
|
|
|
|
#^s::Config_UI_saveSession()
|
2015-03-07 13:10:00 +00:00
|
|
|
#^r::Reload
|
2012-11-26 23:52:18 +00:00
|
|
|
#^q::ExitApp
|