2012-11-26 23:52:18 +00:00
|
|
|
/*
|
2016-03-09 18:34:57 +00:00
|
|
|
bug.n -- tiling window management
|
|
|
|
Copyright (c) 2010-2015 Joshua Fuhs, joten
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2016-03-09 18:34:57 +00:00
|
|
|
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 <http://www.gnu.org/licenses/>
|
|
|
|
|
|
|
|
@version 9.0.0
|
2012-11-26 23:52:18 +00:00
|
|
|
*/
|
|
|
|
|
2016-03-09 18:34:57 +00:00
|
|
|
NAME := "bug.n"
|
|
|
|
VERSION := "9.0.0"
|
2011-07-27 17:43:34 +00:00
|
|
|
|
2016-03-09 18:34:57 +00:00
|
|
|
;; Script settings
|
2011-07-27 17:43:34 +00:00
|
|
|
OnExit, Main_cleanup
|
|
|
|
SetBatchLines, -1
|
|
|
|
SetTitleMatchMode, 3
|
|
|
|
SetTitleMatchMode, fast
|
|
|
|
SetWinDelay, 10
|
2016-03-09 18:34:57 +00:00
|
|
|
#NoEnv
|
2011-07-27 17:43:34 +00:00
|
|
|
#SingleInstance force
|
2016-06-11 20:59:46 +00:00
|
|
|
;#Warn ; Enable warnings to assist with detecting common errors.
|
2011-07-27 17:43:34 +00:00
|
|
|
#WinActivateForce
|
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
;; Pseudo main function
|
2016-02-12 17:58:58 +00:00
|
|
|
Main_appDir := ""
|
2012-11-26 23:52:18 +00:00
|
|
|
If 0 = 1
|
2012-12-05 12:50:30 +00:00
|
|
|
Main_appDir = %1%
|
2012-11-26 23:52:18 +00:00
|
|
|
|
|
|
|
Main_setup()
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-25 19:50:01 +00:00
|
|
|
Debug_initLog(Main_logFile, 0, False)
|
2012-11-27 03:13:38 +00:00
|
|
|
|
2013-05-19 20:07:09 +00:00
|
|
|
Debug_logMessage("====== Initializing ======", 0)
|
2012-11-27 03:13:38 +00:00
|
|
|
Config_filePath := Main_appDir "\Config.ini"
|
2012-11-26 23:52:18 +00:00
|
|
|
Config_init()
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2016-03-09 18:34:57 +00:00
|
|
|
Menu, Tray, Tip, %NAME% %VERSION%
|
2016-04-13 17:28:24 +00:00
|
|
|
If A_IsCompiled
|
|
|
|
Menu, Tray, Icon, %A_ScriptFullPath%, -159
|
2016-04-14 14:25:50 +00:00
|
|
|
If FileExist(A_ScriptDir . "\logo.ico")
|
2016-04-13 17:28:24 +00:00
|
|
|
Menu, Tray, Icon, % A_ScriptDir . "\logo.ico"
|
2012-11-26 23:52:18 +00:00
|
|
|
Menu, Tray, NoStandard
|
|
|
|
Menu, Tray, Add, Toggle bar, Main_toggleBar
|
|
|
|
Menu, Tray, Add, Help, Main_help
|
2012-12-05 12:39:51 +00:00
|
|
|
Menu, Tray, Add,
|
2012-11-26 23:52:18 +00:00
|
|
|
Menu, Tray, Add, Exit, Main_quit
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-26 23:52:18 +00:00
|
|
|
ResourceMonitor_init()
|
|
|
|
Manager_init()
|
2012-11-27 03:13:38 +00:00
|
|
|
Debug_logMessage("====== Running ======", 0)
|
2012-11-26 23:52:18 +00:00
|
|
|
Return ;; end of the auto-execute section
|
|
|
|
|
|
|
|
;; Function & label definitions
|
|
|
|
Main_cleanup:
|
2012-11-27 03:13:38 +00:00
|
|
|
Debug_logMessage("====== Cleaning up ======", 0)
|
2012-12-05 23:55:38 +00:00
|
|
|
;; Config_autoSaveSession as False is deprecated.
|
|
|
|
If Not (Config_autoSaveSession = "off") And Not (Config_autoSaveSession = "False")
|
|
|
|
Manager_saveState()
|
2012-11-26 23:52:18 +00:00
|
|
|
Manager_cleanup()
|
|
|
|
ResourceMonitor_cleanup()
|
2012-11-27 03:13:38 +00:00
|
|
|
Debug_logMessage("====== Exiting bug.n ======", 0)
|
2011-07-27 17:43:34 +00:00
|
|
|
ExitApp
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2016-03-09 18:23:53 +00:00
|
|
|
Main_evalCommand(command)
|
|
|
|
{
|
|
|
|
type := SubStr(command, 1, 5)
|
|
|
|
If (type = "Run, ")
|
|
|
|
{
|
|
|
|
parameters := SubStr(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(command, 6)
|
|
|
|
Else If (command = "Reload")
|
|
|
|
Reload
|
|
|
|
Else If (command = "ExitApp")
|
|
|
|
ExitApp
|
|
|
|
Else
|
|
|
|
{
|
|
|
|
i := InStr(command, "(")
|
|
|
|
j := InStr(command, ")", False, i)
|
|
|
|
If i And j
|
|
|
|
{
|
|
|
|
functionName := SubStr(command, 1, i - 1)
|
|
|
|
functionArguments := SubStr(command, i + 1, j - (i + 1))
|
|
|
|
StringReplace, functionArguments, functionArguments, %A_SPACE%, , All
|
|
|
|
StringSplit, functionArgument, functionArguments, `,
|
|
|
|
Debug_logMessage("DEBUG[1] Main_evalCommand: " functionName "(" functionArguments ")", 1)
|
|
|
|
If (functionArgument0 = 0)
|
|
|
|
%functionName%()
|
|
|
|
Else If (functionArgument0 = 1)
|
|
|
|
%functionName%(functionArguments)
|
|
|
|
Else If (functionArgument0 = 2)
|
|
|
|
%functionName%(functionArgument1, functionArgument2)
|
|
|
|
Else If (functionArgument0 = 3)
|
|
|
|
%functionName%(functionArgument1, functionArgument2, functionArgument3)
|
|
|
|
Else If (functionArgument0 = 4)
|
|
|
|
%functionName%(functionArgument1, functionArgument2, functionArgument3, functionArgument4)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-27 17:43:34 +00:00
|
|
|
Main_help:
|
2014-03-09 17:31:37 +00:00
|
|
|
Run, explore %Main_docDir%
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
2016-03-09 18:23:53 +00:00
|
|
|
;; Create bug.n-specific directories.
|
|
|
|
Main_makeDir(dirName) {
|
|
|
|
IfNotExist, %dirName%
|
|
|
|
{
|
|
|
|
FileCreateDir, %dirName%
|
|
|
|
If ErrorLevel
|
|
|
|
{
|
|
|
|
MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
|
|
|
|
ExitApp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Else
|
|
|
|
{
|
|
|
|
FileGetAttrib, attrib, %dirName%
|
|
|
|
IfNotInString, attrib, D
|
|
|
|
{
|
|
|
|
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
|
2012-11-26 23:52:18 +00:00
|
|
|
ExitApp
|
|
|
|
}
|
|
|
|
}
|
2012-11-25 13:56:35 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
Main_quit:
|
|
|
|
ExitApp
|
|
|
|
Return
|
2012-11-25 13:56:35 +00:00
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
Main_setup() {
|
|
|
|
Local winAppDir
|
|
|
|
|
|
|
|
Main_docDir := A_ScriptDir
|
|
|
|
If (SubStr(A_ScriptDir, -3) = "\src")
|
|
|
|
Main_docDir .= "\.."
|
|
|
|
Main_docDir .= "\doc"
|
|
|
|
|
2016-03-09 18:23:53 +00:00
|
|
|
Main_logFile := ""
|
|
|
|
Main_dataDir := ""
|
|
|
|
Main_autoLayout := ""
|
|
|
|
Main_autoWindowState := ""
|
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
EnvGet, winAppDir, APPDATA
|
2016-03-09 18:23:53 +00:00
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
If (Main_appDir = "")
|
|
|
|
Main_appDir := winAppDir . "\bug.n"
|
|
|
|
Main_logFile := Main_appDir . "\log.txt"
|
|
|
|
Main_dataDir := Main_appDir . "\data"
|
|
|
|
Main_autoLayout := Main_dataDir . "\_Layout.ini"
|
|
|
|
Main_autoWindowState := Main_dataDir . "\_WindowState.ini"
|
|
|
|
|
|
|
|
Main_makeDir(Main_appDir)
|
|
|
|
Main_makeDir(Main_dataDir)
|
|
|
|
}
|
|
|
|
|
2011-07-27 17:43:34 +00:00
|
|
|
Main_toggleBar:
|
2012-11-26 23:52:18 +00:00
|
|
|
Monitor_toggleBar()
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
|
|
|
#Include Bar.ahk
|
|
|
|
#Include Config.ahk
|
2012-09-28 15:46:17 +00:00
|
|
|
#Include Debug.ahk
|
2011-07-27 17:43:34 +00:00
|
|
|
#Include Manager.ahk
|
|
|
|
#Include Monitor.ahk
|
2012-11-26 23:52:18 +00:00
|
|
|
#Include ResourceMonitor.ahk
|
2015-01-26 20:12:14 +00:00
|
|
|
#Include Tiler.ahk
|
2011-07-27 17:43:34 +00:00
|
|
|
#Include View.ahk
|
2015-01-25 17:07:51 +00:00
|
|
|
#Include Window.ahk
|