File: nopaste

package info (click to toggle)
epic4 1%3A3.0-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,756 kB
  • sloc: ansic: 56,285; makefile: 631; sh: 161; perl: 30
file content (49 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
load utime

on ^set "nopaste on" {
	@ nopaste.on = 1
	setup_nopaste
	xecho -b NOPASTE set to on
}

on ^set "nopaste off" {
	@ nopaste.on = 0
	remove_nopaste
	xecho -b NOPASTE set to off
}

alias setup_nopaste 
{
	@ nopaste.last = utime()
	@ nopaste.counter = 0
	on ?input * {
		if ([$[1]*] == [/]) {
			return 0
		}
		if ((:nc = strlen($*)) == 0) {
			return 0
		}
		@ :td = utime_sub($utime() $nopaste.last)
		@ :sec = word(0 $td)
		@ :usec = (sec * 1000000) + word(1 $td)
		@ nopaste.last = utime()

		@ :us = ((100000 - usec) / nc)
		@ nopaste.counter += us
		if (nopaste.counter < 0) {
			@ nopaste.counter = 0
		}
		if (nopaste.counter > 2500) {
			parsekey erase_line
			return 1
		} {
			return 0
		}
	}
}

alias remove_nopaste
{
	on input -*
}