tools/linelength.py

Wed, 25 May 2022 20:36:34 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 20:36:34 +0300
changeset 199
6988973515d2
parent 114
4e03b0e2a29f
permissions
-rwxr-xr-x

Fix pick() picking from weird places on the screen with high DPI scaling

glReadPixels reads data from the frame buffer, which contains data after
high DPI scaling, so any reads to that need to take this scaling into account

#!/usr/bin/env python3
import sys
def check(filename):
	with open(filename) as file:
		for linenumber, line in enumerate(file, 1):
			if line[-1] == '\n':
				line = line[:-1]
			line = str.replace(line, '\t', ' ' * 4)
			if len(line) > 120:
				print(str.format(
					'{filename}:{linenumber}: warning: line length exceeds 120 characters',
					filename = filename,
					linenumber = linenumber
				), file = sys.stderr)
def main():
	for filename in sys.argv[1:]:
		check(filename)
	return 0
if __name__ == '__main__':
	sys.exit(main())

mercurial