Commit 3585c67f9830628293344eac0d355eda35804e5f

Authored by Perry Werneck
1 parent 8b88ea8d
Exists in master and in 1 other branch develop

Isolating CG translation table.

src/include/internals.h
... ... @@ -142,6 +142,8 @@
142 142 /// @brief Add current lib3270 selection to a list
143 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 147 /*--[ Internal Widgets & Tools ]---------------------------------------------------------------------*/
146 148  
147 149 enum
... ...
src/include/v3270/actions.h
... ... @@ -43,18 +43,20 @@
43 43 V3270_ACTION_FLAG_CUT = 0x10000000,
44 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 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 54 guint key;
53 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 34 #include <lib3270/log.h>
35 35 #include <lib3270/trace.h>
36 36 #include <gdk/gdkkeysyms-compat.h>
  37 + #include <lib3270/selection.h>
37 38  
38 39 /*--[ Implement ]------------------------------------------------------------------------------------*/
39 40  
... ... @@ -92,6 +93,9 @@ gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event)
92 93 case GDK_SCROLL_RIGHT:
93 94 lib3270_move_selection(terminal->host,LIB3270_DIR_RIGHT);
94 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 257  
258 258 static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, GdkRectangle *rect)
259 259 {
260   - size_t ix;
261   -
262 260 // 0x00 is always blank.
263 261 if(!chr)
264 262 return TRUE;
... ... @@ -277,6 +275,7 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk
277 275 return TRUE;
278 276 }
279 277  
  278 + /*
280 279 // Check for UTF-8 CG - https://unicode.org/charts/PDF/U2300.pdf
281 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 291 { 0xb8, "÷" }, // Division Sign ÷
293 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 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 408 cairo_rel_line_to(cr,rect->width,0);
411 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 415 default:
414 416  
415 417 if(!draw_cg(cr, chr, font, rect))
  418 + {
416 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 }
... ...
src/terminal/font/translate.c 0 → 100644
... ... @@ -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 272 <Unit filename="src/terminal/font/properties.c">
273 273 <Option compilerVar="CC" />
274 274 </Unit>
  275 + <Unit filename="src/terminal/font/translate.c">
  276 + <Option compilerVar="CC" />
  277 + </Unit>
275 278 <Unit filename="src/terminal/get.c">
276 279 <Option compilerVar="CC" />
277 280 </Unit>
... ...