Skip to content

Instantly share code, notes, and snippets.

@unxed
unxed / kothic-leaflet.js
Created October 25, 2011 21:14
FileSystem API-based cache for Kothic-JS - v.0.02
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder;
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};
@unxed
unxed / kothic-leaflet.js
Created October 27, 2011 11:37
FileSystem API-based cache for Kothic-JS - v.0.03
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder;
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};
@unxed
unxed / kothic-leaflet.js
Created October 27, 2011 16:29
FileSystem API-based cache for Kothic-JS - v.0.04
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder;
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};
@unxed
unxed / index.html
Created October 27, 2011 16:31
sample code to show how to use tilelayer to draw tiles cached in local filesystem
<!doctype html>
<html>
<head>
<title>Сanvas-based OpenStreetMap</title>
<link rel="stylesheet" href="leaflet/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="leaflet/leaflet.ie.css" /><![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
// xkbcat: Logs X11 keypresses, globally.
#include <X11/XKBlib.h>
#include <X11/extensions/XInput2.h>
#include <xkbcommon/xkbcommon.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
// xkbcat: Logs X11 keypresses, globally.
#include <X11/XKBlib.h>
#include <X11/extensions/XInput2.h>
#include <xkbcommon/xkbcommon.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
size_t TTYInputSequenceParser::TryParseAsKittyEscapeSequence(const char *s, size_t l)
{
// kovidgoyal's kitty keyboard protocol (progressive enhancement flags 15) support
// CSI [ XXX : XXX : XXX ; XXX : XXX [u~ABCDEFHPQRS]
// some parts sometimes ommitted, see docs
// https://sw.kovidgoyal.net/kitty/keyboard-protocol/
// todo: enhanced key flag now set for essential keys only, should be set for more ones
// todo: add more keys. all needed by far2l seem to be here, but kitty supports much more
@unxed
unxed / gist:d979fe069039fe075c18eb0218b1f8f5
Last active September 1, 2024 04:11
Windows-compatible kitty keyboard protocol implementation; Public Domain
if (_kitty_kb_flags) {
// References:
// https://sw.kovidgoyal.net/kitty/keyboard-protocol/
// https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
char buffer[64] = {0};
const bool ctrl = (KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) != 0;
const bool alt = (KeyEvent.dwControlKeyState & (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED)) != 0;