Permalink
Browse files

Autocomplete improvements

There are a bunch of temporary WIN32 constants in lib_listbox which
should be moved to the WIN32 libs. Size of the controls has been fixed
on Win7 and WinXP with A_GuiWidth/Height. levels.ahk now supports Sybase
ASA7
  • Loading branch information...
1 parent e760098 commit a136b1ef987fbfbc94401a71be9297e0d853d7ea @lordkrandel committed Sep 26, 2012
Showing with 51 additions and 33 deletions.
  1. +16 −6 lib/lib_LISTBOX.ahk
  2. +17 −10 scripts/ac/ac.ahk
  3. +18 −17 scripts/ac/levels.ahk
View
@@ -4,18 +4,28 @@ class ListBox {
this.hwnd := hwnd
}
selectAll(){
- this.select( -1 )
+ this.select( 1, -1 )
}
deselectAll(){
- this.select( 0 )
+ this.select( 0, -1 )
}
- select( i = 1){
+ select( a = 1, i = 1 ){
LB_SETSEL := 0x185
- PostMessage, % LB_SETSEL, 0, % i,, % "ahk_id " this.hwnd
+ SendMessage, % LB_SETSEL, % a, % i,, % "ahk_id " this.hwnd
}
choose( c ) {
- s := c.is("number") ? "Choose" : "ChooseString"
- Control, %s%, %c%, , % "ahk_id " this.hwnd
+ LB_SETTOPINDEX := 0x197
+ LB_GETCURSEL := 0x188
+ this.deselectAll()
+ if (c.is("number")){
+ this.select(1, c)
+ sel := c
+ } else {
+ Control, ChooseString, %c%, , % "ahk_id " this.hwnd
+ SendMessage, % LB_GETCURSEL, 0, 0, , % "ahk_id" this.hwnd
+ sel := ErrorLevel
+ }
+ SendMessage, % LB_SETTOPINDEX, % sel,0,, % "ahk_id " this.hwnd
}
set( e ){
if (isObject(e)){
View
@@ -51,7 +51,7 @@ class autoComplete extends g { ; ________________________
Gui, %g%: +Resize
Gui, %g%: Font, s10, Verdana
Gui, %g%: Add, edit, x0 y0 w300 h20 hwndhwndedit gEventDispatcher
- Gui, %g%: Add, listbox, x0 y20 hwndhwndlistbox Choose1 0x100 Multi +0x1000
+ Gui, %g%: Add, listbox, x0 y20 hwndhwndlistbox Choose0 0x100 Multi +0x1000
this.hwnd := winhwnd
this.listbox := new Listbox(hwndlistbox)
@@ -85,17 +85,16 @@ class autoComplete extends g { ; ________________________
this.listbox.choose(val)
}
} else {
- this.listbox.choose(1)
+ this.listbox.choose(0)
}
controlfocus,, % "ahk_id " this.win.edit
}
size(){
bl := A_BatchLines
SetBatchLines, 1000
- p := this.getPos()
- this.controlSet( this.listbox.hwnd, "Move", "w" p.w - 15 " h" p.h - 58)
- this.controlSet( this.win.edit, "Move", "w" p.w )
+ this.controlSet( this.listbox.hwnd, "Move", "w" A_GuiWidth " h" A_GuiHeight - 20)
+ this.controlSet( this.win.edit, "Move", "w" A_GuiWidth )
SetBatchLines, %bl%
}
@@ -160,18 +159,26 @@ class autoComplete extends g { ; ________________________
t := this.controlGet( this.win.edit )
entries := this.Entries
if (t != ""){
- arr := entries.split("|", "")
+ arr := entries.split("|", "")
entries := ""
+ top := ""
for k, v in arr {
- if (instr(v,t)){
- entries .= "|" v
+ s := instr(v,t)
+ if ( s > 0 ){
+ if ( s == 1 ){
+ top .= "|" v
+ } else {
+ entries .= "|" v
+ }
}
}
}
- entries := Core.firstValid( entries, "||" )
+
+ entries := top entries
+ entries := Core.firstValid( entries, "|" )
this.listbox.set( entries )
- this.listbox.choose(1)
+ this.listbox.choose(0)
}
}
View
@@ -3,6 +3,7 @@
class level {
odbc := ""
__new(odbc){
+
this.odbc := odbc
}
getDefault(){
@@ -42,18 +43,18 @@ class ownerlevel extends level{
q =
(
- select distinct
- table_owner
- from
- dbo.sp_tables()
- order by
- table_owner
- ;
+ select distinct
+ creator
+ from
+ sys.syscatalog
+ order by
+ creator
+ ;
)
query := new Query( this.odbc.conn, q )
s := ""
loop {
- s := s "|" query.rs.fields.item("table_owner").value
+ s := s "|" query.rs.fields.item("creator").value
query.rs.movenext()
} until (query.rs.EOF)
return s
@@ -65,24 +66,27 @@ class tablelevel extends level{
name := "Tables"
getEntries(val){
+
+ val := val.toUpper()
q =
(
select
- table_name
+ creator,
+ tname
from
- dbo.sp_tables()
+ sys.syscatalog
where
- upper(table_owner) = '%val%'
+ upper(creator) = '%val%'
order by
- table_owner,
- table_name
+ creator,
+ tname
;
)
this.odbc.connect()
query := new Query(this.odbc.conn, q )
s := ""
loop {
- s := s "|" query.rs.fields.item("table_name").value
+ s := s "|" query.rs.fields.item("tname").value
query.rs.movenext()
} until (query.rs.EOF)
return s
@@ -115,6 +119,3 @@ class columnlevel extends level{
return s
}
}
-
-
-

0 comments on commit a136b1e

Please sign in to comment.