⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sys-command.zc

📁 实现树形结构
💻 ZC
字号:
//[of]:description
//[c]Private part of the implementation of the box class
//[cf]
//[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
import "base/types"
import "base/memory-allocator"
import "collection/linked-collection"
//[cf]
//[c]
//[of]:sys command
//[of]:type
//[c]
public struct system command: local linked element
	// the id used by windows as the command identifier
	id: word
	private _pad1: word // ### buggy compiler and alignments
end
//[c]
//[cf]
//[c]
//[of]:module initialization
//[of]:initialize system commands
//[c]
public func initialize system commands

	first slot = 0
	def array = allocate memory (sizeof sys cmd or next * max commands): [] local sys cmd or next
	global commands = array
	def i = 0
	def n = max commands - 1
	while i < n
		next (array [i]) = i + 1
		++i
	end
	next (array [i]) = -1

end
//[cf]
//[of]:release system commands
//[c]
public func release system commands

	free memory (global commands)

end
//[cf]
//[cf]
//[of]:global accessing
//[of]:system command from id (id)
//[c]
public equ system command from id (id: word) =
	cmd (global commands [id:dword])
//[cf]
//[cf]
//[of]:initialize - release
//[of]:initialize (system command)
//[c]
public func initialize (cmd: system command)

	def slot = first slot
	if slot <> -1
		first slot = next (global commands [slot])
		id (cmd) = slot: word
		cmd (global commands [slot]) = cmd
	else
		id (cmd) = -1:w
	end

end
//[cf]
//[of]:release (system command)
//[c]
public func release (cmd: system command)

	// release the id
	next (global commands [id (cmd): dword]) = first slot
	first slot = id (cmd): int
	
end
//[cf]
//[cf]
//[c]
//[of]:private
//[of]:type
private union sys cmd or next
	next: int
	cmd: system command
end
//[cf]
//[of]:constants
//[c]
// Maximum number of ids that can be allocated
// It will consume max commands * 4 bytes of memory
private equ max commands = 4096
//[cf]
//[of]:globals
//[c]
def first slot: int
def global commands: [] local sys cmd or next
//[cf]
//[cf]
//[cf]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -