From 963beea3f3910879de4285dde9e6a11872468252 Mon Sep 17 00:00:00 2001 From: Simon Rawles Date: Mon, 2 May 2016 17:33:40 +0100 Subject: [PATCH 1/3] Handling of Hebrew. There are still problems when entering some escape codes. In order to enter Latin characters, the user must press a meta key, which often sets off browser keyboard shortcuts. --- teletext-editor.js | 53 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/teletext-editor.js b/teletext-editor.js index 191346b..ee8a6e4 100644 --- a/teletext-editor.js +++ b/teletext-editor.js @@ -1451,7 +1451,7 @@ this.keypress = function(event) { if ( placed_code > -1 ) { check_for_remove_code(curx,cury,1); place_code(curx, cury, placed_code, 1); - cursor_right(); + advance_cursor(); matched = 1; } @@ -1475,7 +1475,7 @@ this.keypress = function(event) { render(curx, cury+1, 1, 1); } // Move the cursor right (and render that) - cursor_right(); + advance_cursor(); } } else { // If we're in graphics mode... @@ -1526,7 +1526,7 @@ this.keypress = function(event) { gfx_change(curx, cury, curx, cury); // Move the cursor right. - cursor_right(); + advance_cursor(); } } } @@ -1548,6 +1548,13 @@ this.keypress = function(event) { // them separately. If split == 1, it's necessary to call the render // function twice. +var advance_cursor = function() { + // We might be in Hebrew mode. If so, advancing means to go + // left. Otherwise, it means to go right. + if ( cset == 6 ) { cursor_left_for_hebrew(); return; } + cursor_right(); +} + var cursor_right = function() { // The first cell that needs to be re-rendered is the original one. var old_curx = curx; var old_cury = cury; @@ -1568,6 +1575,22 @@ var cursor_right = function() { } } +// If we're using the editor in Hebrew mode, we need to move the cursor +// left. +var cursor_left_for_hebrew = function() { + var old_curx = curx; + var old_cury = cury; + var split = 1; + curx--; + if ( curx < 0 ) { cury++; curx = 39; } else { split = 0; } + if ( cury > 24 ) { cury = 0; } + if ( split == 0 ) { render(curx, cury, 2, 1, 1); } + if ( split == 1 ) { + render(old_curx, old_cury, 1, 1); + render(curx, cury, 1, 1); + } +} + // The other functions work in a similar way. var cursor_left = function() { var old_curx = curx; @@ -4093,14 +4116,22 @@ var init_font = function(charset) { var keymap = function(keypress) { + //console.log("[key] " + keypress); + + // The Hebrew character set (6) is identical to the English (0) + // one outside of the range 0x60..0x7b. + // English: pound sign if ( cset == 0 && keypress == 163 ) { return 0x23; } + if ( cset == 6 && keypress == 163 ) { return 0x23; } // English: hash if ( cset == 0 && keypress == 35 ) { return 0x5f; } + if ( cset == 6 && keypress == 35 ) { return 0x5f; } // English: long dash (underscore) if ( cset == 0 && keypress == 95 ) { return 0x60; } + if ( cset == 6 && keypress == 95 ) { return 0x60; } // German: capital A with umlaut if ( cset == 1 && keypress == 196 ) { return 0x5b; } @@ -4129,6 +4160,22 @@ var keymap = function(keypress) { // German: degree symbol if ( cset == 1 && keypress == 176 ) { return 0x60; } + // The Hebrew alphabet. + if ( cset == 6 && keypress >= 1488 && keypress <= 1514) { + return 0x60 + ( keypress - 1488 ); + } + + // There is no modern keyboard equivalent for the Israeli old + // shekel symbol, which fell out of general use in when the + // Israeli new shekel was introduced on 1 January 1986. The + // Israeli new shekel symbol is not in the teletext character + // set. When the new shekel symbol is entered, the old one + // will come out in the editor. + if ( cset == 6 && keypress == 8362 ) { + return 0x7b; + } + + return keypress; } From c03ac65a381ac7e663dae527ac1324cf12a77822 Mon Sep 17 00:00:00 2001 From: Simon Rawles Date: Mon, 2 May 2016 17:53:20 +0100 Subject: [PATCH 2/3] Just prevent the default action for a keypress between 0x20 and 0x7f always. --- teletext-editor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/teletext-editor.js b/teletext-editor.js index ee8a6e4..881c846 100644 --- a/teletext-editor.js +++ b/teletext-editor.js @@ -1302,10 +1302,10 @@ this.keypress = function(event) { // so return since we've already handled ESC in keydown if ( code == 27 ) { return; } - // Stop Firefox bringing up a search box when the apostrophe or - // slash key is pressed. - if ( code == 39 ) { event.preventDefault(); } - if ( code == 47 ) { event.preventDefault(); } + // Stop Firefox interpreting this keypress as a shortcut for the + // app. Non-Latin keyboards sometimes send Latin character keypresses + // if a meta key is pressed. + if ( code >= 32 && code < 128 ) { event.preventDefault(); } unhide_status_bar(); From b615150fb2783c1cbc9ae979f51962f23bd6ba60 Mon Sep 17 00:00:00 2001 From: Simon Rawles Date: Mon, 2 May 2016 18:42:09 +0100 Subject: [PATCH 3/3] A small renaming. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e42527..64d24bd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# teletext-editor +# The edit.tf teletext editor This is a teletext editor implemented in JavaScript, so that people now need no more than a JavaScript-enabled browser in order to create their