forked from KolibriOS/kolibrios
outdated/clip: Post-SVN tidy
- Move source code from `trunk` into root directory. - Update build files and ASM include paths. - Note: Line endings standardised from `CRLF` > `LF`, so best to view diffs with whitespace changes hidden.
This commit is contained in:
@@ -1,413 +1,419 @@
|
||||
; <--- description --->
|
||||
; compiler: FASM
|
||||
; name: Clipboard server/daemon
|
||||
; version: 0.2
|
||||
; author: barsuk
|
||||
|
||||
; <--- include all MeOS stuff --->
|
||||
include "lang.inc"
|
||||
include "..\..\..\..\macros.inc"
|
||||
|
||||
; <--- start of MenuetOS application --->
|
||||
MEOS_APP_START
|
||||
|
||||
;define DEBUG TRUE
|
||||
define DEBUG FALSE
|
||||
include "bdebug.inc"
|
||||
|
||||
DEFAULT_SIZE = 0x10010 ; 64K + size of headers
|
||||
MAX_SIZE = 0x01000000 ; 16 M
|
||||
MAX_FORMAT = 16
|
||||
DELAY = 10 ; 1/10 sec between sending attempts
|
||||
ATTEMPT = 5 ; number of sending attempts
|
||||
|
||||
|
||||
; <--- start of code --->
|
||||
CODE
|
||||
|
||||
; ¢®-¯¥à¢ëå, ¤® 㡨âì ¢á¥ @clip, ª ª¨¥ ©¤ãâáï:
|
||||
; ¤¥¬® ¡ãä¥à ®¡¬¥ ¤®«¦¥ ¡ëâì ⮫쪮 ®¤¨!
|
||||
; ¨ ¨¬ ®ª ¦¥âáï á ¬ë© ¬®«®¤®© ¨§ ¤¥¬®®¢...
|
||||
|
||||
mov ecx, 2 ; ¯¥à¢ë© ®¬¥à ᫮⠤«ï ¯à®¢¥àª¨
|
||||
mov ebp, info
|
||||
mov ebx, ebp
|
||||
mov edx, 18
|
||||
.next_process:
|
||||
mov eax, 9
|
||||
int 0x40
|
||||
cmp dword [ebx + 10], '@CLI'
|
||||
jnz .differ
|
||||
cmp byte [ebx + 14], 'P'
|
||||
jnz .differ
|
||||
.similar:
|
||||
xchg eax, edx
|
||||
mov ebx, 2
|
||||
int 0x40
|
||||
mov ebx, ebp
|
||||
xchg eax, edx
|
||||
.differ:
|
||||
inc ecx
|
||||
cmp ecx, eax
|
||||
jae .done ; process not found
|
||||
jmp .next_process
|
||||
|
||||
.done:
|
||||
mov eax, 68 ; init heap
|
||||
mov ebx, 11
|
||||
int 0x40
|
||||
|
||||
mov eax, 66 ; set hotkey: Ctrl-Alt-V
|
||||
mov ebx, 4
|
||||
mov ecx, 47
|
||||
mov edx, 0x110 ; 0x110
|
||||
int 0x40
|
||||
print "set hot key (1 bad)"
|
||||
pregs
|
||||
|
||||
mov ebp, DEFAULT_SIZE
|
||||
|
||||
mov eax, 68 ; get memory for buffer
|
||||
mov ebx, 12
|
||||
mov ecx, ebp
|
||||
int 0x40
|
||||
mov esi, IPC_buffer
|
||||
mov [esi], eax
|
||||
|
||||
mov eax, 60 ; define buffer for IPC
|
||||
mov ebx, 1
|
||||
mov ecx, [esi]
|
||||
mov edx, ebp
|
||||
int 0x40
|
||||
|
||||
mov eax, 40
|
||||
mov ebx, 01000010b ;
|
||||
int 0x40
|
||||
|
||||
wait_event: ; main cycle
|
||||
mov eax, [IPC_buffer]
|
||||
mov dword [eax], 0 ; unlock buffer
|
||||
mov dword [eax + 4], 8
|
||||
|
||||
mov eax, 10 ; wait
|
||||
int 0x40
|
||||
print "event"
|
||||
pregs
|
||||
|
||||
;dec eax
|
||||
;dec eax
|
||||
cmp eax, 2
|
||||
jnz ipc_event
|
||||
|
||||
print "hotkey"
|
||||
|
||||
mov eax, 2
|
||||
int 0x40
|
||||
pregs
|
||||
cmp ah, 47 ; "v" up
|
||||
jnz wait_event
|
||||
|
||||
print "hotkey v up"
|
||||
; it is hotkey
|
||||
mov eax, 1
|
||||
mov ebx, eax
|
||||
call find_format
|
||||
pregs
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
mov esi, [data_buffer + eax * 4]
|
||||
mov edi, [data_size + eax * 4]
|
||||
mov ecx, 2
|
||||
print "ping"
|
||||
.next:
|
||||
mov eax, 72
|
||||
movzx edx, byte [esi]
|
||||
int 0x40 ; here we should pause if eax = 1
|
||||
pregs
|
||||
|
||||
inc esi
|
||||
dec edi
|
||||
jnz .next
|
||||
jmp wait_event
|
||||
|
||||
ipc_event:
|
||||
|
||||
; we get an IPC message
|
||||
|
||||
print "recv. "
|
||||
|
||||
mov eax, [IPC_buffer]
|
||||
mov dword [eax], 1 ; lock buffer
|
||||
mov dword [eax + 4], 8
|
||||
|
||||
dph1 dword [eax] ; lock
|
||||
dph1 dword [eax + 4] ; current used size
|
||||
dph1 dword [eax + 8] ; pid
|
||||
dph1 dword [eax + 12] ; len
|
||||
print ""
|
||||
dph1 dword [eax + 16] ; cmd << 16 | fmt
|
||||
dph1 dword [eax + 20]
|
||||
dph1 dword [eax + 24]
|
||||
|
||||
mov ebx, [eax + 8 + 4]
|
||||
cmp ebx, 8
|
||||
jb wait_event ; all my messages have 8-byte header
|
||||
; so ignore this one
|
||||
|
||||
movzx ecx, word [eax + 8 + 8] ; command
|
||||
cmp ecx, 1
|
||||
jz command_setsize
|
||||
cmp ecx, 2
|
||||
jz command_set
|
||||
cmp ecx, 3
|
||||
jz command_getsize
|
||||
cmp ecx, 4
|
||||
jz command_get
|
||||
cmp ecx, 5
|
||||
jz command_delete
|
||||
jmp wait_event ; unrecognised command
|
||||
|
||||
command_setsize:
|
||||
|
||||
; the only thing we really need to do here is to grow IPC buffer
|
||||
; no changes are done to real buffer of chosen format
|
||||
|
||||
; the bad thing is that IPC buffer grows and never becomes less.
|
||||
; i want to fix this in the next version.
|
||||
|
||||
print "set size"
|
||||
|
||||
mov esi, [IPC_buffer_size]
|
||||
mov ecx, [eax + 24] ; size
|
||||
add ecx, 0x18 ; for headers
|
||||
;pregs
|
||||
cmp esi, ecx
|
||||
jae wait_event
|
||||
print "ipc buffer resize from esi to ecx"
|
||||
pregs
|
||||
|
||||
mov ebp, MAX_SIZE ; sort of protection. forbid transfer of more
|
||||
cmp ecx, ebp ; than 16,7 Mb of data through buffer
|
||||
jbe not_much
|
||||
mov ecx, ebp
|
||||
|
||||
not_much:
|
||||
xchg eax, edi ; edx := [IPC_buffer]
|
||||
add ecx, 0x18 ; for headers
|
||||
|
||||
mov [IPC_buffer_size], ecx
|
||||
mov eax, 68
|
||||
mov ebx, 12
|
||||
int 0x40 ; get memory
|
||||
print "get mem for new buf, eax"
|
||||
pregs
|
||||
mov [IPC_buffer], eax
|
||||
|
||||
mov dword [eax + 4], 8
|
||||
mov edx, ecx
|
||||
mov ecx, eax
|
||||
mov eax, 60
|
||||
mov ebx, 1
|
||||
int 0x40 ; make it IPC buffer
|
||||
|
||||
mov ecx, edi
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
int 0x40 ; free old IPC buffer
|
||||
|
||||
jmp wait_event
|
||||
|
||||
command_set:
|
||||
print "set"
|
||||
|
||||
; here we put the data transfered to us to one of internal buffers
|
||||
|
||||
;;;outs eax + 0x18
|
||||
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
call find_format
|
||||
cmp eax, -1
|
||||
jz new_format
|
||||
mov edx, eax
|
||||
|
||||
; free old buffer of this format
|
||||
|
||||
mov ecx, [data_buffer + edx * 4]
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
int 0x40
|
||||
jmp set_buffer
|
||||
|
||||
new_format:
|
||||
mov eax, data_count ; allocate a buffer
|
||||
mov edx, [eax]
|
||||
inc dword [eax] ; no protection, no checks. very bad :(
|
||||
set_buffer:
|
||||
mov eax, [IPC_buffer]
|
||||
mov ecx, dword [eax + 12]
|
||||
sub ecx, 8 ; get length of data itself
|
||||
; subtract size of my headers
|
||||
;pregs
|
||||
mov [data_size + edx * 4], ecx ; save length of data
|
||||
|
||||
mov eax, 68
|
||||
mov ebx, 12
|
||||
int 0x40
|
||||
mov [data_buffer + edx * 4], eax
|
||||
|
||||
; copy data from IPC to new buffer
|
||||
mov esi, [IPC_buffer]
|
||||
mov ebp, esi
|
||||
add esi, 24 ; start of data
|
||||
mov edi, eax
|
||||
rep movsb ; oh, me knows that it's bad
|
||||
|
||||
mov eax, ebp
|
||||
movzx ecx, word [eax + 18] ; format id
|
||||
mov [data_format + edx * 4], ecx
|
||||
|
||||
; debug
|
||||
; print "set debug"
|
||||
; mov eax, [data_buffer + edx * 4]
|
||||
; mov ebx, [data_size + edx * 4]
|
||||
; mov ecx, [data_format + edx * 4]
|
||||
; pregs
|
||||
|
||||
jmp wait_event
|
||||
|
||||
command_delete:
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
cmp eax, -1
|
||||
jz command_clear
|
||||
call find_format
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
mov ecx, [data_buffer + eax * 4]
|
||||
mov [data_format + eax * 4], 0
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
int 0x40
|
||||
jmp wait_event
|
||||
|
||||
command_clear:
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
mov edx, data_buffer
|
||||
.next:
|
||||
mov ecx, [edx]
|
||||
jecxz .nofree
|
||||
int 0x40
|
||||
.nofree:
|
||||
mov [edx + data_size - data_buffer], 0
|
||||
add edx, 4
|
||||
cmp edx, data_format
|
||||
jnae .next
|
||||
jmp wait_event
|
||||
|
||||
command_getsize:
|
||||
|
||||
print "get size"
|
||||
|
||||
; we should send reply, containing size of data with chosen format id
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
mov esi, 4
|
||||
call find_format
|
||||
;pregs
|
||||
cmp eax, -1
|
||||
jz zero_size
|
||||
|
||||
lea edx, [data_size + eax * 4]
|
||||
mov eax, [edx]
|
||||
jmp send_getsize
|
||||
zero_size:
|
||||
mov edx, dw_zero ; send 0 to indicate that the buffer is empty
|
||||
send_getsize:
|
||||
jmp send_msg
|
||||
|
||||
command_get:
|
||||
print "get"
|
||||
|
||||
; we need to send the data
|
||||
|
||||
; [:||||:]
|
||||
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
call find_format
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
mov edi, eax ; ¥ä¨£
|
||||
|
||||
mov edx, [data_buffer + edi * 4]
|
||||
mov esi, [data_size + edi * 4]
|
||||
;jmp send_msg
|
||||
|
||||
send_msg:
|
||||
|
||||
; for debugging
|
||||
; mov eax, 5
|
||||
; mov ebx, DELAY*5
|
||||
; int 0x40
|
||||
|
||||
mov ebp, ATTEMPT ; number of attempts to send
|
||||
mov eax, [IPC_buffer]
|
||||
mov ecx, [eax + 8] ; sender PID
|
||||
mov eax, 60
|
||||
mov ebx, 2
|
||||
int 0x40
|
||||
print "send data result eax"
|
||||
pregs
|
||||
cmp eax, 2
|
||||
jz .wait
|
||||
cmp eax, 3 ; it is strange..
|
||||
jz .wait ; maybe he needs time to resize his buf
|
||||
jmp wait_event
|
||||
.wait:
|
||||
dec ebp
|
||||
jz wait_event
|
||||
mov eax, 5 ; sleep a bit
|
||||
mov ebx, DELAY
|
||||
int 0x40
|
||||
jmp send_msg
|
||||
|
||||
|
||||
find_format: ; small function returning number of format
|
||||
|
||||
;print "find format"
|
||||
push ebx
|
||||
mov ebx, eax ; format id
|
||||
and ebx, 0xffff ; it is word
|
||||
xor eax, eax
|
||||
next:
|
||||
cmp [data_format + eax * 4], ebx
|
||||
jz found
|
||||
inc eax
|
||||
cmp eax, MAX_FORMAT
|
||||
jb next
|
||||
not_found:
|
||||
or eax, -1
|
||||
found:
|
||||
;pregs
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; <--- initialised data --->
|
||||
DATA
|
||||
IPC_buffer dd 0
|
||||
IPC_buffer_size dd DEFAULT_SIZE ; initially 64K
|
||||
|
||||
info db 1024 dup(0) ; for process info
|
||||
|
||||
data_buffer dd MAX_FORMAT dup(0) ; buffer for some format
|
||||
; (256 formats max)
|
||||
data_format dd MAX_FORMAT dup(0) ; format id
|
||||
data_size dd MAX_FORMAT dup(0) ; size of buffer
|
||||
data_count dd 0 ; number of formats used
|
||||
dw_zero dd 0 ; used to tell that
|
||||
; we don't have a format
|
||||
|
||||
; <--- uninitialised data --->
|
||||
UDATA
|
||||
|
||||
|
||||
MEOS_APP_END
|
||||
; <--- end of MenuetOS application --->
|
||||
; SPDX-License-Identifier: NOASSERTION
|
||||
;
|
||||
|
||||
; Text encoded with Code Page 866 - Cyrillic
|
||||
|
||||
|
||||
; <--- description --->
|
||||
; compiler: FASM
|
||||
; name: Clipboard server/daemon
|
||||
; version: 0.2
|
||||
; author: barsuk
|
||||
|
||||
; <--- include all MeOS stuff --->
|
||||
include "lang.inc"
|
||||
include "..\..\..\macros.inc"
|
||||
|
||||
; <--- start of MenuetOS application --->
|
||||
MEOS_APP_START
|
||||
|
||||
;define DEBUG TRUE
|
||||
define DEBUG FALSE
|
||||
include "bdebug.inc"
|
||||
|
||||
DEFAULT_SIZE = 0x10010 ; 64K + size of headers
|
||||
MAX_SIZE = 0x01000000 ; 16 M
|
||||
MAX_FORMAT = 16
|
||||
DELAY = 10 ; 1/10 sec between sending attempts
|
||||
ATTEMPT = 5 ; number of sending attempts
|
||||
|
||||
|
||||
; <--- start of code --->
|
||||
CODE
|
||||
|
||||
; ¢®-¯¥à¢ëå, ¤® 㡨âì ¢á¥ @clip, ª ª¨¥ ©¤ãâáï:
|
||||
; ¤¥¬® ¡ãä¥à ®¡¬¥ ¤®«¦¥ ¡ëâì ⮫쪮 ®¤¨!
|
||||
; ¨ ¨¬ ®ª ¦¥âáï á ¬ë© ¬®«®¤®© ¨§ ¤¥¬®®¢...
|
||||
|
||||
mov ecx, 2 ; ¯¥à¢ë© ®¬¥à ᫮⠤«ï ¯à®¢¥àª¨
|
||||
mov ebp, info
|
||||
mov ebx, ebp
|
||||
mov edx, 18
|
||||
.next_process:
|
||||
mov eax, 9
|
||||
int 0x40
|
||||
cmp dword [ebx + 10], '@CLI'
|
||||
jnz .differ
|
||||
cmp byte [ebx + 14], 'P'
|
||||
jnz .differ
|
||||
.similar:
|
||||
xchg eax, edx
|
||||
mov ebx, 2
|
||||
int 0x40
|
||||
mov ebx, ebp
|
||||
xchg eax, edx
|
||||
.differ:
|
||||
inc ecx
|
||||
cmp ecx, eax
|
||||
jae .done ; process not found
|
||||
jmp .next_process
|
||||
|
||||
.done:
|
||||
mov eax, 68 ; init heap
|
||||
mov ebx, 11
|
||||
int 0x40
|
||||
|
||||
mov eax, 66 ; set hotkey: Ctrl-Alt-V
|
||||
mov ebx, 4
|
||||
mov ecx, 47
|
||||
mov edx, 0x110 ; 0x110
|
||||
int 0x40
|
||||
print "set hot key (1 bad)"
|
||||
pregs
|
||||
|
||||
mov ebp, DEFAULT_SIZE
|
||||
|
||||
mov eax, 68 ; get memory for buffer
|
||||
mov ebx, 12
|
||||
mov ecx, ebp
|
||||
int 0x40
|
||||
mov esi, IPC_buffer
|
||||
mov [esi], eax
|
||||
|
||||
mov eax, 60 ; define buffer for IPC
|
||||
mov ebx, 1
|
||||
mov ecx, [esi]
|
||||
mov edx, ebp
|
||||
int 0x40
|
||||
|
||||
mov eax, 40
|
||||
mov ebx, 01000010b ;
|
||||
int 0x40
|
||||
|
||||
wait_event: ; main cycle
|
||||
mov eax, [IPC_buffer]
|
||||
mov dword [eax], 0 ; unlock buffer
|
||||
mov dword [eax + 4], 8
|
||||
|
||||
mov eax, 10 ; wait
|
||||
int 0x40
|
||||
print "event"
|
||||
pregs
|
||||
|
||||
;dec eax
|
||||
;dec eax
|
||||
cmp eax, 2
|
||||
jnz ipc_event
|
||||
|
||||
print "hotkey"
|
||||
|
||||
mov eax, 2
|
||||
int 0x40
|
||||
pregs
|
||||
cmp ah, 47 ; "v" up
|
||||
jnz wait_event
|
||||
|
||||
print "hotkey v up"
|
||||
; it is hotkey
|
||||
mov eax, 1
|
||||
mov ebx, eax
|
||||
call find_format
|
||||
pregs
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
mov esi, [data_buffer + eax * 4]
|
||||
mov edi, [data_size + eax * 4]
|
||||
mov ecx, 2
|
||||
print "ping"
|
||||
.next:
|
||||
mov eax, 72
|
||||
movzx edx, byte [esi]
|
||||
int 0x40 ; here we should pause if eax = 1
|
||||
pregs
|
||||
|
||||
inc esi
|
||||
dec edi
|
||||
jnz .next
|
||||
jmp wait_event
|
||||
|
||||
ipc_event:
|
||||
|
||||
; we get an IPC message
|
||||
|
||||
print "recv. "
|
||||
|
||||
mov eax, [IPC_buffer]
|
||||
mov dword [eax], 1 ; lock buffer
|
||||
mov dword [eax + 4], 8
|
||||
|
||||
dph1 dword [eax] ; lock
|
||||
dph1 dword [eax + 4] ; current used size
|
||||
dph1 dword [eax + 8] ; pid
|
||||
dph1 dword [eax + 12] ; len
|
||||
print ""
|
||||
dph1 dword [eax + 16] ; cmd << 16 | fmt
|
||||
dph1 dword [eax + 20]
|
||||
dph1 dword [eax + 24]
|
||||
|
||||
mov ebx, [eax + 8 + 4]
|
||||
cmp ebx, 8
|
||||
jb wait_event ; all my messages have 8-byte header
|
||||
; so ignore this one
|
||||
|
||||
movzx ecx, word [eax + 8 + 8] ; command
|
||||
cmp ecx, 1
|
||||
jz command_setsize
|
||||
cmp ecx, 2
|
||||
jz command_set
|
||||
cmp ecx, 3
|
||||
jz command_getsize
|
||||
cmp ecx, 4
|
||||
jz command_get
|
||||
cmp ecx, 5
|
||||
jz command_delete
|
||||
jmp wait_event ; unrecognised command
|
||||
|
||||
command_setsize:
|
||||
|
||||
; the only thing we really need to do here is to grow IPC buffer
|
||||
; no changes are done to real buffer of chosen format
|
||||
|
||||
; the bad thing is that IPC buffer grows and never becomes less.
|
||||
; i want to fix this in the next version.
|
||||
|
||||
print "set size"
|
||||
|
||||
mov esi, [IPC_buffer_size]
|
||||
mov ecx, [eax + 24] ; size
|
||||
add ecx, 0x18 ; for headers
|
||||
;pregs
|
||||
cmp esi, ecx
|
||||
jae wait_event
|
||||
print "ipc buffer resize from esi to ecx"
|
||||
pregs
|
||||
|
||||
mov ebp, MAX_SIZE ; sort of protection. forbid transfer of more
|
||||
cmp ecx, ebp ; than 16,7 Mb of data through buffer
|
||||
jbe not_much
|
||||
mov ecx, ebp
|
||||
|
||||
not_much:
|
||||
xchg eax, edi ; edx := [IPC_buffer]
|
||||
add ecx, 0x18 ; for headers
|
||||
|
||||
mov [IPC_buffer_size], ecx
|
||||
mov eax, 68
|
||||
mov ebx, 12
|
||||
int 0x40 ; get memory
|
||||
print "get mem for new buf, eax"
|
||||
pregs
|
||||
mov [IPC_buffer], eax
|
||||
|
||||
mov dword [eax + 4], 8
|
||||
mov edx, ecx
|
||||
mov ecx, eax
|
||||
mov eax, 60
|
||||
mov ebx, 1
|
||||
int 0x40 ; make it IPC buffer
|
||||
|
||||
mov ecx, edi
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
int 0x40 ; free old IPC buffer
|
||||
|
||||
jmp wait_event
|
||||
|
||||
command_set:
|
||||
print "set"
|
||||
|
||||
; here we put the data transfered to us to one of internal buffers
|
||||
|
||||
;;;outs eax + 0x18
|
||||
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
call find_format
|
||||
cmp eax, -1
|
||||
jz new_format
|
||||
mov edx, eax
|
||||
|
||||
; free old buffer of this format
|
||||
|
||||
mov ecx, [data_buffer + edx * 4]
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
int 0x40
|
||||
jmp set_buffer
|
||||
|
||||
new_format:
|
||||
mov eax, data_count ; allocate a buffer
|
||||
mov edx, [eax]
|
||||
inc dword [eax] ; no protection, no checks. very bad :(
|
||||
set_buffer:
|
||||
mov eax, [IPC_buffer]
|
||||
mov ecx, dword [eax + 12]
|
||||
sub ecx, 8 ; get length of data itself
|
||||
; subtract size of my headers
|
||||
;pregs
|
||||
mov [data_size + edx * 4], ecx ; save length of data
|
||||
|
||||
mov eax, 68
|
||||
mov ebx, 12
|
||||
int 0x40
|
||||
mov [data_buffer + edx * 4], eax
|
||||
|
||||
; copy data from IPC to new buffer
|
||||
mov esi, [IPC_buffer]
|
||||
mov ebp, esi
|
||||
add esi, 24 ; start of data
|
||||
mov edi, eax
|
||||
rep movsb ; oh, me knows that it's bad
|
||||
|
||||
mov eax, ebp
|
||||
movzx ecx, word [eax + 18] ; format id
|
||||
mov [data_format + edx * 4], ecx
|
||||
|
||||
; debug
|
||||
; print "set debug"
|
||||
; mov eax, [data_buffer + edx * 4]
|
||||
; mov ebx, [data_size + edx * 4]
|
||||
; mov ecx, [data_format + edx * 4]
|
||||
; pregs
|
||||
|
||||
jmp wait_event
|
||||
|
||||
command_delete:
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
cmp eax, -1
|
||||
jz command_clear
|
||||
call find_format
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
mov ecx, [data_buffer + eax * 4]
|
||||
mov [data_format + eax * 4], 0
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
int 0x40
|
||||
jmp wait_event
|
||||
|
||||
command_clear:
|
||||
mov eax, 68
|
||||
mov ebx, 13
|
||||
mov edx, data_buffer
|
||||
.next:
|
||||
mov ecx, [edx]
|
||||
jecxz .nofree
|
||||
int 0x40
|
||||
.nofree:
|
||||
mov [edx + data_size - data_buffer], 0
|
||||
add edx, 4
|
||||
cmp edx, data_format
|
||||
jnae .next
|
||||
jmp wait_event
|
||||
|
||||
command_getsize:
|
||||
|
||||
print "get size"
|
||||
|
||||
; we should send reply, containing size of data with chosen format id
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
mov esi, 4
|
||||
call find_format
|
||||
;pregs
|
||||
cmp eax, -1
|
||||
jz zero_size
|
||||
|
||||
lea edx, [data_size + eax * 4]
|
||||
mov eax, [edx]
|
||||
jmp send_getsize
|
||||
zero_size:
|
||||
mov edx, dw_zero ; send 0 to indicate that the buffer is empty
|
||||
send_getsize:
|
||||
jmp send_msg
|
||||
|
||||
command_get:
|
||||
print "get"
|
||||
|
||||
; we need to send the data
|
||||
|
||||
; [:||||:]
|
||||
|
||||
movzx eax, word [eax + 18] ; format id
|
||||
call find_format
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
mov edi, eax ; ¥ä¨£
|
||||
|
||||
mov edx, [data_buffer + edi * 4]
|
||||
mov esi, [data_size + edi * 4]
|
||||
;jmp send_msg
|
||||
|
||||
send_msg:
|
||||
|
||||
; for debugging
|
||||
; mov eax, 5
|
||||
; mov ebx, DELAY*5
|
||||
; int 0x40
|
||||
|
||||
mov ebp, ATTEMPT ; number of attempts to send
|
||||
mov eax, [IPC_buffer]
|
||||
mov ecx, [eax + 8] ; sender PID
|
||||
mov eax, 60
|
||||
mov ebx, 2
|
||||
int 0x40
|
||||
print "send data result eax"
|
||||
pregs
|
||||
cmp eax, 2
|
||||
jz .wait
|
||||
cmp eax, 3 ; it is strange..
|
||||
jz .wait ; maybe he needs time to resize his buf
|
||||
jmp wait_event
|
||||
.wait:
|
||||
dec ebp
|
||||
jz wait_event
|
||||
mov eax, 5 ; sleep a bit
|
||||
mov ebx, DELAY
|
||||
int 0x40
|
||||
jmp send_msg
|
||||
|
||||
|
||||
find_format: ; small function returning number of format
|
||||
|
||||
;print "find format"
|
||||
push ebx
|
||||
mov ebx, eax ; format id
|
||||
and ebx, 0xffff ; it is word
|
||||
xor eax, eax
|
||||
next:
|
||||
cmp [data_format + eax * 4], ebx
|
||||
jz found
|
||||
inc eax
|
||||
cmp eax, MAX_FORMAT
|
||||
jb next
|
||||
not_found:
|
||||
or eax, -1
|
||||
found:
|
||||
;pregs
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; <--- initialised data --->
|
||||
DATA
|
||||
IPC_buffer dd 0
|
||||
IPC_buffer_size dd DEFAULT_SIZE ; initially 64K
|
||||
|
||||
info db 1024 dup(0) ; for process info
|
||||
|
||||
data_buffer dd MAX_FORMAT dup(0) ; buffer for some format
|
||||
; (256 formats max)
|
||||
data_format dd MAX_FORMAT dup(0) ; format id
|
||||
data_size dd MAX_FORMAT dup(0) ; size of buffer
|
||||
data_count dd 0 ; number of formats used
|
||||
dw_zero dd 0 ; used to tell that
|
||||
; we don't have a format
|
||||
|
||||
; <--- uninitialised data --->
|
||||
UDATA
|
||||
|
||||
|
||||
MEOS_APP_END
|
||||
; <--- end of MenuetOS application --->
|
@@ -1,5 +1,5 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
@@ -1,47 +1,50 @@
|
||||
; debugging include file by barsuk
|
||||
; if DEBUG=TRUE, adds debug.inc
|
||||
; if DEBUG=FALSE, adds stubs for several macros from debug.inc
|
||||
|
||||
match =TRUE, DEBUG
|
||||
{
|
||||
|
||||
include '..\..\..\..\debug.inc'
|
||||
|
||||
macro dph1 str
|
||||
\{
|
||||
debug_print_hex str
|
||||
push eax
|
||||
mov al, ' '
|
||||
call debug_outchar
|
||||
pop eax
|
||||
\}
|
||||
|
||||
macro outs str
|
||||
\{
|
||||
pushad
|
||||
lea edx, [str]
|
||||
call debug_outstr
|
||||
popad
|
||||
\}
|
||||
}
|
||||
|
||||
match =FALSE, DEBUG
|
||||
{
|
||||
|
||||
macro print message
|
||||
\{
|
||||
\}
|
||||
|
||||
macro pregs
|
||||
\{
|
||||
\}
|
||||
|
||||
macro dph1 str
|
||||
\{
|
||||
\}
|
||||
|
||||
macro outs str
|
||||
\{
|
||||
\}
|
||||
|
||||
}
|
||||
; SPDX-License-Identifier: NOASSERTION
|
||||
;
|
||||
|
||||
; debugging include file by barsuk
|
||||
; if DEBUG=TRUE, adds debug.inc
|
||||
; if DEBUG=FALSE, adds stubs for several macros from debug.inc
|
||||
|
||||
match =TRUE, DEBUG
|
||||
{
|
||||
|
||||
include '..\..\..\debug.inc'
|
||||
|
||||
macro dph1 str
|
||||
\{
|
||||
debug_print_hex str
|
||||
push eax
|
||||
mov al, ' '
|
||||
call debug_outchar
|
||||
pop eax
|
||||
\}
|
||||
|
||||
macro outs str
|
||||
\{
|
||||
pushad
|
||||
lea edx, [str]
|
||||
call debug_outstr
|
||||
popad
|
||||
\}
|
||||
}
|
||||
|
||||
match =FALSE, DEBUG
|
||||
{
|
||||
|
||||
macro print message
|
||||
\{
|
||||
\}
|
||||
|
||||
macro pregs
|
||||
\{
|
||||
\}
|
||||
|
||||
macro dph1 str
|
||||
\{
|
||||
\}
|
||||
|
||||
macro outs str
|
||||
\{
|
||||
\}
|
||||
|
||||
}
|
@@ -1,240 +1,246 @@
|
||||
; <--- description --->
|
||||
; compiler: FASM
|
||||
; name: Clipboard Client Demo
|
||||
; version: 0.1
|
||||
; author: barsuk
|
||||
|
||||
|
||||
; <--- include all MeOS stuff --->
|
||||
include "lang.inc"
|
||||
include "..\..\..\..\macros.inc"
|
||||
|
||||
TEST_SIZE = 100000 ; ¤®«¦® ¤¥«¨âìáï 4
|
||||
|
||||
IPC_buffer_size = TEST_SIZE + 0x10
|
||||
MAX_BUFFER = TEST_SIZE + 0x10
|
||||
|
||||
SEND_DELAY = 10
|
||||
RECV_DELAY = 100
|
||||
|
||||
ATTEMPT = 5 ; ç¨á«® ¯®¯ë⮪ ®â¯à ¢¨âì á®®¡é¥¨¥ ¤¥¬®ã, ¥á«¨
|
||||
; ® § ïâ
|
||||
|
||||
; <--- start of MenuetOS application --->
|
||||
MEOS_APP_START
|
||||
|
||||
define DEBUG TRUE
|
||||
include "bdebug.inc"
|
||||
|
||||
include "clip.inc"
|
||||
|
||||
; <--- start of code --->
|
||||
CODE
|
||||
|
||||
|
||||
;;; This is the entry point of the program
|
||||
|
||||
begin:
|
||||
|
||||
print "clipboard testing module loaded"
|
||||
|
||||
mov eax, 5
|
||||
mov ebx, 100 ; 5 sec
|
||||
int 0x40
|
||||
|
||||
call clipboard_init
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
; put the data into clip_buffer
|
||||
|
||||
mov esi, test_line
|
||||
mov edi, cb.data
|
||||
mov ecx, cb.size
|
||||
rep movsb
|
||||
|
||||
print "init ok. @clip found."
|
||||
|
||||
mov esi, cb
|
||||
mov eax, 2
|
||||
call clipboard_write
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
print "write test ok."
|
||||
|
||||
; á«¥£ª ®ç¨á⨬ ¡ãä¥à, ¤«ï ¤¥¦®á⨠¯à®¢¥àª¨
|
||||
|
||||
mov dword [cb.data], 0
|
||||
|
||||
;jmp .exit
|
||||
mov eax, 3 ; try to read bad data
|
||||
mov esi, cb
|
||||
mov edx, 7
|
||||
call clipboard_read
|
||||
or eax, eax
|
||||
jz .bad2
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
.bad2:
|
||||
print "unset data read ok 1."
|
||||
mov eax, 88 ; -"-
|
||||
mov esi, cb
|
||||
mov edx, 7
|
||||
call clipboard_read
|
||||
or eax, eax
|
||||
jz .bad3
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
.bad3:
|
||||
print "unset data read ok 2."
|
||||
|
||||
.read:
|
||||
mov eax, 2
|
||||
mov esi, cb
|
||||
mov edx, 7
|
||||
call clipboard_read ; read the string we've written
|
||||
or eax, eax
|
||||
jz .err
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
print "read ok o_O, data:"
|
||||
outs cb.data
|
||||
print ""
|
||||
|
||||
mov eax, 5
|
||||
mov ebx, 200
|
||||
int 0x40
|
||||
|
||||
|
||||
; ¯®á«¥¤ïï ¯à®¢¥àª - à¥á ©§ ¡ãä¥à . ¨¬¥®, ¢®§ì¬¥¬ ¬®£® ¤ ëå
|
||||
; ¨ ¯à®ª ç ¥¬ ¨å ç¥à¥§ ¡ãä¥à
|
||||
|
||||
mov eax, 68
|
||||
mov ebx, 11
|
||||
int 0x40
|
||||
|
||||
mov eax, 68
|
||||
mov ebx, 12
|
||||
mov ecx, TEST_SIZE + 12
|
||||
int 0x40
|
||||
mov [mega_buf], eax
|
||||
|
||||
mov dword [eax], TEST_SIZE
|
||||
|
||||
lea edx, [eax + 12]
|
||||
mov eax, 12131415
|
||||
shr ecx, 2
|
||||
.loop:
|
||||
mov [edx], eax
|
||||
add edx, 4
|
||||
dec ecx
|
||||
jnz .loop
|
||||
|
||||
print "mega buffer allocated and filled"
|
||||
|
||||
; now write it
|
||||
|
||||
mov esi, [mega_buf]
|
||||
mov eax, 69
|
||||
call clipboard_write
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
print "mega buffer written"
|
||||
mov eax, 5
|
||||
mov ebx, 100
|
||||
int 0x40
|
||||
|
||||
; clear it.
|
||||
|
||||
mov edx, [mega_buf]
|
||||
add edx, 12
|
||||
xor eax, eax
|
||||
mov ecx, TEST_SIZE/4
|
||||
.loopc:
|
||||
mov [edx], eax
|
||||
add edx, 4
|
||||
dec ecx
|
||||
jnz .loopc
|
||||
|
||||
; now read
|
||||
|
||||
mov eax, 69
|
||||
mov esi, [mega_buf]
|
||||
mov edx, 7
|
||||
call clipboard_read ; read the string we've written
|
||||
or eax, eax
|
||||
jz .err
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
print "mega buf read"
|
||||
|
||||
; now compare
|
||||
|
||||
mov edx, [mega_buf]
|
||||
add edx, 12
|
||||
mov eax, 12131415
|
||||
mov ecx, TEST_SIZE/4
|
||||
.loopm:
|
||||
cmp eax, [edx]
|
||||
jnz .err
|
||||
add edx, 4
|
||||
dec ecx
|
||||
jnz .loopm
|
||||
|
||||
print "deleting mega buf"
|
||||
|
||||
mov eax, 69
|
||||
call clipboard_delete
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
mov eax, 5
|
||||
mov ebx, 100
|
||||
int 0x40
|
||||
|
||||
print "if read error then all is ok"
|
||||
|
||||
mov eax, 69
|
||||
mov esi, [mega_buf]
|
||||
mov edx, 7
|
||||
call clipboard_read ; read the string we've written
|
||||
or eax, eax
|
||||
jz .reading
|
||||
jmp .err
|
||||
|
||||
.reading:
|
||||
|
||||
print "test complete!"
|
||||
|
||||
.exit:
|
||||
or eax, -1
|
||||
int 0x40
|
||||
|
||||
.err:
|
||||
print "error!"
|
||||
jmp .exit
|
||||
|
||||
|
||||
; <--- initialised data --->
|
||||
DATA
|
||||
|
||||
CLIP_BUFFER cb, 256
|
||||
|
||||
; in_buf db 256 dup(0)
|
||||
; out_buf db 'Cthulhu Fhtagn',0
|
||||
|
||||
test_line db 'Cthulhu Fhtagn',0
|
||||
mega_buf dd 0
|
||||
|
||||
; <--- uninitialised data --->
|
||||
UDATA
|
||||
|
||||
|
||||
MEOS_APP_END
|
||||
; <--- end of MenuetOS application --->
|
||||
; SPDX-License-Identifier: NOASSERTION
|
||||
;
|
||||
|
||||
; Text encoded with Code Page 866 - Cyrillic
|
||||
|
||||
|
||||
; <--- description --->
|
||||
; compiler: FASM
|
||||
; name: Clipboard Client Demo
|
||||
; version: 0.1
|
||||
; author: barsuk
|
||||
|
||||
|
||||
; <--- include all MeOS stuff --->
|
||||
include "lang.inc"
|
||||
include "..\..\..\macros.inc"
|
||||
|
||||
TEST_SIZE = 100000 ; ¤®«¦® ¤¥«¨âìáï 4
|
||||
|
||||
IPC_buffer_size = TEST_SIZE + 0x10
|
||||
MAX_BUFFER = TEST_SIZE + 0x10
|
||||
|
||||
SEND_DELAY = 10
|
||||
RECV_DELAY = 100
|
||||
|
||||
ATTEMPT = 5 ; ç¨á«® ¯®¯ë⮪ ®â¯à ¢¨âì á®®¡é¥¨¥ ¤¥¬®ã, ¥á«¨
|
||||
; ® § ïâ
|
||||
|
||||
; <--- start of MenuetOS application --->
|
||||
MEOS_APP_START
|
||||
|
||||
define DEBUG TRUE
|
||||
include "bdebug.inc"
|
||||
|
||||
include "clip.inc"
|
||||
|
||||
; <--- start of code --->
|
||||
CODE
|
||||
|
||||
|
||||
;;; This is the entry point of the program
|
||||
|
||||
begin:
|
||||
|
||||
print "clipboard testing module loaded"
|
||||
|
||||
mov eax, 5
|
||||
mov ebx, 100 ; 5 sec
|
||||
int 0x40
|
||||
|
||||
call clipboard_init
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
; put the data into clip_buffer
|
||||
|
||||
mov esi, test_line
|
||||
mov edi, cb.data
|
||||
mov ecx, cb.size
|
||||
rep movsb
|
||||
|
||||
print "init ok. @clip found."
|
||||
|
||||
mov esi, cb
|
||||
mov eax, 2
|
||||
call clipboard_write
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
print "write test ok."
|
||||
|
||||
; á«¥£ª ®ç¨á⨬ ¡ãä¥à, ¤«ï ¤¥¦®á⨠¯à®¢¥àª¨
|
||||
|
||||
mov dword [cb.data], 0
|
||||
|
||||
;jmp .exit
|
||||
mov eax, 3 ; try to read bad data
|
||||
mov esi, cb
|
||||
mov edx, 7
|
||||
call clipboard_read
|
||||
or eax, eax
|
||||
jz .bad2
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
.bad2:
|
||||
print "unset data read ok 1."
|
||||
mov eax, 88 ; -"-
|
||||
mov esi, cb
|
||||
mov edx, 7
|
||||
call clipboard_read
|
||||
or eax, eax
|
||||
jz .bad3
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
.bad3:
|
||||
print "unset data read ok 2."
|
||||
|
||||
.read:
|
||||
mov eax, 2
|
||||
mov esi, cb
|
||||
mov edx, 7
|
||||
call clipboard_read ; read the string we've written
|
||||
or eax, eax
|
||||
jz .err
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
print "read ok o_O, data:"
|
||||
outs cb.data
|
||||
print ""
|
||||
|
||||
mov eax, 5
|
||||
mov ebx, 200
|
||||
int 0x40
|
||||
|
||||
|
||||
; ¯®á«¥¤ïï ¯à®¢¥àª - à¥á ©§ ¡ãä¥à . ¨¬¥®, ¢®§ì¬¥¬ ¬®£® ¤ ëå
|
||||
; ¨ ¯à®ª ç ¥¬ ¨å ç¥à¥§ ¡ãä¥à
|
||||
|
||||
mov eax, 68
|
||||
mov ebx, 11
|
||||
int 0x40
|
||||
|
||||
mov eax, 68
|
||||
mov ebx, 12
|
||||
mov ecx, TEST_SIZE + 12
|
||||
int 0x40
|
||||
mov [mega_buf], eax
|
||||
|
||||
mov dword [eax], TEST_SIZE
|
||||
|
||||
lea edx, [eax + 12]
|
||||
mov eax, 12131415
|
||||
shr ecx, 2
|
||||
.loop:
|
||||
mov [edx], eax
|
||||
add edx, 4
|
||||
dec ecx
|
||||
jnz .loop
|
||||
|
||||
print "mega buffer allocated and filled"
|
||||
|
||||
; now write it
|
||||
|
||||
mov esi, [mega_buf]
|
||||
mov eax, 69
|
||||
call clipboard_write
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
print "mega buffer written"
|
||||
mov eax, 5
|
||||
mov ebx, 100
|
||||
int 0x40
|
||||
|
||||
; clear it.
|
||||
|
||||
mov edx, [mega_buf]
|
||||
add edx, 12
|
||||
xor eax, eax
|
||||
mov ecx, TEST_SIZE/4
|
||||
.loopc:
|
||||
mov [edx], eax
|
||||
add edx, 4
|
||||
dec ecx
|
||||
jnz .loopc
|
||||
|
||||
; now read
|
||||
|
||||
mov eax, 69
|
||||
mov esi, [mega_buf]
|
||||
mov edx, 7
|
||||
call clipboard_read ; read the string we've written
|
||||
or eax, eax
|
||||
jz .err
|
||||
cmp eax, -1
|
||||
jz .err
|
||||
|
||||
print "mega buf read"
|
||||
|
||||
; now compare
|
||||
|
||||
mov edx, [mega_buf]
|
||||
add edx, 12
|
||||
mov eax, 12131415
|
||||
mov ecx, TEST_SIZE/4
|
||||
.loopm:
|
||||
cmp eax, [edx]
|
||||
jnz .err
|
||||
add edx, 4
|
||||
dec ecx
|
||||
jnz .loopm
|
||||
|
||||
print "deleting mega buf"
|
||||
|
||||
mov eax, 69
|
||||
call clipboard_delete
|
||||
or eax, eax
|
||||
jz .err
|
||||
|
||||
mov eax, 5
|
||||
mov ebx, 100
|
||||
int 0x40
|
||||
|
||||
print "if read error then all is ok"
|
||||
|
||||
mov eax, 69
|
||||
mov esi, [mega_buf]
|
||||
mov edx, 7
|
||||
call clipboard_read ; read the string we've written
|
||||
or eax, eax
|
||||
jz .reading
|
||||
jmp .err
|
||||
|
||||
.reading:
|
||||
|
||||
print "test complete!"
|
||||
|
||||
.exit:
|
||||
or eax, -1
|
||||
int 0x40
|
||||
|
||||
.err:
|
||||
print "error!"
|
||||
jmp .exit
|
||||
|
||||
|
||||
; <--- initialised data --->
|
||||
DATA
|
||||
|
||||
CLIP_BUFFER cb, 256
|
||||
|
||||
; in_buf db 256 dup(0)
|
||||
; out_buf db 'Cthulhu Fhtagn',0
|
||||
|
||||
test_line db 'Cthulhu Fhtagn',0
|
||||
mega_buf dd 0
|
||||
|
||||
; <--- uninitialised data --->
|
||||
UDATA
|
||||
|
||||
|
||||
MEOS_APP_END
|
||||
; <--- end of MenuetOS application --->
|
@@ -1,272 +1,278 @@
|
||||
; <--- description --->
|
||||
; compiler: FASM
|
||||
; name: Clipboard test with GUI.
|
||||
; version: 0.1
|
||||
; author: barsuk
|
||||
; comments: uses edit_box by Maxxxx32,<Lrz> (old static version)
|
||||
|
||||
|
||||
; <--- include all MeOS stuff --->
|
||||
include "lang.inc"
|
||||
include "..\..\..\..\macros.inc"
|
||||
|
||||
; <--- start of MenuetOS application --->
|
||||
MEOS_APP_START
|
||||
|
||||
SEND_DELAY = 10
|
||||
RECV_DELAY = 100
|
||||
ATTEMPT = 5
|
||||
|
||||
|
||||
define DEBUG TRUE
|
||||
include "bdebug.inc"
|
||||
|
||||
include "editbox.inc"
|
||||
|
||||
include "clip.inc"
|
||||
|
||||
use_edit_box
|
||||
|
||||
; <--- start of code --->
|
||||
CODE
|
||||
|
||||
call clipboard_init
|
||||
|
||||
call draw_window ; at first create and draw the window
|
||||
|
||||
wait_event: ; main cycle
|
||||
|
||||
mov edi, input_box
|
||||
call edit_box.mouse
|
||||
|
||||
mov eax, 10
|
||||
int 0x40
|
||||
|
||||
cmp eax, 1 ; if event == 1
|
||||
je redraw ; jump to redraw handler
|
||||
cmp eax, 2 ; else if event == 2
|
||||
je key ; jump to key handler
|
||||
cmp eax, 3 ; else if event == 3
|
||||
je button ; jump to button handler
|
||||
|
||||
jmp wait_event ; else return to the start of main cycle
|
||||
|
||||
|
||||
redraw: ; redraw event handler
|
||||
call draw_window
|
||||
jmp wait_event
|
||||
|
||||
|
||||
key: ; key event handler
|
||||
mov eax, 2 ; get key code
|
||||
int 0x40
|
||||
|
||||
cmp ah, '0'
|
||||
jb no_digit
|
||||
cmp ah, '9'
|
||||
ja no_digit
|
||||
sub ah, '0'
|
||||
mov byte [format_id], ah
|
||||
call draw_window
|
||||
jmp wait_event
|
||||
no_digit:
|
||||
|
||||
mov edi, input_box
|
||||
call edit_box.key
|
||||
|
||||
jmp wait_event
|
||||
|
||||
|
||||
button: ; button event handler
|
||||
mov eax, 17 ; get button identifier
|
||||
int 0x40
|
||||
|
||||
cmp ah, 1
|
||||
jz exit
|
||||
|
||||
cmp ah, 5
|
||||
jz copy
|
||||
cmp ah, 6
|
||||
jz paste
|
||||
jmp wait_event
|
||||
copy:
|
||||
mov esi, input_text
|
||||
mov edi, buffer.data
|
||||
mov ecx, [buffer.size]
|
||||
rep movsb ; copy text to buffer
|
||||
|
||||
mov edi, input_box
|
||||
mov edx, [edi + 38] ; ed_size
|
||||
xchg edx, [buffer.size]
|
||||
movzx eax, byte [format_id]
|
||||
mov esi, buffer
|
||||
call clipboard_write
|
||||
xchg edx, [buffer.size]
|
||||
jmp wait_event
|
||||
|
||||
paste:
|
||||
mov esi, buffer
|
||||
movzx eax, byte [format_id]
|
||||
mov edx, 7
|
||||
call clipboard_read
|
||||
|
||||
or eax, eax
|
||||
jz wait_event
|
||||
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
|
||||
or edx, edx
|
||||
jz wait_event ; íâ® ¢á¥ ®è¨¡ª¨
|
||||
|
||||
mov eax, input_box
|
||||
;print "input box"
|
||||
;dph1 [eax]
|
||||
;dph1 [eax+4]
|
||||
;dph1 [eax+8]
|
||||
;dph1 [eax+12]
|
||||
;dph1 [eax+16]
|
||||
;dph1 [eax+20]
|
||||
;dph1 [eax+24]
|
||||
|
||||
;;;;jmp wait_event
|
||||
|
||||
mov word [input_box + 36], ed_focus ; flags
|
||||
|
||||
mov ecx, [input_box + 38] ; size
|
||||
print "paste read ecx=size"
|
||||
jecxz .noloop
|
||||
mov edi, input_box
|
||||
mov ah, 8 ; backspace
|
||||
.loop:
|
||||
call edit_box.key
|
||||
dec ecx
|
||||
jnz .loop
|
||||
.noloop:
|
||||
mov esi, buffer.data
|
||||
mov ecx, edx
|
||||
pregs
|
||||
.loop2:
|
||||
mov ah, [esi]
|
||||
cmp ah, 0
|
||||
jz .done
|
||||
call edit_box.key ; ï ¡ë ᥡ¥ à㪨 ®â१ « § â ª®¥
|
||||
; ® çâ® ¤¥« âì, ¥á«¨ ¨ ç¥ ¥ ¯®«ãç ¥âáï?
|
||||
inc esi
|
||||
dec ecx
|
||||
jnz .loop2
|
||||
|
||||
.done:
|
||||
print "rest of data ecx"
|
||||
pregs
|
||||
call draw_window
|
||||
jmp wait_event
|
||||
|
||||
exit:
|
||||
or eax, -1 ; exit application
|
||||
int 0x40
|
||||
|
||||
|
||||
draw_window:
|
||||
mov eax, 12 ; start drawing
|
||||
mov ebx, 1
|
||||
int 0x40
|
||||
|
||||
mov eax, 0 ; create and draw the window
|
||||
mov ebx, 100*65536+400 ; (window_cx)*65536+(window_sx)
|
||||
mov ecx, 100*65536+250 ; (window_cy)*65536+(window_sy)
|
||||
mov edx, 0x33ffffff ; work area color & window type 3
|
||||
mov edi, head
|
||||
int 0x40
|
||||
|
||||
mov eax, 4
|
||||
mov ebx, 10 shl 16 + 10
|
||||
mov ecx, 0x80000000
|
||||
mov edx, text1
|
||||
int 0x40
|
||||
mov eax, 4
|
||||
mov ebx, 10 shl 16 + 20
|
||||
mov edx, text2
|
||||
int 0x40
|
||||
mov eax, 47
|
||||
mov ebx, 0x00020000
|
||||
movzx ecx, byte [format_id]
|
||||
mov edx, 200 shl 16 + 20
|
||||
mov esi, 0
|
||||
int 0x40
|
||||
|
||||
mov eax, 8
|
||||
mov ebx, 10 shl 16 + 60
|
||||
mov ecx, 40 shl 16 + 15
|
||||
mov edx, 5
|
||||
mov esi, 0xd72189
|
||||
int 0x40
|
||||
mov eax, 4
|
||||
mov ebx, 12 shl 16 + 42
|
||||
mov ecx, 0x80000000
|
||||
mov edx, button1
|
||||
int 0x40
|
||||
|
||||
mov eax, 8
|
||||
mov ebx, 80 shl 16 + 60
|
||||
mov ecx, 40 shl 16 + 15
|
||||
mov edx, 6
|
||||
mov esi, 0xd72189
|
||||
int 0x40
|
||||
mov eax, 4
|
||||
mov ebx, 82 shl 16 + 42
|
||||
mov ecx, 0x80000000
|
||||
mov edx, button2
|
||||
int 0x40
|
||||
|
||||
mov edi, input_box
|
||||
call edit_box.draw
|
||||
|
||||
; mov eax, 4
|
||||
; mov ebx, 10 shl 16 + 90
|
||||
; mov ecx, 0
|
||||
; mov edx, input_text
|
||||
; mov esi, [input_box + 38]
|
||||
; int 0x40
|
||||
; mov eax, esi
|
||||
;print "eax = edit etxt len"
|
||||
;pregs
|
||||
|
||||
|
||||
|
||||
mov eax, 12 ; finish drawing
|
||||
mov ebx, 2
|
||||
int 0x40
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; <--- initialised data --->
|
||||
DATA
|
||||
|
||||
format_id db 1
|
||||
|
||||
; buffer db 256 dup(0)
|
||||
|
||||
CLIP_BUFFER buffer, 256
|
||||
|
||||
input_text db 256 dup(0)
|
||||
input_box edit_box 100,10,70,0xffffff,0,0x00aaaaaa,0,255,input_text
|
||||
|
||||
; input_box edit_box 100,10,70,0xffffff,0,0xaaaaaa,0,\
|
||||
; 0xaaaaaa,0,255,input_text,ed_always_focus
|
||||
|
||||
head db "<22>ਬ¥à à ¡®âë á ¡ãä¥à®¬ ®¡¬¥ ",0
|
||||
text1 db "<22> ¦¨¬ ©â¥ æ¨äàë 0-9 ¤«ï ᬥë id ä®à¬ â ¤ ëå",0
|
||||
text2 db "‘¥©ç á ¢ë¡à id ä®à¬ â ¤ ëå: ",0
|
||||
|
||||
button1 db "Š®¯¨à®¢ âì",0
|
||||
button2 db "‚áâ ¢¨âì",0
|
||||
|
||||
; <--- uninitialised data --->
|
||||
UDATA
|
||||
|
||||
|
||||
MEOS_APP_END
|
||||
; <--- end of MenuetOS application --->
|
||||
; SPDX-License-Identifier: NOASSERTION
|
||||
;
|
||||
|
||||
; Text encoded with Code Page 866 - Cyrillic
|
||||
|
||||
|
||||
; <--- description --->
|
||||
; compiler: FASM
|
||||
; name: Clipboard test with GUI.
|
||||
; version: 0.1
|
||||
; author: barsuk
|
||||
; comments: uses edit_box by Maxxxx32,<Lrz> (old static version)
|
||||
|
||||
|
||||
; <--- include all MeOS stuff --->
|
||||
include "lang.inc"
|
||||
include "..\..\..\macros.inc"
|
||||
|
||||
; <--- start of MenuetOS application --->
|
||||
MEOS_APP_START
|
||||
|
||||
SEND_DELAY = 10
|
||||
RECV_DELAY = 100
|
||||
ATTEMPT = 5
|
||||
|
||||
|
||||
define DEBUG TRUE
|
||||
include "bdebug.inc"
|
||||
|
||||
include "editbox.inc"
|
||||
|
||||
include "clip.inc"
|
||||
|
||||
use_edit_box
|
||||
|
||||
; <--- start of code --->
|
||||
CODE
|
||||
|
||||
call clipboard_init
|
||||
|
||||
call draw_window ; at first create and draw the window
|
||||
|
||||
wait_event: ; main cycle
|
||||
|
||||
mov edi, input_box
|
||||
call edit_box.mouse
|
||||
|
||||
mov eax, 10
|
||||
int 0x40
|
||||
|
||||
cmp eax, 1 ; if event == 1
|
||||
je redraw ; jump to redraw handler
|
||||
cmp eax, 2 ; else if event == 2
|
||||
je key ; jump to key handler
|
||||
cmp eax, 3 ; else if event == 3
|
||||
je button ; jump to button handler
|
||||
|
||||
jmp wait_event ; else return to the start of main cycle
|
||||
|
||||
|
||||
redraw: ; redraw event handler
|
||||
call draw_window
|
||||
jmp wait_event
|
||||
|
||||
|
||||
key: ; key event handler
|
||||
mov eax, 2 ; get key code
|
||||
int 0x40
|
||||
|
||||
cmp ah, '0'
|
||||
jb no_digit
|
||||
cmp ah, '9'
|
||||
ja no_digit
|
||||
sub ah, '0'
|
||||
mov byte [format_id], ah
|
||||
call draw_window
|
||||
jmp wait_event
|
||||
no_digit:
|
||||
|
||||
mov edi, input_box
|
||||
call edit_box.key
|
||||
|
||||
jmp wait_event
|
||||
|
||||
|
||||
button: ; button event handler
|
||||
mov eax, 17 ; get button identifier
|
||||
int 0x40
|
||||
|
||||
cmp ah, 1
|
||||
jz exit
|
||||
|
||||
cmp ah, 5
|
||||
jz copy
|
||||
cmp ah, 6
|
||||
jz paste
|
||||
jmp wait_event
|
||||
copy:
|
||||
mov esi, input_text
|
||||
mov edi, buffer.data
|
||||
mov ecx, [buffer.size]
|
||||
rep movsb ; copy text to buffer
|
||||
|
||||
mov edi, input_box
|
||||
mov edx, [edi + 38] ; ed_size
|
||||
xchg edx, [buffer.size]
|
||||
movzx eax, byte [format_id]
|
||||
mov esi, buffer
|
||||
call clipboard_write
|
||||
xchg edx, [buffer.size]
|
||||
jmp wait_event
|
||||
|
||||
paste:
|
||||
mov esi, buffer
|
||||
movzx eax, byte [format_id]
|
||||
mov edx, 7
|
||||
call clipboard_read
|
||||
|
||||
or eax, eax
|
||||
jz wait_event
|
||||
|
||||
cmp eax, -1
|
||||
jz wait_event
|
||||
|
||||
or edx, edx
|
||||
jz wait_event ; íâ® ¢á¥ ®è¨¡ª¨
|
||||
|
||||
mov eax, input_box
|
||||
;print "input box"
|
||||
;dph1 [eax]
|
||||
;dph1 [eax+4]
|
||||
;dph1 [eax+8]
|
||||
;dph1 [eax+12]
|
||||
;dph1 [eax+16]
|
||||
;dph1 [eax+20]
|
||||
;dph1 [eax+24]
|
||||
|
||||
;;;;jmp wait_event
|
||||
|
||||
mov word [input_box + 36], ed_focus ; flags
|
||||
|
||||
mov ecx, [input_box + 38] ; size
|
||||
print "paste read ecx=size"
|
||||
jecxz .noloop
|
||||
mov edi, input_box
|
||||
mov ah, 8 ; backspace
|
||||
.loop:
|
||||
call edit_box.key
|
||||
dec ecx
|
||||
jnz .loop
|
||||
.noloop:
|
||||
mov esi, buffer.data
|
||||
mov ecx, edx
|
||||
pregs
|
||||
.loop2:
|
||||
mov ah, [esi]
|
||||
cmp ah, 0
|
||||
jz .done
|
||||
call edit_box.key ; ï ¡ë ᥡ¥ à㪨 ®â१ « § â ª®¥
|
||||
; ® çâ® ¤¥« âì, ¥á«¨ ¨ ç¥ ¥ ¯®«ãç ¥âáï?
|
||||
inc esi
|
||||
dec ecx
|
||||
jnz .loop2
|
||||
|
||||
.done:
|
||||
print "rest of data ecx"
|
||||
pregs
|
||||
call draw_window
|
||||
jmp wait_event
|
||||
|
||||
exit:
|
||||
or eax, -1 ; exit application
|
||||
int 0x40
|
||||
|
||||
|
||||
draw_window:
|
||||
mov eax, 12 ; start drawing
|
||||
mov ebx, 1
|
||||
int 0x40
|
||||
|
||||
mov eax, 0 ; create and draw the window
|
||||
mov ebx, 100*65536+400 ; (window_cx)*65536+(window_sx)
|
||||
mov ecx, 100*65536+250 ; (window_cy)*65536+(window_sy)
|
||||
mov edx, 0x33ffffff ; work area color & window type 3
|
||||
mov edi, head
|
||||
int 0x40
|
||||
|
||||
mov eax, 4
|
||||
mov ebx, 10 shl 16 + 10
|
||||
mov ecx, 0x80000000
|
||||
mov edx, text1
|
||||
int 0x40
|
||||
mov eax, 4
|
||||
mov ebx, 10 shl 16 + 20
|
||||
mov edx, text2
|
||||
int 0x40
|
||||
mov eax, 47
|
||||
mov ebx, 0x00020000
|
||||
movzx ecx, byte [format_id]
|
||||
mov edx, 200 shl 16 + 20
|
||||
mov esi, 0
|
||||
int 0x40
|
||||
|
||||
mov eax, 8
|
||||
mov ebx, 10 shl 16 + 60
|
||||
mov ecx, 40 shl 16 + 15
|
||||
mov edx, 5
|
||||
mov esi, 0xd72189
|
||||
int 0x40
|
||||
mov eax, 4
|
||||
mov ebx, 12 shl 16 + 42
|
||||
mov ecx, 0x80000000
|
||||
mov edx, button1
|
||||
int 0x40
|
||||
|
||||
mov eax, 8
|
||||
mov ebx, 80 shl 16 + 60
|
||||
mov ecx, 40 shl 16 + 15
|
||||
mov edx, 6
|
||||
mov esi, 0xd72189
|
||||
int 0x40
|
||||
mov eax, 4
|
||||
mov ebx, 82 shl 16 + 42
|
||||
mov ecx, 0x80000000
|
||||
mov edx, button2
|
||||
int 0x40
|
||||
|
||||
mov edi, input_box
|
||||
call edit_box.draw
|
||||
|
||||
; mov eax, 4
|
||||
; mov ebx, 10 shl 16 + 90
|
||||
; mov ecx, 0
|
||||
; mov edx, input_text
|
||||
; mov esi, [input_box + 38]
|
||||
; int 0x40
|
||||
; mov eax, esi
|
||||
;print "eax = edit etxt len"
|
||||
;pregs
|
||||
|
||||
|
||||
|
||||
mov eax, 12 ; finish drawing
|
||||
mov ebx, 2
|
||||
int 0x40
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; <--- initialised data --->
|
||||
DATA
|
||||
|
||||
format_id db 1
|
||||
|
||||
; buffer db 256 dup(0)
|
||||
|
||||
CLIP_BUFFER buffer, 256
|
||||
|
||||
input_text db 256 dup(0)
|
||||
input_box edit_box 100,10,70,0xffffff,0,0x00aaaaaa,0,255,input_text
|
||||
|
||||
; input_box edit_box 100,10,70,0xffffff,0,0xaaaaaa,0,\
|
||||
; 0xaaaaaa,0,255,input_text,ed_always_focus
|
||||
|
||||
head db "<22>ਬ¥à à ¡®âë á ¡ãä¥à®¬ ®¡¬¥ ",0
|
||||
text1 db "<22> ¦¨¬ ©â¥ æ¨äàë 0-9 ¤«ï ᬥë id ä®à¬ â ¤ ëå",0
|
||||
text2 db "‘¥©ç á ¢ë¡à id ä®à¬ â ¤ ëå: ",0
|
||||
|
||||
button1 db "Š®¯¨à®¢ âì",0
|
||||
button2 db "‚áâ ¢¨âì",0
|
||||
|
||||
; <--- uninitialised data --->
|
||||
UDATA
|
||||
|
||||
|
||||
MEOS_APP_END
|
||||
; <--- end of MenuetOS application --->
|
Reference in New Issue
Block a user