More prep for merge

This commit is contained in:
Joshua Fuhs 2012-12-03 22:18:19 -05:00
parent fe1f4793f4
commit 7efc059c7c
6 changed files with 7 additions and 284 deletions

View file

@ -365,7 +365,8 @@ Config_saveSession(original, target)
;; The FileMove below is an all-or-nothing replacement of the file. ;; The FileMove below is an all-or-nothing replacement of the file.
;; We don't want to leave this half-finished. ;; We don't want to leave this half-finished.
FileAppend, %text%, %tmpfilename% FileAppend, %text%, %tmpfilename%
If ErrorLevel { If ErrorLevel
{
If FileExist(tmpfilename) If FileExist(tmpfilename)
FileDelete, %tmpfilename% FileDelete, %tmpfilename%
} }
@ -415,7 +416,7 @@ Config_saveSession(original, target)
#+Right::View_setGapWidth(+2) #+Right::View_setGapWidth(+2)
;; View/Tag management ;; View/Tag management
;#+n::View_toggleMargins() #+n::View_toggleMargins()
#BackSpace::Monitor_activateView(-1) #BackSpace::Monitor_activateView(-1)
#+0::Monitor_setWindowTag(0) #+0::Monitor_setWindowTag(0)
#1::Monitor_activateView(1) #1::Monitor_activateView(1)
@ -463,5 +464,5 @@ Config_saveSession(original, target)
#^e::Run, edit %Config_filePath% #^e::Run, edit %Config_filePath%
#^s::Config_UI_saveSession() #^s::Config_UI_saveSession()
#^r::Main_reload() #^r::Main_reload()
;#^+r::Reload #^+r::Reload
#^q::ExitApp #^q::ExitApp

View file

@ -1,111 +0,0 @@
/**
* AHK List implementation
* Copyright (c) 2012 Joshua Fuhs
*
* 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/>.
*
*/
/**
* This is an admittedly poor list implementation, but I was new to AHK,
* and I had seen several examples of this already used.
* The lists being operated on should not be larger than a few hundred,
* and preferably no larger than one hundred.
*/
List_new() {
Global
Return ""
}
List_prepend( ByRef l, e ) {
l := e . "`;" . l
Return
}
List_append(ByRef l, e) {
l := l . e . "`;"
Return
}
; Insert at position immediately preceding index p
List_insert(ByRef l, e, p) {
Local arr, search, replace
If ( p = 0)
return List_prepend(l, e)
StringSplit arr, l, `;
if ( p >= arr0 - 1 )
return List_append(l, e)
p += 1
search := arr%p% . ";"
replace := e . ";" . search
StringReplace, l, l, %search%, %replace%
}
List_remove(ByRef l, e) {
Local search
search := "" . e . ";"
StringReplace, l, l, %search%,
return
}
List_removeAt(ByRef l, p) {
Local arr, search
StringSplit arr, l, `;
if( p >= arr0 - 1)
Return
p += 1
search := arr%p% . ";"
StringReplace, l, l, %search%,
}
List_find(ByRef l, e) {
Local arr, arr0
StringSplit arr, l, `;
Loop, % (arr0 - 1) {
If arr%A_Index% = %e%
Return (A_Index - 1)
}
Return -1
}
List_dump(l) {
Local result
StringReplace, result, l, `;, %A_Space%, All
Return result
}
List_get(l, p) {
Local arr
StringSplit arr, l, `;
If( p >= arr0 )
Return ""
p += 1
Return arr%p%
}
List_size(l) {
Local arr, arr0
StringSplit arr, l, `;
Return (arr0 - 1)
}
List_toArray(l, arrName) {
Local trimmedList
StringTrimRight, trimmedList, l, 1
StringSplit %arrName%, trimmedList, `;
Return (%arrName%0)
}

View file

@ -1,84 +0,0 @@
Test_check(Condition, msg) {
Global
If Condition
Return
Log_bare(msg)
Exit, 1
}
Log_init("List.test.txt", True)
testlist := List_new()
Log_bare("new list: " . List_dump(testlist))
Test_check(List_dump(testlist) = "", "Test 1 failure")
If Not (List_dump(testlist) = "" )
Log_bare("Test 1 failure")
List_append(testlist, "abc")
Log_bare("appended 'abc': " . List_dump(testlist))
If Not (List_dump(testlist) = "abc " )
Log_bare("Test 2 failure")
List_append(testlist, "def")
Log_bare("appended 'def': " . List_dump(testlist))
If Not (List_dump(testlist) = "abc def " )
Log_bare("Test 3 failure")
List_append(testlist, "ghi")
List_remove(testlist, "abc")
Log_bare("removed 'abc': " . List_dump(testlist))
If Not (List_dump(testlist) = "def ghi " )
Log_bare("Test 4 failure")
List_append(testlist, "jkl")
List_remove(testlist, "ghi")
Log_bare("add 'jkl', remove 'ghi': " . List_dump(testlist))
If Not (List_dump(testlist) = "def jkl " )
Log_bare("Test 5 failure")
List_append(testlist, "mno")
List_remove(testlist, "mno")
Log_bare("add and remove 'mno': " . List_dump(testlist))
If Not (List_dump(testlist) = "def jkl " )
Log_bare("Test 6 failure")
List_prepend(testlist, "12345")
Log_bare("prepend '12345': " . List_dump(testlist))
If Not (List_dump(testlist) = "12345 def jkl ")
Log_bare("Test 7 failure")
List_insert(testlist, "xyz", 0)
List_insert(testlist, "Happy", 1)
List_insert(testlist, "Blah", 5)
List_insert(testlist, "10", 10)
Log_bare("Attempt multiple inserts by index: " . List_dump(testlist))
If Not (List_dump(testlist) = "xyz Happy 12345 def jkl Blah 10 ")
Log_bare("Test 8 failure")
List_removeAt(testlist, 0)
List_removeAt(testlist, 1)
List_removeAt(testlist, 2)
List_removeAt(testlist, 3)
List_removeAt(testlist, 10)
Log_bare("Attempt multiple removals by index: " . List_dump(testlist))
If Not (List_dump(testlist) = "Happy def Blah ")
Log_bare("Test 9 failure")
If Not (List_find(testlist, "Happy") = 0)
Log_bare("Test 10 failure")
If Not (List_find(testlist, "def") = 1)
Log_bare("Test 11 failure")
If Not (List_find(testlist, "Blah") = 2)
Log_bare("Test 12 failure")
If Not (List_find(testlist, "nonexistent") = -1)
Log_bare("Test 13 failure")
If Not (List_size(testlist) = 3)
Log_bare("Test 14 failure")
If Not (List_get(testlist, 0) = "Happy")
Log_bare("Test 15 failure")
If Not (List_get(testlist, 1) = "def")
Log_bare("Test 16 failure")
If Not (List_get(testlist, 2) = "Blah")
Log_bare("Test 17 failure")
If Not (List_get(testlist, 3) = "")
Log_bare("Test 18 failure")
Return
#Include Log.ahk
#Include List.ahk

View file

@ -1,82 +0,0 @@
/**
* AHK Debug log implementation
* Copyright (c) 2012 Joshua Fuhs
*
* 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.3.0
*/
Log_debug_level := 0
Log_init(name, truncate) {
Global
If truncate
IfExist, %name%
FileDelete, %name%
Log_name := name
}
Log_msg( message ) {
Local CurrentTime
If Not Log_name
Return
FormatTime, CurrentTime, , yyyyMMddHHmmss
FileAppend, %CurrentTime% %message%`r`n, %Log_name%
}
Log_bare( message ) {
Local padded_message
If Not Log_name
Return
padded_message := " " . message . "`r`n"
FileAppend, %padded_message% , %Log_name%
}
Log_incDebugLevel() {
Global
If Not Log_name
Return
If ( Log_debug_level < 9 )
{
Log_debug_level += 1
Log_msg("Debug logging level incremented to " . Log_debug_level )
}
}
Log_decDebugLevel() {
Global
If Not Log_name
Return
If ( Log_debug_level > 0 ) {
Log_debug_level -= 1
If ( Log_debug_level = 0 )
Log_msg("Debug logging is disabled")
Else
Log_msg("Debug logging level decremented to " . Log_debug_level)
}
}
Log_dbg_msg( level, message ) {
Global
If (level > 0 And Log_debug_level >= level)
Log_msg( "DBG " . level . ": " . message )
}
Log_dbg_bare( level, message ) {
Global
If (level > 0 And Log_debug_level >= level)
Log_bare( "DBG " . level . ": " . message )
}

View file

@ -242,7 +242,6 @@ Main_toggleBar:
Return Return
#include Debug.ahk #include Debug.ahk
#Include List.ahk
#Include Bar.ahk #Include Bar.ahk
#Include Config.ahk #Include Config.ahk
#Include Manager.ahk #Include Manager.ahk

View file

@ -950,7 +950,7 @@ Manager__restoreWindowState(filename)
;Debug_logMessage("view_set: " . view_set, 1) ;Debug_logMessage("view_set: " . view_set, 1)
;Debug_logMessage("excluded_view_set: " . excluded_view_set, 1) ;Debug_logMessage("excluded_view_set: " . excluded_view_set, 1)
candidate_set := List_new() candidate_set := ""
; Scan through all defined windows. Create a candidate set of windows based on whether the properties of existing windows match. ; Scan through all defined windows. Create a candidate set of windows based on whether the properties of existing windows match.
Loop, % (widx - 1) Loop, % (widx - 1)
@ -1012,7 +1012,7 @@ Manager__restoreWindowState(filename)
Manager__setWinProperties(i, isManaged, m, v, isDecorated, isFloating, hideTitle ) Manager__setWinProperties(i, isManaged, m, v, isDecorated, isFloating, hideTitle )
;Manager_winHide(i) ;Manager_winHide(i)
List_append(candidate_set, i) candidate_set := candidate_set . i . ";"
} }
;Debug_logMessage("candidate_set: " . candidate_set, 1) ;Debug_logMessage("candidate_set: " . candidate_set, 1)