-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsdm.js
199 lines (174 loc) · 4.63 KB
/
sdm.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/* -*- Mode: JAVASCRIPT; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is tanasinn
*
* The Initial Developer of the Original Code is
* Hayaki Saito.
* Portions created by the Initial Developer are Copyright (C) 2010 - 2013
* the Initial Developer. All Rights Reserved.
*
* ***** END LICENSE BLOCK ***** */
"use strict";
/**
* @class SixelScrollingMode
*
* DECSDM - Sixel Scrolling Mode
*
* Sixel Scrolling
*
* When sixel scrolling is enabled, the sixel image begins at the top left of
* the active text position. A sixel image will scroll the display when the
* image reaches the bottom margin of the display (the image may also scroll
* off the top of the display). A graphics new line character (-) is sent
* immediately after the sixel dump, and the text cursor is set at the same
* position as the sixel cursor upon exiting sixel mode.
* With sixel scrolling disabled, the sixel image begins at the top left of
* the display. When the image reaches the bottom margin, the display does not
* scroll, and additional sixel commands are ignored. Upon exiting sixel mode,
* the text cursor is set at the same position as when sixel mode was entered.
*
* Default: Enable sixel scrolling (TODO: find the evidence)
*
* Format
*
* CSI ? 8 0 h
* 9/11 3/15 3/8 3/0 6/8
*
* Set: disable sixel scrolling.
*
* CSI ? 8 0 l
* 9/11 3/15 3/8 3/0 6/12
*
* Reset: enable sixel scrolling.
*
*/
var SixelScrollingMode = new Class().extends(Plugin);
SixelScrollingMode.definition = {
id: "sixel_scrolling_mode",
/** plugin information */
getInfo: function getInfo()
{
return {
name: _("Sixel Scrolling Mode"),
version: "0.1",
description: _("Switch between Sixel Scrolling Mode / Sixel Display Mode")
};
},
"[persistable] enabled_when_startup": true,
"[persistable] default_value": false,
_mode: null,
/** Installs itself.
* @param {InstallContext} context A InstallContext object.
*/
"[install]":
function install(context)
{
this._mode = this.default_value;
},
/** Uninstalls itself.
*/
"[uninstall]":
function uninstall()
{
this._mode = null;
},
/** Sixel Display Mode (DECSDM)
*/
"[subscribe('sequence/decset/80'), pnp]":
function activate()
{
this._mode = true;
// smooth scroll.
this.sendMessage("command/change-sixel-display-mode", true);
},
/** Sixel Scrolling Mode (DECSDM)
*/
"[subscribe('sequence/decrst/80'), pnp]":
function deactivate()
{
this._mode = false;
// smooth scroll.
this.sendMessage("command/change-sixel-display-mode", false);
},
/** Report mode
*/
"[subscribe('sequence/decrqm/80'), pnp]":
function report()
{
var mode = this._mode ? 1: 2,
message = "?80;" + mode + "$y";
this.sendMessage("command/send-sequence/csi", message);
},
/** on hard / soft reset
*/
"[subscribe('command/{soft | hard}-terminal-reset'), pnp]":
function reset(broker)
{
if (this.default_value) {
this.activate();
} else {
this.deactivate();
}
},
/**
* Serialize snd persist current state.
*/
"[subscribe('@command/backup'), type('Object -> Undefined'), pnp]":
function backup(context)
{
// serialize this plugin object.
context[this.id] = {
mode: this._mode,
};
},
/**
* Deserialize and restore stored state.
*/
"[subscribe('@command/restore'), type('Object -> Undefined'), pnp]":
function restore(context)
{
var data = context[this.id];
if (data) {
this._mode = data.mode;
} else {
coUtils.Debug.reportWarning(
_("Cannot restore last state: data not found."));
}
},
/** test */
"[test]":
function()
{
var enabled = this.enabled;
try {
this.enabled = false;
this.enabled = true;
this.enabled = false;
} finally {
this.enabled = enabled;
}
},
}; // class SixelScrollingMode
/**
* @fn main
* @brief Module entry point.
* @param {Broker} broker The Broker object.
*/
function main(broker)
{
new SixelScrollingMode(broker);
}
// EOF