📄 timer.zc
字号:
//[c]timer
//[c]
//[of]:license
//[c] Code Browser - a folding text editor for programmers
//[c] Copyright (C) 2003-07 Marc Kerbiquet
//[c]
//[c] This program is free software; you can redistribute it and/or modify
//[c] it under the terms of the GNU General Public License as published by
//[c] the Free Software Foundation; either version 2 of the License, or
//[c] (at your option) any later version.
//[c]
//[c] This program is distributed in the hope that it will be useful,
//[c] but WITHOUT ANY WARRANTY; without even the implied warranty of
//[c] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//[c] GNU General Public License for more details.
//[c]
//[c] You should have received a copy of the GNU General Public License
//[c] along with this program; if not, write to the Free Software
//[c] Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//[cf]
//[of]:imports
//[c]
import "base/types"
import "collection/linked-collection"
//[c]
import "win32/windows"
//[cf]
//[of]:structures
//[c]
typedef timer function = {object, timer} void
//[c]
public struct timer : local linked element
private bound : bool
private id : UINT
private time out : dword
// function to notify
private recipient : object
private code : timer function
end
//[cf]
//[c]
//[of]:class initialization
//[of]:initialize timer
//[c]
public func initialize timer
initialize (timers)
end
//[cf]
//[cf]
//[of]:initialize - release
//[of]:initialize (m, timeout, recipient, code)
//[c]
public func initialize (
m: timer,
time out: dword,
recipient: object,
code: timer function )
time out (m) = time out
bound (m) = false
recipient (m) = recipient
code (m) = code
add (timers, m)
end
//[cf]
//[of]:release (m)
//[c]
public func release (m: timer)
stop (m)
// remove from the global list
remove (timers, m)
end
//[cf]
//[cf]
//[of]:operations
//[of]:stop (timer)
//[c]
public func stop (m: timer)
if bound (m)
KillTimer (nil, id (m))
end
end
//[cf]
//[of]:start (timer)
//[c]
public func start (m: timer)
// remove any previously started timer
stop (m)
id (m) = SetTimer (
nil,
0,
time out (m),
^timer proc (HWND, UINT, UINT, DWORD))
bound (m) = true
end
//[cf]
//[cf]
//[c]
//[of]:private
//[of]:globals
//[c]
private def timers : local linked collection
//[cf]
//[c]
//[of]:timer proc (...)
//[c]
private [call="__stdcall"] func timer proc (
hwnd: HWND,
msg: UINT,
event: UINT,
time: DWORD)
// search associated timer
each (timers) ? t
equ timer = t : timer
if id (timer) == event
code (timer) {recipient (timer), timer}
return
end
end
end
//[cf]
//[cf]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -