removed List.ahk, related files and references (3 in total)

This commit is contained in:
joten 2012-09-28 14:23:34 +02:00
parent 67ab171e40
commit 6c6c00533d
3 changed files with 9 additions and 202 deletions

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

@ -744,12 +744,12 @@ Manager_sync(ByRef wndIds = "") {
; No windows are known to the system yet.
; Try to do something smart with the initial layout.
Manager_initial_sync() {
Local wndId0, wnd, wndX, wndY, wndW, wndH, x, y, m, len
Local m, wnd, wndH, wndId, wndId0, wndIds, wndW, wndX, wndY, x, y
; Initialize lists
; Note that these variables make this function non-reentrant.
Loop, % Manager_monitorCount
Manager_initial_sync_m#%A_Index%_wndList := List_new()
Manager_initial_sync_m#%A_Index%_wndList := ""
; check all visible windows against the known windows
WinGet, wndId, List, , ,
@ -767,17 +767,19 @@ Manager_initial_sync() {
m := Monitor_get(x, y)
If m > 0
List_append(Manager_initial_sync_m#%m%_wndList, wndId%A_index%)
Manager_initial_sync_m#%m%_wndList .= wndId%A_Index% ";"
; @todo: What percentage of the monitor area is it occupying? (Suggest layout)
; @todo: What part of the monitor is it on? (Ordering of windows)
}
Loop, % Manager_monitorCount {
Loop, % Manager_monitorCount
{
m := A_Index
len := List_toArray(Manager_initial_sync_m#%m%_wndList, "Manager_initial_sync_tmpArray")
Loop, % len
Manager_manage(m, 1, Manager_initial_sync_tmpArray%A_Index%)
StringTrimRight, wndIds, Manager_initial_sync_m#%m%_wndList, 1
StringSplit, wndId, wndIds, `;
Loop, % wndId0
Manager_manage(m, 1, wndId%A_Index%)
}
}