mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-10-26 22:53:08 +00:00
GUACAMOLE-1820: Simplify unicode interpretation.
This commit is contained in:
@@ -62,9 +62,9 @@ Guacamole.KeyEventInterpreter = function KeyEventInterpreter(batchSeperation, st
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @private
|
* @private
|
||||||
* @param {KEY_DEFINITION|object} [template={}]
|
* @param {KeyDefinition|object} [template={}]
|
||||||
* The object whose properties should be copied within the new
|
* The object whose properties should be copied within the new
|
||||||
* KEY_DEFINITION.
|
* KeyDefinition.
|
||||||
*/
|
*/
|
||||||
var KeyDefinition = function KeyDefinition(template) {
|
var KeyDefinition = function KeyDefinition(template) {
|
||||||
|
|
||||||
@@ -278,38 +278,9 @@ Guacamole.KeyEventInterpreter = function KeyEventInterpreter(batchSeperation, st
|
|||||||
if (keysym < 0x00 || (keysym > 0xFF && (keysym | 0xFFFF) != 0x0100FFFF))
|
if (keysym < 0x00 || (keysym > 0xFF && (keysym | 0xFFFF) != 0x0100FFFF))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var codepoint = keysym & 0xFFFF;
|
|
||||||
var mask;
|
|
||||||
var bytes;
|
|
||||||
|
|
||||||
// Determine size and initial byte mask
|
|
||||||
if (codepoint <= 0x007F) {
|
|
||||||
mask = 0x00;
|
|
||||||
bytes = 1;
|
|
||||||
}
|
|
||||||
else if (codepoint <= 0x7FF) {
|
|
||||||
mask = 0xC0;
|
|
||||||
bytes = 2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mask = 0xE0;
|
|
||||||
bytes = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
var byteArray = new ArrayBuffer(bytes);
|
|
||||||
var byteView = new Int8Array(byteArray);
|
|
||||||
|
|
||||||
// Add trailing bytes, if any
|
|
||||||
for (var i = 1; i < bytes; i++) {
|
|
||||||
byteView[bytes - i] = 0x80 | (codepoint & 0x3F);
|
|
||||||
codepoint >>= 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set initial byte
|
|
||||||
byteView[0] = mask | codepoint;
|
|
||||||
|
|
||||||
// Convert to UTF8 string
|
// Convert to UTF8 string
|
||||||
var name = new TextDecoder("utf-8").decode(byteArray);
|
var codepoint = keysym & 0xFFFF;
|
||||||
|
var name = String.fromCharCode(codepoint);
|
||||||
|
|
||||||
// Create and return the definition
|
// Create and return the definition
|
||||||
return new KeyDefinition({keysym: keysym, name: name, value: name, modifier: false});
|
return new KeyDefinition({keysym: keysym, name: name, value: name, modifier: false});
|
||||||
@@ -482,7 +453,7 @@ Guacamole.KeyEventInterpreter = function KeyEventInterpreter(batchSeperation, st
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current batch of typed text. Note that the batch may be
|
* Return the current batch of typed text. Note that the batch may be
|
||||||
@@ -494,8 +465,8 @@ Guacamole.KeyEventInterpreter = function KeyEventInterpreter(batchSeperation, st
|
|||||||
*/
|
*/
|
||||||
this.getCurrentBatch = function getCurrentBatch() {
|
this.getCurrentBatch = function getCurrentBatch() {
|
||||||
return currentBatch;
|
return currentBatch;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A granular description of an extracted key event, including a human-readable
|
* A granular description of an extracted key event, including a human-readable
|
||||||
@@ -576,4 +547,4 @@ Guacamole.KeyEventInterpreter.KeyEventBatch = function KeyEventBatch(events, sim
|
|||||||
*/
|
*/
|
||||||
this.simpleValue = simpleValue || '';
|
this.simpleValue = simpleValue || '';
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ angular.module('player').directive('guacPlayer', ['$injector', function guacPlay
|
|||||||
// Convert to the display-optimized TextBatch type
|
// Convert to the display-optimized TextBatch type
|
||||||
$scope.textBatches.push(new TextBatch(batch));
|
$scope.textBatches.push(new TextBatch(batch));
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
// Notify listeners when current position within the recording
|
// Notify listeners when current position within the recording
|
||||||
// has changed
|
// has changed
|
||||||
|
|||||||
Reference in New Issue
Block a user