https://rosettacode.org/wiki/Clipboard_manager/display#M2000_Interpreter
Module Clipboard_Manager {
Declare SetWindowPos Lib "User32.SetWindowPos" {
Long hwnd, Long hWnd,
Long x, Long y,
Long nWidth, Long nHeight,
Long uFlags
}
title "", 0 ' hide console
font "Courier new"
mode 16.5
cls #003300, 0 ' paper color
pen #ccffdd
last1=""
s=stack
boolean pinme
declare Form1 form
declare button1 button form Form1
declare button2 button form Form1
Form1=>PreviewKey=true
function PureStr(a$){
if len(a$)>20 then a$=left$(a$,20)+"..."
=a$
}
function form1.mousemove (new MouseKey, ControlKeys, X, Y) {
if mouseKey<>0 and ControlKeys=0 then
move X, Y: Cursor !
select case Row
case 2 to 11
Form1=>SendScanCode ""+(row-1)
case 12
Form1=>SendScanCode "0"
end select
else
try {button1=>GetFocus}
end if
}
function Form1.KeyPreview(New &Char$) {
local where=val(Char$)
select case Char$
case "1" to "9"
try {
last1=stackitem$(s, where)
clipboard last1
Char$=""
}
case "0" ' for ten
try {
last1=stackitem$(s, 10)
clipboard last1
Char$=""
where=10
}
end select
if Char$="" then
Layer Form1 {
cls, 2
if len(S)>0 then
? $(,4)
for i=1 to len(s)
print i,". ";
if i=where then print "(clipboard): ";
print PureStr(stackitem$(s, i))
next
end if
refresh
}
end if
}
function button1.click {
Try {Clipboard !} ' clear clipboard
s=stack
last1=""
layer Form1 {
cls, 2
}
}
function button2.click {
if pinme then
button2=>caption="Pin Window"
layer Form1 {
Form1=>opacity 255
Call void SetWindowPos(hwnd, -2, 0, 0, 0, 0, 3)
}
else
button2=>caption="Unpin Window"
layer Form1 {
Form1=>opacity 192
Call void SetWindowPos(hwnd, -1, 0, 0, 0, 0, 3)
}
end if
pinme~
}
function Form1.Unload (new &cancel) {
if pinme then cancel=true: call local button2.click()
}
function button1.blink {
layer Form1 {
try {
last=clipboard$
if last<>"" then
if last<>last1 then
stack s {
push last
swap last, last1
while stack.size>10
shift 11: drop
end while
}
cls, 2
if len(S)>0 then
? $(,4)
for i=1 to len(s)
print i,". ";PureStr(stackitem$(s, i))
next
end if
refresh
end if
end if
}
}
}
Form1=>title="Clipboard List"
Form1=>move 3000,3000, 10000, 7000
button1=>default=true
button1=>move 600,6000,5300-2*600, 600
button2=>move 5300,6000,5300-2*600, 600
button1=>caption="Clear List"
button2=>caption="Pin Window"
button1=>blink=100 ' timer from button
method Form1, "show", true ' show modal - here listen evants and when we close the form we went to next statement.
title "M2000", 1 ' show again console
declare Form1 nothing
}
Clipboard_Manager

Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.