Commit 3585c67f9830628293344eac0d355eda35804e5f
1 parent
8b88ea8d
Exists in
master
and in
1 other branch
Isolating CG translation table.
Showing
6 changed files
with
94 additions
and
12 deletions
Show diff stats
src/include/internals.h
| @@ -142,6 +142,8 @@ | @@ -142,6 +142,8 @@ | ||
| 142 | /// @brief Add current lib3270 selection to a list | 142 | /// @brief Add current lib3270 selection to a list |
| 143 | G_GNUC_INTERNAL GList * g_list_append_lib3270_selection(GList *list, H3270 *hSession, gboolean all); | 143 | G_GNUC_INTERNAL GList * g_list_append_lib3270_selection(GList *list, H3270 *hSession, gboolean all); |
| 144 | 144 | ||
| 145 | + G_GNUC_INTERNAL const gchar * v3270_translate_cg_to_utf(unsigned char chr); | ||
| 146 | + | ||
| 145 | /*--[ Internal Widgets & Tools ]---------------------------------------------------------------------*/ | 147 | /*--[ Internal Widgets & Tools ]---------------------------------------------------------------------*/ |
| 146 | 148 | ||
| 147 | enum | 149 | enum |
src/include/v3270/actions.h
| @@ -43,18 +43,20 @@ | @@ -43,18 +43,20 @@ | ||
| 43 | V3270_ACTION_FLAG_CUT = 0x10000000, | 43 | V3270_ACTION_FLAG_CUT = 0x10000000, |
| 44 | } V3270_ACTION_FLAGS; | 44 | } V3270_ACTION_FLAGS; |
| 45 | 45 | ||
| 46 | - typedef struct _v3270_action | 46 | + typedef struct _v3270_action V3270_ACTION; |
| 47 | + | ||
| 48 | + struct _v3270_action | ||
| 47 | { | 49 | { |
| 48 | LIB3270_PROPERTY_HEAD | 50 | LIB3270_PROPERTY_HEAD |
| 49 | 51 | ||
| 50 | - V3270_ACTION_FLAGS flags; ///< @brief (The flags for activation. | 52 | + V3270_ACTION_FLAGS flags; ///< @brief (The flags for activation). |
| 51 | 53 | ||
| 52 | guint key; | 54 | guint key; |
| 53 | GdkModifierType mods; | 55 | GdkModifierType mods; |
| 54 | 56 | ||
| 55 | - int (*activate)(const struct _v3270_action *action, GtkWidget *widget); | 57 | + int (*activate)(GtkWidget *widget, const V3270_ACTION *action); |
| 56 | 58 | ||
| 57 | - } V3270_ACTION; | 59 | + }; |
| 58 | 60 | ||
| 59 | 61 | ||
| 60 | /// | 62 | /// |
src/terminal/actions/scroll.c
| @@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
| 34 | #include <lib3270/log.h> | 34 | #include <lib3270/log.h> |
| 35 | #include <lib3270/trace.h> | 35 | #include <lib3270/trace.h> |
| 36 | #include <gdk/gdkkeysyms-compat.h> | 36 | #include <gdk/gdkkeysyms-compat.h> |
| 37 | + #include <lib3270/selection.h> | ||
| 37 | 38 | ||
| 38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 39 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 39 | 40 | ||
| @@ -92,6 +93,9 @@ gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event) | @@ -92,6 +93,9 @@ gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event) | ||
| 92 | case GDK_SCROLL_RIGHT: | 93 | case GDK_SCROLL_RIGHT: |
| 93 | lib3270_move_selection(terminal->host,LIB3270_DIR_RIGHT); | 94 | lib3270_move_selection(terminal->host,LIB3270_DIR_RIGHT); |
| 94 | return TRUE; | 95 | return TRUE; |
| 96 | + | ||
| 97 | + case GDK_SCROLL_SMOOTH: | ||
| 98 | + return FALSE; | ||
| 95 | } | 99 | } |
| 96 | 100 | ||
| 97 | } | 101 | } |
src/terminal/drawing/draw.c
| @@ -257,8 +257,6 @@ static void draw_small_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo | @@ -257,8 +257,6 @@ static void draw_small_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo | ||
| 257 | 257 | ||
| 258 | static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, GdkRectangle *rect) | 258 | static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, GdkRectangle *rect) |
| 259 | { | 259 | { |
| 260 | - size_t ix; | ||
| 261 | - | ||
| 262 | // 0x00 is always blank. | 260 | // 0x00 is always blank. |
| 263 | if(!chr) | 261 | if(!chr) |
| 264 | return TRUE; | 262 | return TRUE; |
| @@ -277,6 +275,7 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | @@ -277,6 +275,7 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | ||
| 277 | return TRUE; | 275 | return TRUE; |
| 278 | } | 276 | } |
| 279 | 277 | ||
| 278 | + /* | ||
| 280 | // Check for UTF-8 CG - https://unicode.org/charts/PDF/U2300.pdf | 279 | // Check for UTF-8 CG - https://unicode.org/charts/PDF/U2300.pdf |
| 281 | static const struct CharList | 280 | static const struct CharList |
| 282 | { | 281 | { |
| @@ -292,15 +291,14 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | @@ -292,15 +291,14 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | ||
| 292 | { 0xb8, "÷" }, // Division Sign ÷ | 291 | { 0xb8, "÷" }, // Division Sign ÷ |
| 293 | { 0x90, "⎕" }, // APL FUNCTIONAL SYMBOL QUAD | 292 | { 0x90, "⎕" }, // APL FUNCTIONAL SYMBOL QUAD |
| 294 | }; | 293 | }; |
| 294 | + */ | ||
| 295 | 295 | ||
| 296 | + const gchar * utf = v3270_translate_cg_to_utf(chr); | ||
| 296 | 297 | ||
| 297 | - for(ix = 0; ix < G_N_ELEMENTS(charlist); ix++) | 298 | + if(utf) |
| 298 | { | 299 | { |
| 299 | - if(chr == charlist[ix].chr) | ||
| 300 | - { | ||
| 301 | - v3270_draw_text(cr,rect,font,charlist[ix].utf); | ||
| 302 | - return TRUE; | ||
| 303 | - } | 300 | + v3270_draw_text(cr,rect,font,utf); |
| 301 | + return TRUE; | ||
| 304 | } | 302 | } |
| 305 | 303 | ||
| 306 | debug("%s: Unknown char 0x%02x",__FUNCTION__,(int) chr); | 304 | debug("%s: Unknown char 0x%02x",__FUNCTION__,(int) chr); |
| @@ -410,10 +408,18 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 | @@ -410,10 +408,18 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 | ||
| 410 | cairo_rel_line_to(cr,rect->width,0); | 408 | cairo_rel_line_to(cr,rect->width,0); |
| 411 | break; | 409 | break; |
| 412 | 410 | ||
| 411 | + case 0x90: // APL FUNCTIONAL SYMBOL QUAD | ||
| 412 | + cairo_rectangle(cr, rect->x+1, rect->y+1, rect->width-2, rect->height-2); | ||
| 413 | + break; | ||
| 414 | + | ||
| 413 | default: | 415 | default: |
| 414 | 416 | ||
| 415 | if(!draw_cg(cr, chr, font, rect)) | 417 | if(!draw_cg(cr, chr, font, rect)) |
| 418 | + { | ||
| 416 | lib3270_write_screen_trace(session,"I don't known how to draw CG character %02x\n",(int) chr); | 419 | lib3270_write_screen_trace(session,"I don't known how to draw CG character %02x\n",(int) chr); |
| 420 | + cairo_rectangle(cr, rect->x+1, rect->y+1, rect->width-2, rect->height-2); | ||
| 421 | + | ||
| 422 | + } | ||
| 417 | 423 | ||
| 418 | } | 424 | } |
| 419 | } | 425 | } |
| @@ -0,0 +1,65 @@ | @@ -0,0 +1,65 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + */ | ||
| 29 | + | ||
| 30 | + #include <config.h> | ||
| 31 | + #include "private.h" | ||
| 32 | + | ||
| 33 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
| 34 | + | ||
| 35 | +static const struct | ||
| 36 | +{ | ||
| 37 | + unsigned char chr; | ||
| 38 | + const gchar * utf; | ||
| 39 | +} cg_to_utf[] = | ||
| 40 | +{ | ||
| 41 | + { 0x8c, "≤" }, // CG 0xf7, less or equal "≤" | ||
| 42 | + { 0xae, "≥" }, // CG 0xd9, greater or equal "≥" | ||
| 43 | + { 0xbe, "≠" }, // CG 0xbe, not equal "≠" | ||
| 44 | + { 0xad, "[" }, // "[" | ||
| 45 | + { 0xbd, "]" }, // "]" | ||
| 46 | + { 0xb8, "÷" }, // Division Sign ÷ | ||
| 47 | + { 0x90, "⎕" }, // APL FUNCTIONAL SYMBOL QUAD | ||
| 48 | +}; | ||
| 49 | + | ||
| 50 | +const gchar * v3270_translate_cg_to_utf(unsigned char chr) | ||
| 51 | +{ | ||
| 52 | + size_t ix; | ||
| 53 | + | ||
| 54 | + if(!chr) | ||
| 55 | + return " "; | ||
| 56 | + | ||
| 57 | + for(ix = 0; ix < G_N_ELEMENTS(cg_to_utf); ix++) | ||
| 58 | + { | ||
| 59 | + if(chr == cg_to_utf[ix].chr) | ||
| 60 | + return cg_to_utf[ix].utf; | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + return NULL; | ||
| 65 | +} |
v3270.cbp
| @@ -272,6 +272,9 @@ | @@ -272,6 +272,9 @@ | ||
| 272 | <Unit filename="src/terminal/font/properties.c"> | 272 | <Unit filename="src/terminal/font/properties.c"> |
| 273 | <Option compilerVar="CC" /> | 273 | <Option compilerVar="CC" /> |
| 274 | </Unit> | 274 | </Unit> |
| 275 | + <Unit filename="src/terminal/font/translate.c"> | ||
| 276 | + <Option compilerVar="CC" /> | ||
| 277 | + </Unit> | ||
| 275 | <Unit filename="src/terminal/get.c"> | 278 | <Unit filename="src/terminal/get.c"> |
| 276 | <Option compilerVar="CC" /> | 279 | <Option compilerVar="CC" /> |
| 277 | </Unit> | 280 | </Unit> |