summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-07-19 23:16:29 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-07-19 23:16:29 (GMT)
commit5093663eb4e4aa17edd97cbd864ccb4a3d48a803 (patch)
tree48192ae6b37e1803d78ed81f5658ad9d2756cfd1
parent12abead3f60d6f72c0d41672af87215dfc13c8fc (diff)
Given their own structure to rendering options.
-rw-r--r--configure.ac2
-rw-r--r--src/analysis/Makefile.am1
-rw-r--r--src/analysis/binary.c101
-rw-r--r--src/analysis/binary.h3
-rw-r--r--src/analysis/loaded-int.h10
-rw-r--r--src/analysis/loaded.c48
-rw-r--r--src/analysis/loaded.h6
-rw-r--r--src/analysis/roptions.h101
-rw-r--r--src/glibext/Makefile.am1
-rw-r--r--src/glibext/gbuffercache.c6
-rw-r--r--src/glibext/gbuffercache.h3
-rw-r--r--src/glibext/gbufferline.c59
-rw-r--r--src/glibext/gbufferline.h11
-rw-r--r--src/glibext/gbufferview.c70
-rw-r--r--src/glibext/gbufferview.h15
-rw-r--r--src/glibext/gdisplayoptions.c (renamed from src/analysis/roptions.c)209
-rw-r--r--src/glibext/gdisplayoptions.h68
-rw-r--r--src/glibext/glinecursor.h6
-rw-r--r--src/glibext/gwidthtracker.c32
-rw-r--r--src/glibext/gwidthtracker.h5
-rw-r--r--src/gtkext/gtkblockdisplay.c8
-rw-r--r--src/gtkext/gtkbufferdisplay.c12
-rw-r--r--src/gtkext/gtkdisplaypanel-int.h2
-rw-r--r--src/gtkext/gtkdisplaypanel.c95
-rw-r--r--src/gui/menus/view.c19
25 files changed, 476 insertions, 417 deletions
diff --git a/configure.ac b/configure.ac
index 09af338..e2b9c97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -326,7 +326,7 @@ AC_SUBST(LIBPYGOBJECT_LIBS)
AC_CONFIG_FILES([stamp-h po/Makefile.in], [echo timestamp > stamp-h])
-AC_CONFIG_COMMANDS([marshal], [echo -e "VOID:UINT64\nVOID:INT,UINT64,INT\nVOID:OBJECT,OBJECT\nVOID:ENUM,OBJECT\nVOID:ENUM,ENUM\nVOID:BOOLEAN,UINT64\nVOID:BOOLEAN,ULONG,ULONG\nVOID:INT,INT\nVOID:OBJECT,BOOLEAN" > src/glibext/chrysamarshal.list])
+AC_CONFIG_COMMANDS([marshal], [echo -e "VOID:UINT64\nVOID:INT,UINT64,INT\nVOID:OBJECT,OBJECT\nVOID:ENUM,OBJECT\nVOID:ENUM,ENUM\nVOID:BOOLEAN,UINT64\nVOID:BOOLEAN,ULONG,ULONG\nVOID:INT,INT\nVOID:OBJECT,BOOLEAN\nVOID:ULONG,BOOLEAN" > src/glibext/chrysamarshal.list])
AC_CONFIG_FILES([Makefile
pixmaps/Makefile
diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am
index 20a02b6..3ba21a3 100644
--- a/src/analysis/Makefile.am
+++ b/src/analysis/Makefile.am
@@ -11,7 +11,6 @@ libanalysis_la_SOURCES = \
loaded.h loaded.c \
loading.h loading.c \
project.h project.c \
- roptions.h roptions.c \
routine.h routine.c \
type-int.h \
type.h type.c \
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 222bafc..89370b2 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -89,8 +89,7 @@ struct _GLoadedBinary
size_t decbuf_count; /* Taille des tableaux */
size_t defsrc; /* Fichier source principal */
- bool col_display[BVW_COUNT][BLC_DISPLAY];/* Position et code binaire */
- bool lines_display; /* Affichage des lignes */
+ GDisplayOptions *options[BVW_COUNT]; /* Options d'affichage */
};
@@ -173,10 +172,7 @@ static GtkWidget *g_loaded_binary_build_view(GLoadedBinary *, unsigned int);
static unsigned int g_loaded_binary_get_view_index(GLoadedBinary *, GtkWidget *);
/* Fournit toutes les options d'affichage pour un contenu. */
-bool * const g_loaded_binary_get_all_display_options(const GLoadedBinary *, unsigned int);
-
-/* Définit une option d'affichage pour un contenu chargé. */
-static bool g_loaded_binary_set_display_option(GLoadedBinary *, unsigned int, unsigned int, bool);
+static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary *, unsigned int);
@@ -242,14 +238,17 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
binary->collections = create_collections_list();
attach_binary_to_collections(binary->collections, binary);
- binary->col_display[BVW_BLOCK][BLC_PHYSICAL] = true;
- binary->col_display[BVW_BLOCK][BLC_VIRTUAL] = true;
- binary->col_display[BVW_BLOCK][BLC_BINARY] = false;
- binary->col_display[BVW_GRAPH][BLC_PHYSICAL] = false;
- binary->col_display[BVW_GRAPH][BLC_VIRTUAL] = false;
- binary->col_display[BVW_GRAPH][BLC_BINARY] = false;
+ binary->options[BVW_BLOCK] = g_display_options_new();
+
+ g_display_options_add(binary->options[BVW_BLOCK], _("Physical offset"), true);
+ g_display_options_add(binary->options[BVW_BLOCK], _("Virtual address"), true);
+ g_display_options_add(binary->options[BVW_BLOCK], _("Binary code"), false);
+
+ binary->options[BVW_GRAPH] = g_display_options_new();
- binary->lines_display = true;
+ g_display_options_add(binary->options[BVW_GRAPH], _("Physical offset"), false);
+ g_display_options_add(binary->options[BVW_GRAPH], _("Virtual address"), false);
+ g_display_options_add(binary->options[BVW_GRAPH], _("Binary code"), false);
}
@@ -282,8 +281,7 @@ static void g_loaded_binary_interface_init(GLoadedContentInterface *iface)
iface->build_view = (build_loaded_view_fc)g_loaded_binary_build_view;
iface->get_view_index = (get_loaded_view_index_fc)g_loaded_binary_get_view_index;
- iface->get_all_options = (get_all_loaded_options_fc)g_loaded_binary_get_all_display_options;
- iface->set_option = (set_loaded_option_fc)g_loaded_binary_set_display_option;
+ iface->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options;
}
@@ -302,6 +300,8 @@ static void g_loaded_binary_interface_init(GLoadedContentInterface *iface)
static void g_loaded_binary_dispose(GLoadedBinary *binary)
{
+ BinaryView i; /* Boucle de parcours */
+
if (binary->format != NULL)
g_object_unref(G_OBJECT(binary->format));
@@ -310,6 +310,11 @@ static void g_loaded_binary_dispose(GLoadedBinary *binary)
/* TODO... */
+
+
+ for (i = 0; i < BVW_COUNT; i++)
+ g_object_unref(G_OBJECT(binary->options[i]));
+
G_OBJECT_CLASS(g_loaded_binary_parent_class)->dispose(G_OBJECT(binary));
}
@@ -1379,25 +1384,6 @@ GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *binary,
#endif
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à consulter. *
-* *
-* Description : Indique si les lignes doivent apparaître dans le rendu. *
-* *
-* Retour : Consigne d'affichage. [OUT] *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool *g_loaded_binary_display_decomp_lines(GLoadedBinary *binary)
-{
- return &binary->lines_display;
-
-}
-
-
/* ---------------------------------------------------------------------------------- */
/* GESTION SOUS FORME DE CONTENU CHARGE */
@@ -1536,6 +1522,7 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS
GBinFormat *format; /* Format lié au binaire */
const char *arch; /* Architecture d'exécution */
const char *desc; /* Description humaine associée*/
+ bool has_virt; /* Présence de virtuel ? */
GProcContext *context; /* Contexte de suivi dédié */
GWidthTracker *tracker; /* Gestionnaire de largeur */
@@ -1567,7 +1554,10 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS
goto glba_exit;
}
- binary->col_display[BVW_BLOCK][BLC_VIRTUAL] = g_arch_processor_has_virtual_space(binary->proc);
+ has_virt = g_arch_processor_has_virtual_space(binary->proc);
+
+ g_display_options_set(binary->options[BVW_BLOCK], BLC_VIRTUAL, has_virt);
+ g_display_options_set(binary->options[BVW_GRAPH], BLC_VIRTUAL, has_virt);
/* Phase de désassemblage pur */
@@ -1741,42 +1731,19 @@ static unsigned int g_loaded_binary_get_view_index(GLoadedBinary *binary, GtkWid
* *
******************************************************************************/
-bool * const g_loaded_binary_get_all_display_options(const GLoadedBinary *binary, unsigned int index)
+static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary *binary, unsigned int index)
{
- return binary->col_display[index];
-
-}
+ GDisplayOptions *result; /* Instance à renvoyer */
+ assert(index < BVW_COUNT);
-/******************************************************************************
-* *
-* Paramètres : binary = contenu chargé à consulter. *
-* index = composant graphique à cibler. *
-* option = type de paramètre à manipuler. *
-* state = valeur dudit paramètre. *
-* *
-* Description : Définit une option d'affichage pour un contenu chargé. *
-* *
-* Retour : true si un changement a été effectué, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_loaded_binary_set_display_option(GLoadedBinary *binary, unsigned int index, unsigned int option, bool state)
-{
- bool result; /* Variation à faire remonter */
- bool old; /* Ancien état à remplacer */
-
- old = binary->col_display[index][option];
-
- if (state != old)
- {
- binary->col_display[index][option] = state;
- result = true;
- }
+ if (index < BVW_COUNT)
+ result = binary->options[index];
+ else
+ result = NULL;
- else result = false;
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
return result;
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 906469a..cbaab41 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -167,9 +167,6 @@ GBufferCache *g_loaded_binary_get_disassembled_cache(const GLoadedBinary *);
/* Fournit le tampon associé au contenu d'un fichier source. */
//GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *, size_t);
-/* Indique si les lignes doivent apparaître dans le rendu. */
-bool *g_loaded_binary_display_decomp_lines(GLoadedBinary *);
-
diff --git a/src/analysis/loaded-int.h b/src/analysis/loaded-int.h
index 7d4bb19..044dad7 100644
--- a/src/analysis/loaded-int.h
+++ b/src/analysis/loaded-int.h
@@ -58,10 +58,7 @@ typedef GtkWidget * (* build_loaded_view_fc) (GLoadedContent *, unsigned int);
typedef unsigned int (* get_loaded_view_index_fc) (GLoadedContent *, GtkWidget *);
/* Fournit toutes les options d'affichage pour un contenu. */
-typedef bool * const (* get_all_loaded_options_fc) (const GLoadedContent *, unsigned int);
-
-/* Définit une option d'affichage pour un contenu. */
-typedef bool ( * set_loaded_option_fc) (GLoadedContent *, unsigned int, unsigned int, bool);
+typedef GDisplayOptions * (* get_loaded_options_fc) (const GLoadedContent *, unsigned int);
/* Accès à un contenu binaire quelconque (interface) */
@@ -85,15 +82,12 @@ struct _GLoadedContentIface
build_loaded_view_fc build_view; /* Mise en place de vues */
get_loaded_view_index_fc get_view_index;/* Récupération d'indice de vue*/
- get_all_loaded_options_fc get_all_options; /* Obtention de liste brute*/
- set_loaded_option_fc set_option; /* Définition d'affichage */
+ get_loaded_options_fc get_options; /* Obtention de liste d'options*/
/* Signaux */
void (* analyzed) (GLoadedContent *, gboolean);
- void (* display_changed) (GLoadedContent *, unsigned int, unsigned int);
-
};
diff --git a/src/analysis/loaded.c b/src/analysis/loaded.c
index 5359103..28aea43 100644
--- a/src/analysis/loaded.c
+++ b/src/analysis/loaded.c
@@ -135,14 +135,6 @@ static void g_loaded_content_default_init(GLoadedContentInterface *iface)
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
- g_signal_new("display-changed",
- G_TYPE_LOADED_CONTENT,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GLoadedContentIface, display_changed),
- NULL, NULL,
- g_cclosure_user_marshal_VOID__ENUM_ENUM,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
-
}
@@ -471,60 +463,28 @@ unsigned int g_loaded_content_get_view_index(GLoadedContent *content, GtkWidget
* *
* Description : Fournit toutes les options d'affichage pour un contenu. *
* *
-* Retour : Tableau de paramètres en accès libre. *
+* Retour : Gestionnaire de paramètres. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool * const g_loaded_content_get_all_display_options(const GLoadedContent *content, unsigned int index)
+GDisplayOptions *g_loaded_content_get_display_options(const GLoadedContent *content, unsigned int index)
{
- bool const *result; /* Accès aux options à renvoyer*/
+ GDisplayOptions *result; /* Accès aux options à renvoyer*/
GLoadedContentIface *iface; /* Interface utilisée */
assert(index <= g_loaded_content_count_views(content));
iface = G_LOADED_CONTENT_GET_IFACE(content);
- result = iface->get_all_options(content, index);
+ result = iface->get_options(content, index);
return result;
}
-/******************************************************************************
-* *
-* Paramètres : content = contenu chargé à consulter. *
-* index = composant graphique à cibler. *
-* option = type de paramètre à manipuler. *
-* state = valeur dudit paramètre. *
-* *
-* Description : Définit une option d'affichage pour un contenu chargé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_loaded_content_set_display_option(GLoadedContent *content, unsigned int index, unsigned int option, bool state)
-{
- GLoadedContentIface *iface; /* Interface utilisée */
- bool changed; /* Note un changement */
-
- assert(index <= g_loaded_content_count_views(content));
-
- iface = G_LOADED_CONTENT_GET_IFACE(content);
-
- changed = iface->set_option(content, index, option, state);
-
- if (changed)
- g_signal_emit_by_name(content, "display-changed", index, option);
-
-}
-
-
/* ---------------------------------------------------------------------------------- */
/* PHASE D'ANALYSE EN PARALLELE */
diff --git a/src/analysis/loaded.h b/src/analysis/loaded.h
index 344d102..66d448a 100644
--- a/src/analysis/loaded.h
+++ b/src/analysis/loaded.h
@@ -32,6 +32,7 @@
#include "content.h"
#include "../common/xml.h"
+#include "../glibext/gdisplayoptions.h"
#include "../gtkext/gtkdockstation.h"
@@ -93,10 +94,7 @@ GtkWidget *g_loaded_content_build_view(GLoadedContent *, unsigned int);
unsigned int g_loaded_content_get_view_index(GLoadedContent *, GtkWidget *);
/* Fournit toutes les options d'affichage pour un contenu. */
-bool * const g_loaded_content_get_all_display_options(const GLoadedContent *, unsigned int);
-
-/* Définit une option d'affichage pour un contenu chargé. */
-void g_loaded_content_set_display_option(GLoadedContent *, unsigned int, unsigned int, bool);
+GDisplayOptions *g_loaded_content_get_display_options(const GLoadedContent *, unsigned int);
diff --git a/src/analysis/roptions.h b/src/analysis/roptions.h
deleted file mode 100644
index 1f27ff5..0000000
--- a/src/analysis/roptions.h
+++ /dev/null
@@ -1,101 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * roptions.h - prototypes pour les options de rendus des lignes de code
- *
- * Copyright (C) 2009-2017 Cyrille Bagard
- *
- * This file is part of Chrysalide.
- *
- * Chrysalide is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Chrysalide is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _ANALYSIS_ROPTIONS_H
-#define _ANALYSIS_ROPTIONS_H
-
-
-#include <glib-object.h>
-#include <stdbool.h>
-
-
-#include "../arch/processor.h"
-#include "../format/executable.h"
-
-
-
-/* Support principal de rendu */
-typedef enum _MainRendering
-{
- MRD_BLOCK, /* Unique bloc de code */
- MRD_GRAPH, /* Graphique de blocs de code */
-
- MRD_COUNT
-
-} MainRendering;
-
-
-/* Zone de rendu */
-typedef enum _ShowingArea
-{
- SAR_ADDRESS, /* Adresse d'une ligne */
- SAR_CODE, /* Code brut d'une ligne */
- SAR_INSTRUCTION, /* Instruction d'une ligne */
-
- SAR_COUNT
-
-} ShowingArea;
-
-
-#define G_TYPE_RENDERING_OPTIONS g_rendering_options_get_type()
-#define G_RENDERING_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_RENDERING_OPTIONS, GRenderingOptions))
-#define G_IS_RENDERING_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_RENDERING_OPTIONS))
-#define G_RENDERING_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_RENDERING_OPTIONS, GRenderingOptionsClass))
-#define G_IS_RENDERING_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_RENDERING_OPTIONS))
-#define G_RENDERING_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_RENDERING_OPTIONS, GRenderingOptionsClass))
-
-
-/* Options de représentation (instance) */
-typedef struct _GRenderingOptions GRenderingOptions;
-
-/* Options de représentation (classe) */
-typedef struct _GRenderingOptionsClass GRenderingOptionsClass;
-
-
-/* Indique le type défini pour des options de représentation. */
-GType g_rendering_options_get_type(void);
-
-/* Crée un un groupe d'options pour le rendu des lignes. */
-GRenderingOptions *g_rendering_options_new(GExeFormat *);
-
-/* Fournit le format du contenu binaire représenté. */
-GExeFormat *g_rendering_options_get_format(const GRenderingOptions *);
-
-/* Fournit l'architecture du contenu binaire représenté. */
-GArchProcessor *g_rendering_options_get_processor(const GRenderingOptions *);
-
-/* Affiche (ou non) les adresses des instructions. */
-void g_rendering_options_show_address(GRenderingOptions *, MainRendering, bool);
-
-/* Indique si les adresses des instructions sont à afficher. */
-bool g_rendering_options_has_to_show_address(const GRenderingOptions *, MainRendering);
-
-/* Affiche (ou non) le code des instructions. */
-void g_rendering_options_show_code(GRenderingOptions *, MainRendering, bool);
-
-/* Indique si le code des instructions est à afficher. */
-bool g_rendering_options_has_to_show_code(const GRenderingOptions *, MainRendering);
-
-
-
-#endif /* _ANALYSIS_ROPTIONS_H */
diff --git a/src/glibext/Makefile.am b/src/glibext/Makefile.am
index 9efc138..f2292d9 100644
--- a/src/glibext/Makefile.am
+++ b/src/glibext/Makefile.am
@@ -13,6 +13,7 @@ libglibext_la_SOURCES = \
gbuffercache.h gbuffercache.c \
gbufferline.h gbufferline.c \
gbufferview.h gbufferview.c \
+ gdisplayoptions.h gdisplayoptions.c \
glinecursor-int.h \
glinecursor.h glinecursor.c \
gloadedpanel-int.h \
diff --git a/src/glibext/gbuffercache.c b/src/glibext/gbuffercache.c
index 91f3a6d..7293e7c 100644
--- a/src/glibext/gbuffercache.c
+++ b/src/glibext/gbuffercache.c
@@ -1415,7 +1415,7 @@ void g_buffer_cache_collect_widths(GBufferCache *cache, size_t index, line_width
* first = première ligne à dessiner. *
* last = dernière ligne à dessiner. *
* area = position et surface à traiter. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* selected = ordonnée d'une ligne sélectionnée ou NULL. *
* list = liste de contenus à mettre en évidence. *
* *
@@ -1427,7 +1427,7 @@ void g_buffer_cache_collect_widths(GBufferCache *cache, size_t index, line_width
* *
******************************************************************************/
-void g_buffer_cache_draw(const GBufferCache *cache, cairo_t *cr, size_t first, size_t last, const cairo_rectangle_int_t *area, const bool *display, const gint *selected, const segcnt_list *list)
+void g_buffer_cache_draw(const GBufferCache *cache, cairo_t *cr, size_t first, size_t last, const cairo_rectangle_int_t *area, const GDisplayOptions *options, const gint *selected, const segcnt_list *list)
{
GBufferCacheClass *class; /* Classe des tampons */
gint y; /* Point de départ en ordonnée */
@@ -1465,7 +1465,7 @@ void g_buffer_cache_draw(const GBufferCache *cache, cairo_t *cr, size_t first, s
line = get_cache_info_line(info, i, cache->content);
- g_buffer_line_draw(line, cr, &summary, class->text_pos, y, display, list);
+ g_buffer_line_draw(line, cr, &summary, class->text_pos, y, options, list);
g_object_unref(G_OBJECT(line));
diff --git a/src/glibext/gbuffercache.h b/src/glibext/gbuffercache.h
index 453588e..7a0d250 100644
--- a/src/glibext/gbuffercache.h
+++ b/src/glibext/gbuffercache.h
@@ -30,6 +30,7 @@
#include <gdk/gdk.h>
+#include "gdisplayoptions.h"
#include "gwidthtracker.h"
#include "linegen.h"
@@ -102,7 +103,7 @@ GBufferLine *g_buffer_cache_find_line_by_index(const GBufferCache *, size_t);
void g_buffer_cache_collect_widths(GBufferCache *, size_t, line_width_summary *);
/* Imprime une partie choisie du tampon contenant des lignes. */
-void g_buffer_cache_draw(const GBufferCache *, cairo_t *, size_t, size_t, const cairo_rectangle_int_t *, const bool *, const gint *, const segcnt_list *);
+void g_buffer_cache_draw(const GBufferCache *, cairo_t *, size_t, size_t, const cairo_rectangle_int_t *, const GDisplayOptions *, const gint *, const segcnt_list *);
/* Indique l'indice correspondant à une adresse donnée. */
size_t _g_buffer_cache_find_index_by_cursor(const GBufferCache *, const GLineCursor *, bool, size_t, size_t);
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index 95af21a..39ef0ce 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -1050,7 +1050,7 @@ const line_segment *g_buffer_line_get_segment_from_coord(const GBufferLine *line
* *
* Paramètres : line = ligne à venir consulter. *
* summary = résumé des largeurs maximales. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* base = position jusqu'au segment trouvé. [OUT] *
* offset = position à la colonne visée. [OUT] *
* dir = direction d'un éventuel déplacement en cours. *
@@ -1065,12 +1065,13 @@ const line_segment *g_buffer_line_get_segment_from_coord(const GBufferLine *line
* *
******************************************************************************/
-bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summary *summary, const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force, col_coord_t *coord)
+bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summary *summary, const GDisplayOptions *options, gint *base, gint *offset, GdkScrollDirection dir, bool force, col_coord_t *coord)
{
bool result; /* Bilan à retourner */
BufferLineColumn last; /* Dernière colonne remplie */
gint last_base; /* Dernière abscisse associée */
- BufferLineColumn i; /* Boucle de parcours */
+ size_t count; /* Qté de colonnes en option */
+ size_t i; /* Boucle de parcours */
gint width; /* Largeur d'une colonne donnée*/
gint limit; /* Limite d'appartenance */
gint consumed; /* Distance vers le segment */
@@ -1085,9 +1086,15 @@ bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summar
/* On cible déjà la colonne idéale */
+ count = g_display_options_count(options);
+
for (i = 0; i < BLC_COUNT; i++)
{
- if (i < BLC_DISPLAY && !display[i]) continue;
+ if (i < count)
+ {
+ if (!g_display_options_get(options, i))
+ continue;
+ }
/* Mémorisation de la dernière colonne contenant quelque chose... */
if (get_column_width(&line->columns[i]) > 0)
@@ -1249,7 +1256,7 @@ bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summar
* *
* Paramètres : line = ligne à venir consulter. *
* summary = résumé des largeurs maximales. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* base = position jusqu'au segment trouvé. [OUT] *
* offset = position à la colonne visée. [OUT] *
* dir = direction d'un éventuel déplacement en cours. *
@@ -1263,13 +1270,13 @@ bool g_buffer_line_get_coord_at(const GBufferLine *line, const line_width_summar
* *
******************************************************************************/
-const line_segment *g_buffer_line_get_segment_at(const GBufferLine *line, const line_width_summary *summary, const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force)
+const line_segment *g_buffer_line_get_segment_at(const GBufferLine *line, const line_width_summary *summary, const GDisplayOptions *options, gint *base, gint *offset, GdkScrollDirection dir, bool force)
{
const line_segment *result; /* Trouvaille à retourner */
col_coord_t coord; /* Emplacement du contenu visé */
bool status; /* Bilan de la localisation */
- status = g_buffer_line_get_coord_at(line, summary, display, base, offset, dir, force, &coord);
+ status = g_buffer_line_get_coord_at(line, summary, options, base, offset, dir, force, &coord);
if (status)
result = g_buffer_line_get_segment_from_coord(line, &coord);
@@ -1285,7 +1292,7 @@ const line_segment *g_buffer_line_get_segment_at(const GBufferLine *line, const
* *
* Paramètres : line = ligne à venir consulter. *
* summary = résumé des largeurs maximales. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* base = position jusqu'au segment trouvé. [OUT] *
* offset = position à la colonne visée. [OUT] *
* dir = direction d'un éventuel déplacement en cours. *
@@ -1299,7 +1306,7 @@ const line_segment *g_buffer_line_get_segment_at(const GBufferLine *line, const
* *
******************************************************************************/
-GObject *g_buffer_line_get_creator_at(const GBufferLine *line, const line_width_summary *summary, const bool *display, gint *base, gint *offset, GdkScrollDirection dir, bool force)
+GObject *g_buffer_line_get_creator_at(const GBufferLine *line, const line_width_summary *summary, const GDisplayOptions *options, gint *base, gint *offset, GdkScrollDirection dir, bool force)
{
GObject *result; /* Trouvaille à retourner */
col_coord_t target; /* Emplacement du contenu visé */
@@ -1309,7 +1316,7 @@ GObject *g_buffer_line_get_creator_at(const GBufferLine *line, const line_width_
result = NULL;
- status = g_buffer_line_get_coord_at(line, summary, display, base, offset, dir, force, &target);
+ status = g_buffer_line_get_coord_at(line, summary, options, base, offset, dir, force, &target);
if (status)
{
@@ -1337,7 +1344,7 @@ GObject *g_buffer_line_get_creator_at(const GBufferLine *line, const line_width_
* Paramètres : line = ligne à venir consulter. *
* coord = cordonnées à consulter puis renseigner. [OUT] *
* summary = résumé des largeurs maximales. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* dir = orientation des recherches. *
* offset = décalage pour amener à l'extrémité nouvelle. [OUT] *
* *
@@ -1349,12 +1356,13 @@ GObject *g_buffer_line_get_creator_at(const GBufferLine *line, const line_width_
* *
******************************************************************************/
-bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord, const line_width_summary *summary, const bool *display, GdkScrollDirection dir, gint *offset)
+bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord, const line_width_summary *summary, const GDisplayOptions *options, GdkScrollDirection dir, gint *offset)
{
bool result; /* Bilan à retourner */
- BufferLineColumn i; /* Boucle de parcours #1 */
+ size_t count; /* Qté de colonnes en option */
+ size_t i; /* Boucle de parcours #1 */
bool displayed; /* Confort de lecture */
- BufferLineColumn k; /* Boucle de parcours #2 */
+ size_t k; /* Boucle de parcours #2 */
gint width; /* Largeur d'une colonne donnée*/
result = false;
@@ -1369,6 +1377,8 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord,
/* Recherche dans la direction des colonnes voisines */
+ count = g_display_options_count(options);
+
if (!result)
switch (dir)
{
@@ -1380,7 +1390,7 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord,
/* On s'assure que la colonne précédente est visible et peuplée */
for (; i > BLC_FIRST && !result; i--)
{
- displayed = (i <= BLC_DISPLAY ? display[i - 1] : true);
+ displayed = (i <= count ? g_display_options_get(options, i - 1) : true);
if (displayed)
{
@@ -1400,7 +1410,7 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord,
/* On s'assure que la colonne suivante est visible et peuplée */
for (; (i + 1) < BLC_COUNT && !result; i++)
{
- displayed = ((i + 1) < BLC_DISPLAY ? display[i + 1] : true);
+ displayed = ((i + 1) < count ? g_display_options_get(options, i + 1) : true);
if (displayed)
{
@@ -1428,7 +1438,7 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord,
for (k = 0; k < i; k++)
{
- displayed = (k < BLC_DISPLAY ? display[k] : true);
+ displayed = (k < count ? g_display_options_get(options, k) : true);
if (displayed)
{
@@ -1473,7 +1483,7 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord,
* summary = résumé des largeurs maximales. *
* x_init = abscisse du point d'impression de départ. *
* y = ordonnée du point d'impression. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* list = liste de contenus à mettre en évidence. *
* *
* Description : Imprime la ligne de texte représentée. *
@@ -1484,12 +1494,13 @@ bool g_buffer_line_find_near_coord(const GBufferLine *line, col_coord_t *coord,
* *
******************************************************************************/
-void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const line_width_summary *summary, gint x_init, gint y, const bool *display, const segcnt_list *list)
+void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const line_width_summary *summary, gint x_init, gint y, const GDisplayOptions *options, const segcnt_list *list)
{
GBufferLineClass *class; /* Stockage de briques de base */
bool has_src_surface; /* Note une présence définie */
gint x; /* Point de départ d'impression*/
- BufferLineColumn i; /* Boucle de parcours */
+ size_t count; /* Qté de colonnes en option */
+ size_t i; /* Boucle de parcours */
gint max_width; /* Largeur maximale de colonne */
if (line->flags != BLF_NONE && line->flags != BLF_HAS_CODE)
@@ -1516,9 +1527,15 @@ void g_buffer_line_draw(GBufferLine *line, cairo_t *cairo, const line_width_summ
x = x_init;
+ count = g_display_options_count(options);
+
for (i = 0; i < BLC_COUNT; i++)
{
- if (i < BLC_DISPLAY && !display[i]) continue;
+ if (i < count)
+ {
+ if (!g_display_options_get(options, i))
+ continue;
+ }
draw_line_column_segments(&line->columns[i], cairo, x, y, list);
diff --git a/src/glibext/gbufferline.h b/src/glibext/gbufferline.h
index 835c0dd..21b3ec9 100644
--- a/src/glibext/gbufferline.h
+++ b/src/glibext/gbufferline.h
@@ -29,6 +29,7 @@
#include <stdbool.h>
+#include "gdisplayoptions.h"
#include "linesegment.h"
#include "../analysis/content.h"
#include "../arch/vmpa.h"
@@ -198,19 +199,19 @@ gint g_buffer_line_compute_max_width(const GBufferLine *, BufferLineColumn, cons
const line_segment *g_buffer_line_get_segment_from_coord(const GBufferLine *, const col_coord_t *);
/* Fournit les coordonnées correspondant à une abscisse donnée. */
-bool g_buffer_line_get_coord_at(const GBufferLine *, const line_width_summary *, const bool *, gint *, gint *, GdkScrollDirection, bool, col_coord_t *);
+bool g_buffer_line_get_coord_at(const GBufferLine *, const line_width_summary *, const GDisplayOptions *, gint *, gint *, GdkScrollDirection, bool, col_coord_t *);
/* Donne le segment présent à une abscisse donnée. */
-const line_segment *g_buffer_line_get_segment_at(const GBufferLine *, const line_width_summary *, const bool *, gint *, gint *, GdkScrollDirection, bool);
+const line_segment *g_buffer_line_get_segment_at(const GBufferLine *, const line_width_summary *, const GDisplayOptions *, gint *, gint *, GdkScrollDirection, bool);
/* Donne le créateur présent à une abscisse donnée. */
-GObject *g_buffer_line_get_creator_at(const GBufferLine *, const line_width_summary *, const bool *, gint *, gint *, GdkScrollDirection, bool);
+GObject *g_buffer_line_get_creator_at(const GBufferLine *, const line_width_summary *, const GDisplayOptions *, gint *, gint *, GdkScrollDirection, bool);
/* Fournit des coordonnées voisines selon une direction donnée. */
-bool g_buffer_line_find_near_coord(const GBufferLine *, col_coord_t *, const line_width_summary *, const bool *, GdkScrollDirection, gint *);
+bool g_buffer_line_find_near_coord(const GBufferLine *, col_coord_t *, const line_width_summary *, const GDisplayOptions *, GdkScrollDirection, gint *);
/* Imprime la ligne de texte représentée. */
-void g_buffer_line_draw(GBufferLine *, cairo_t *, const line_width_summary *, gint, gint, const bool *, const segcnt_list *);
+void g_buffer_line_draw(GBufferLine *, cairo_t *, const line_width_summary *, gint, gint, const GDisplayOptions *, const segcnt_list *);
diff --git a/src/glibext/gbufferview.c b/src/glibext/gbufferview.c
index c5bd81e..f3b0147 100644
--- a/src/glibext/gbufferview.c
+++ b/src/glibext/gbufferview.c
@@ -77,10 +77,10 @@ static void g_buffer_view_finalize(GBufferView *);
static void on_buffer_cache_size_changed(const GBufferCache *, bool, size_t, size_t, GBufferView *);
/* Calcule la position idéale de curseur pour un point donné. */
-bool _g_buffer_view_compute_caret_full(GBufferView *, gint, GBufferLine *, size_t, const bool *, cairo_rectangle_int_t *, GLineCursor **);
+bool _g_buffer_view_compute_caret_full(GBufferView *, gint, GBufferLine *, size_t, const GDisplayOptions *, cairo_rectangle_int_t *, GLineCursor **);
/* Déplace le curseur au sein d'une vue de tampon. */
-static bool _g_buffer_view_move_caret(GBufferView *, const GBufferLine *, size_t, cairo_rectangle_int_t *, bool, GdkScrollDirection, const bool *);
+static bool _g_buffer_view_move_caret(GBufferView *, const GBufferLine *, size_t, cairo_rectangle_int_t *, bool, GdkScrollDirection, const GDisplayOptions *);
/* Fournit la ligne présente à une ordonnée donnée. */
@@ -488,7 +488,7 @@ bool g_buffer_view_get_restrictions(const GBufferView *view, GLineCursor **start
/******************************************************************************
* *
* Paramètres : view = visualisation à consulter. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* *
* Description : Fournit la largeur requise par une visualisation. *
* *
@@ -498,13 +498,13 @@ bool g_buffer_view_get_restrictions(const GBufferView *view, GLineCursor **start
* *
******************************************************************************/
-gint g_buffer_view_get_width(GBufferView *view, const bool *display)
+gint g_buffer_view_get_width(GBufferView *view, const GDisplayOptions *options)
{
gint result; /* Taille à retourner */
result = g_buffer_cache_get_text_position(view->cache);
- result += g_width_tracker_get_width(view->tracker, display);
+ result += g_width_tracker_get_width(view->tracker, options);
return result;
@@ -514,7 +514,7 @@ gint g_buffer_view_get_width(GBufferView *view, const bool *display)
/******************************************************************************
* *
* Paramètres : view = visualisation à consulter. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* *
* Description : Fournit la largeur requise pour dépasser les marges gauches. *
* *
@@ -524,13 +524,13 @@ gint g_buffer_view_get_width(GBufferView *view, const bool *display)
* *
******************************************************************************/
-gint g_buffer_view_get_margin(GBufferView *view, const bool *display)
+gint g_buffer_view_get_margin(GBufferView *view, const GDisplayOptions *options)
{
gint result; /* Taille à retourner */
result = g_buffer_cache_get_text_position(view->cache);
- result += g_width_tracker_get_margin(view->tracker, display);
+ result += g_width_tracker_get_margin(view->tracker, options);
return result;
@@ -578,7 +578,7 @@ gint g_buffer_view_get_height(const GBufferView *view)
* Paramètres : view = vue de tampon à mettre à jour. *
* x = abscisse proposée pour le nouvel emplacement. *
* y = ordonnée proposée pour le nouvel emplacement. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* caret = position du curseur à construire. [OUT] *
* cursor = emplacement correspondant à cette position. [OUT] *
* *
@@ -590,7 +590,7 @@ gint g_buffer_view_get_height(const GBufferView *view)
* *
******************************************************************************/
-bool g_buffer_view_compute_caret_full(GBufferView *view, gint x, gint y, const bool *display, cairo_rectangle_int_t *caret, GLineCursor **cursor)
+bool g_buffer_view_compute_caret_full(GBufferView *view, gint x, gint y, const GDisplayOptions *options, cairo_rectangle_int_t *caret, GLineCursor **cursor)
{
bool result; /* Bilan à retourner */
gint lheight; /* Hauteur d'une ligne */
@@ -615,7 +615,7 @@ bool g_buffer_view_compute_caret_full(GBufferView *view, gint x, gint y, const b
/* Calcul d'une position */
- result = _g_buffer_view_compute_caret_full(view, x, line, index, display, caret, cursor);
+ result = _g_buffer_view_compute_caret_full(view, x, line, index, options, caret, cursor);
g_object_unref(G_OBJECT(line));
@@ -632,7 +632,7 @@ bool g_buffer_view_compute_caret_full(GBufferView *view, gint x, gint y, const b
* x = abscisse proposée pour le nouvel emplacement. *
* line = ligne correspondant à la position. *
* index = indice de cette même ligne dans le tampon. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* caret = position du curseur à construire. [OUT] *
* cursor = emplacement correspondant à cette position. [OUT] *
* *
@@ -644,7 +644,7 @@ bool g_buffer_view_compute_caret_full(GBufferView *view, gint x, gint y, const b
* *
******************************************************************************/
-bool _g_buffer_view_compute_caret_full(GBufferView *view, gint x, GBufferLine *line, size_t index, const bool *display, cairo_rectangle_int_t *caret, GLineCursor **cursor)
+bool _g_buffer_view_compute_caret_full(GBufferView *view, gint x, GBufferLine *line, size_t index, const GDisplayOptions *options, cairo_rectangle_int_t *caret, GLineCursor **cursor)
{
bool result; /* Bilan à retourner */
gint text_pos; /* Abscisse de départ du texte */
@@ -668,7 +668,7 @@ bool _g_buffer_view_compute_caret_full(GBufferView *view, gint x, GBufferLine *l
x -= text_pos;
- status = g_buffer_line_get_coord_at(line, &summary, display, &base, &x,
+ status = g_buffer_line_get_coord_at(line, &summary, options, &base, &x,
GDK_SCROLL_LEFT, true, (col_coord_t []) { { 0 } });
if (!status)
@@ -704,7 +704,7 @@ bool _g_buffer_view_compute_caret_full(GBufferView *view, gint x, GBufferLine *l
* caret = position du curseur à faire évoluer. *
* ctrl = indique la demande d'un parcours rapide. *
* dir = direction du parcours. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* *
* Description : Déplace le curseur au sein d'une vue de tampon. *
* *
@@ -714,7 +714,7 @@ bool _g_buffer_view_compute_caret_full(GBufferView *view, gint x, GBufferLine *l
* *
******************************************************************************/
-static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line, size_t index, cairo_rectangle_int_t *caret, bool ctrl, GdkScrollDirection dir, const bool *display)
+static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line, size_t index, cairo_rectangle_int_t *caret, bool ctrl, GdkScrollDirection dir, const GDisplayOptions *options)
{
bool result; /* Bilan à retourner */
gint text_pos; /* Abscisse de départ du texte */
@@ -740,7 +740,7 @@ static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line
/* Déplacement au sein du segment courant ? */
- result = g_buffer_line_get_coord_at(line, &summary, display, &base, &offset, dir, false, &coord);
+ result = g_buffer_line_get_coord_at(line, &summary, options, &base, &offset, dir, false, &coord);
if (result)
{
@@ -756,7 +756,7 @@ static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line
{
base = 0;
- result = g_buffer_line_find_near_coord(line, &coord, &summary, display, dir, &offset);
+ result = g_buffer_line_find_near_coord(line, &coord, &summary, options, dir, &offset);
}
@@ -777,7 +777,7 @@ static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line
* Paramètres : view = vue de tampon à mettre à jour. *
* ctrl = indique la demande d'un parcours rapide. *
* dir = direction du parcours. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* caret = position du curseur à faire évoluer. [OUT] *
* cursor = emplacement correspondant à cette position. [OUT] *
* *
@@ -789,7 +789,7 @@ static bool _g_buffer_view_move_caret(GBufferView *view, const GBufferLine *line
* *
******************************************************************************/
-bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection dir, const bool *display, cairo_rectangle_int_t *caret, GLineCursor **cursor)
+bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection dir, const GDisplayOptions *options, cairo_rectangle_int_t *caret, GLineCursor **cursor)
{
bool result; /* Bilan à retourner */
size_t index; /* Indice de ligne de tampon */
@@ -817,7 +817,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
index--;
other = g_buffer_cache_find_line_by_index(view->cache, index);
- result = _g_buffer_view_compute_caret_full(view, caret->x, other, index, display, caret, cursor);
+ result = _g_buffer_view_compute_caret_full(view, caret->x, other, index, options, caret, cursor);
g_object_unref(G_OBJECT(other));
}
@@ -831,7 +831,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
index++;
other = g_buffer_cache_find_line_by_index(view->cache, index);
- result = _g_buffer_view_compute_caret_full(view, caret->x, other, index, display, caret, cursor);
+ result = _g_buffer_view_compute_caret_full(view, caret->x, other, index, options, caret, cursor);
g_object_unref(G_OBJECT(other));
}
@@ -840,7 +840,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
case GDK_SCROLL_LEFT:
- moved = _g_buffer_view_move_caret(view, line, index, caret, ctrl, GDK_SCROLL_LEFT, display);
+ moved = _g_buffer_view_move_caret(view, line, index, caret, ctrl, GDK_SCROLL_LEFT, options);
if (moved)
{
@@ -853,7 +853,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
index--;
other = g_buffer_cache_find_line_by_index(view->cache, index);
- result = _g_buffer_view_compute_caret_full(view, INT_MAX, other, index, display, caret, cursor);
+ result = _g_buffer_view_compute_caret_full(view, INT_MAX, other, index, options, caret, cursor);
g_object_unref(G_OBJECT(other));
}
@@ -862,7 +862,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
case GDK_SCROLL_RIGHT:
- moved = _g_buffer_view_move_caret(view, line, index, caret, ctrl, GDK_SCROLL_RIGHT, display);
+ moved = _g_buffer_view_move_caret(view, line, index, caret, ctrl, GDK_SCROLL_RIGHT, options);
if (moved)
{
@@ -877,7 +877,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
text_pos = g_buffer_cache_get_text_position(view->cache);
other = g_buffer_cache_find_line_by_index(view->cache, index);
- result = _g_buffer_view_compute_caret_full(view, text_pos, other, index, display, caret, cursor);
+ result = _g_buffer_view_compute_caret_full(view, text_pos, other, index, options, caret, cursor);
g_object_unref(G_OBJECT(other));
}
@@ -909,7 +909,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
* Paramètres : view = vue de tampon à mettre à jour. *
* x = abscisse de la zone principale à traiter. *
* y = ordonnée de la zone principale à traiter. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* *
* Description : Trouve le créateur à l'origine d'un emplacement donné. *
* *
@@ -919,7 +919,7 @@ bool g_buffer_view_move_caret(GBufferView *view, bool ctrl, GdkScrollDirection d
* *
******************************************************************************/
-GObject *g_buffer_view_find_creator(GBufferView *view, gint x, gint y, const bool *display)
+GObject *g_buffer_view_find_creator(GBufferView *view, gint x, gint y, const GDisplayOptions *options)
{
GObject *result; /* Trouvaille à faire remonter */
gint text_pos; /* Abscisse de départ du texte */
@@ -957,7 +957,7 @@ GObject *g_buffer_view_find_creator(GBufferView *view, gint x, gint y, const boo
x -= text_pos;
- result = g_buffer_line_get_creator_at(line, &summary, display, (gint []) { 0 }, &x, GDK_SCROLL_LEFT, false);
+ result = g_buffer_line_get_creator_at(line, &summary, options, (gint []) { 0 }, &x, GDK_SCROLL_LEFT, false);
g_object_unref(G_OBJECT(line));
@@ -1002,7 +1002,7 @@ bool g_buffer_view_unhighlight_segments(GBufferView *view)
* Paramètres : view = vue de tampon à mettre à jour. *
* x = abscisse de la zone principale à traiter. *
* y = ordonnée de la zone principale à traiter. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* *
* Description : Surligne tous les segments similaires à celui sous la souris.*
* *
@@ -1012,7 +1012,7 @@ bool g_buffer_view_unhighlight_segments(GBufferView *view)
* *
******************************************************************************/
-bool g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y, const bool *display)
+bool g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y, const GDisplayOptions *options)
{
bool result; /* Besoin à faire remonter */
gint text_pos; /* Abscisse de départ du texte */
@@ -1056,7 +1056,7 @@ bool g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y, const b
x -= text_pos;
- segment = g_buffer_line_get_segment_at(line, &summary, display,
+ segment = g_buffer_line_get_segment_at(line, &summary, options,
(gint []) { 0 }, &x, GDK_SCROLL_LEFT, true);
g_object_unref(G_OBJECT(line));
@@ -1082,7 +1082,7 @@ bool g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y, const b
* cr = contexte graphique dédié à la procédure. *
* virt_y = ordonnée réelle du point 0 à l'écran. *
* area = position et surface à traiter. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* selected = ordonnée d'une ligne sélectionnée ou NULL. *
* *
* Description : Imprime la visualisation du tampon de lignes quelconques. *
@@ -1093,7 +1093,7 @@ bool g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y, const b
* *
******************************************************************************/
-void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint virt_y, const cairo_rectangle_int_t *area, const bool *display, gint *selected)
+void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint virt_y, const cairo_rectangle_int_t *area, const GDisplayOptions *options, gint *selected)
{
gint line_height; /* Hauteur d'une ligne */
gint cr_y; /* Ordonnée pour le dessin */
@@ -1128,7 +1128,7 @@ void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint virt_y, const
if (selected != NULL)
*selected -= cr_y;
- g_buffer_cache_draw(view->cache, cr, first, last, area, display, selected, view->highlighted);
+ g_buffer_cache_draw(view->cache, cr, first, last, area, options, selected, view->highlighted);
}
diff --git a/src/glibext/gbufferview.h b/src/glibext/gbufferview.h
index 6b5ef45..04e4bbb 100644
--- a/src/glibext/gbufferview.h
+++ b/src/glibext/gbufferview.h
@@ -29,6 +29,7 @@
#include "gbuffercache.h"
+#include "gdisplayoptions.h"
@@ -65,10 +66,10 @@ bool g_buffer_view_get_restrictions(const GBufferView *, GLineCursor **, GLineCu
/* Fournit la largeur requise par une visualisation. */
-gint g_buffer_view_get_width(GBufferView *, const bool *);
+gint g_buffer_view_get_width(GBufferView *, const GDisplayOptions *);
/* Fournit la largeur requise pour dépasser les marges gauches. */
-gint g_buffer_view_get_margin(GBufferView *, const bool *);
+gint g_buffer_view_get_margin(GBufferView *, const GDisplayOptions *);
/* Fournit la hauteur requise par une visualisation. */
gint g_buffer_view_get_height(const GBufferView *);
@@ -78,15 +79,15 @@ gint g_buffer_view_get_height(const GBufferView *);
/* Calcule la position idéale de curseur pour un point donné. */
-bool g_buffer_view_compute_caret_full(GBufferView *, gint, gint, const bool *, cairo_rectangle_int_t *, GLineCursor **);
+bool g_buffer_view_compute_caret_full(GBufferView *, gint, gint, const GDisplayOptions *, cairo_rectangle_int_t *, GLineCursor **);
/* Déplace le curseur au sein d'une vue de tampon. */
-bool g_buffer_view_move_caret(GBufferView *, bool, GdkScrollDirection, const bool *, cairo_rectangle_int_t *, GLineCursor **);
+bool g_buffer_view_move_caret(GBufferView *, bool, GdkScrollDirection, const GDisplayOptions *, cairo_rectangle_int_t *, GLineCursor **);
/* Trouve le créateur à l'origine d'un emplacement donné. */
-GObject *g_buffer_view_find_creator(GBufferView *, gint, gint, const bool *);
+GObject *g_buffer_view_find_creator(GBufferView *, gint, gint, const GDisplayOptions *);
@@ -94,10 +95,10 @@ GObject *g_buffer_view_find_creator(GBufferView *, gint, gint, const bool *);
bool g_buffer_view_unhighlight_segments(GBufferView *);
/* Surligne tous les segments similaires à celui sous la souris. */
-bool g_buffer_view_highlight_segments(GBufferView *, gint, gint, const bool *);
+bool g_buffer_view_highlight_segments(GBufferView *, gint, gint, const GDisplayOptions *);
/* Imprime la visualisation du tampon de lignes quelconques. */
-void g_buffer_view_draw(const GBufferView *, cairo_t *, gint, const cairo_rectangle_int_t *, const bool *, gint *);
+void g_buffer_view_draw(const GBufferView *, cairo_t *, gint, const cairo_rectangle_int_t *, const GDisplayOptions *, gint *);
diff --git a/src/analysis/roptions.c b/src/glibext/gdisplayoptions.c
index b9e4b96..8641f59 100644
--- a/src/analysis/roptions.c
+++ b/src/glibext/gdisplayoptions.c
@@ -1,8 +1,8 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * roptions.c - options de rendus des lignes de code
+ * gdisplayoptions.h - options de rendus des lignes de code
*
- * Copyright (C) 2009-2017 Cyrille Bagard
+ * Copyright (C) 2018 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -21,39 +21,57 @@
*/
-#include "roptions.h"
+#include "gdisplayoptions.h"
+
+
+#include <assert.h>
+#include <malloc.h>
+#include <string.h>
+
+
+#include "chrysamarshal.h"
/* Options de représentation (instance) */
-struct _GRenderingOptions
+struct _GDisplayOptions
{
- GExeFormat *format; /* Format du contenu bianire */
- GArchProcessor *proc; /* Architecture utilisée */
+ GObject parent; /* A laisser en premier */
- bool show_address[MRD_COUNT]; /* Affichage de l'adresse ? */
- bool show_code[MRD_COUNT]; /* Affichage du code brut ? */
+ char **names; /* Désignations des options */
+ bool *values; /* Valeurs des options */
+ size_t count; /* Nombre de ces options */
};
/* Options de représentation (classe) */
-struct _GRenderingOptionsClass
+struct _GDisplayOptionsClass
{
GObjectClass parent; /* A laisser en premier */
+ /* Signaux */
+
+ void (* value_changed) (const GDisplayOptions *, gsize, gboolean);
+
};
/* Initialise la classe des options pour le rendu des lignes. */
-static void g_rendering_options_class_init(GRenderingOptionsClass *);
+static void g_display_options_class_init(GDisplayOptionsClass *);
/* Initialise une instance d'options pour le rendu des lignes. */
-static void g_rendering_options_init(GRenderingOptions *);
+static void g_display_options_init(GDisplayOptions *);
+
+/* Supprime toutes les références externes. */
+static void g_display_options_dispose(GDisplayOptions *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_display_options_finalize(GDisplayOptions *);
/* Indique le type définit pour une ligne de représentation. */
-G_DEFINE_TYPE(GRenderingOptions, g_rendering_options, G_TYPE_OBJECT);
+G_DEFINE_TYPE(GDisplayOptions, g_display_options, G_TYPE_OBJECT);
/******************************************************************************
@@ -68,8 +86,31 @@ G_DEFINE_TYPE(GRenderingOptions, g_rendering_options, G_TYPE_OBJECT);
* *
******************************************************************************/
-static void g_rendering_options_class_init(GRenderingOptionsClass *klass)
+static void g_display_options_class_init(GDisplayOptionsClass *klass)
{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_display_options_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_display_options_finalize;
+
+ /**
+ * Note : il n'existe pas de G_TYPE_GSIZE.
+ *
+ * Or la documentation précise :
+ *
+ * typedef unsigned long gsize;
+ *
+ */
+
+ g_signal_new("value-changed",
+ G_TYPE_DISPLAY_OPTIONS,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GDisplayOptionsClass, value_changed),
+ NULL, NULL,
+ g_cclosure_user_marshal_VOID__ULONG_BOOLEAN,
+ G_TYPE_NONE, 2, G_TYPE_ULONG, G_TYPE_BOOLEAN);
}
@@ -86,153 +127,197 @@ static void g_rendering_options_class_init(GRenderingOptionsClass *klass)
* *
******************************************************************************/
-static void g_rendering_options_init(GRenderingOptions *options)
+static void g_display_options_init(GDisplayOptions *options)
{
+ options->names = NULL;
+ options->values = NULL;
+ options->count = 0;
}
/******************************************************************************
* *
-* Paramètres : format = format du contenu binaire. *
+* Paramètres : options = instance d'objet GLib à traiter. *
* *
-* Description : Crée un un groupe d'options pour le rendu des lignes. *
+* Description : Supprime toutes les références externes. *
* *
-* Retour : Adresse de la structure mise en place. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GRenderingOptions *g_rendering_options_new(GExeFormat *format)
+static void g_display_options_dispose(GDisplayOptions *options)
{
- GRenderingOptions *result; /* Structure à retourner */
-
- result = g_object_new(G_TYPE_RENDERING_OPTIONS, NULL);
-
- result->format = format;
- result->proc = NULL;//get_arch_processor_from_format(format);
-
- return result;
+ G_OBJECT_CLASS(g_display_options_parent_class)->dispose(G_OBJECT(options));
}
/******************************************************************************
* *
-* Paramètres : options = options à consulter. *
+* Paramètres : options = instance d'objet GLib à traiter. *
* *
-* Description : Fournit le format du contenu binaire représenté. *
+* Description : Procède à la libération totale de la mémoire. *
* *
-* Retour : Format du contenu binaire. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GExeFormat *g_rendering_options_get_format(const GRenderingOptions *options)
+static void g_display_options_finalize(GDisplayOptions *options)
{
- return options->format;
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < options->count; i++)
+ free(options->names[i]);
+
+ if (options->names != NULL)
+ free(options->names);
+
+ if (options->values != NULL)
+ free(options->values);
+
+ G_OBJECT_CLASS(g_display_options_parent_class)->finalize(G_OBJECT(options));
}
/******************************************************************************
* *
-* Paramètres : options = options à consulter. *
+* Paramètres : - *
* *
-* Description : Fournit l'architecture du contenu binaire représenté. *
+* Description : Crée un un groupe d'options pour le rendu des lignes. *
* *
-* Retour : Architecture utilisée par le binaire. *
+* Retour : Adresse de la structure mise en place. *
* *
* Remarques : - *
* *
******************************************************************************/
-GArchProcessor *g_rendering_options_get_processor(const GRenderingOptions *options)
+GDisplayOptions *g_display_options_new(void)
{
- return options->proc;
+ GDisplayOptions *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_DISPLAY_OPTIONS, NULL);
+
+ return result;
}
/******************************************************************************
* *
-* Paramètres : options = options à mettre à jour. *
-* rendering = type de rendu impliqué. *
-* state = nouvel état de l'option visée. *
+* Paramètres : options = options à consulter. *
* *
-* Description : Affiche (ou non) les adresses des instructions. *
+* Description : Dénombre la quantité d'options représentées. *
* *
-* Retour : - *
+* Retour : Quantité positive ou nulle. *
* *
* Remarques : - *
* *
******************************************************************************/
-void g_rendering_options_show_address(GRenderingOptions *options, MainRendering rendering, bool state)
+size_t g_display_options_count(const GDisplayOptions *options)
{
- options->show_address[rendering] = state;
+ size_t result; /* Quantité à retourner */
+
+ result = options->count;
+
+ return result;
}
/******************************************************************************
* *
-* Paramètres : options = options à consulter. *
-* rendering = type de rendu impliqué. *
+* Paramètres : options = options à compléter. *
+* name = désignation humaine de la nouvelle option. *
+* value = valeur initiale de l'option à ajouter. *
* *
-* Description : Indique si les adresses des instructions sont à afficher. *
+* Description : Ajoute une nouvelle option à l'ensemble. *
* *
-* Retour : Etat courant de l'option visée. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-bool g_rendering_options_has_to_show_address(const GRenderingOptions *options, MainRendering rendering)
+void g_display_options_add(GDisplayOptions *options, const char *name, bool value)
{
- return options->show_address[rendering];
+ options->count++;
+
+ options->names = (char **)realloc(options->names, options->count * sizeof(char *));
+ options->values = (bool *)realloc(options->values, options->count * sizeof(bool));
+
+ options->names[options->count - 1] = strdup(name);
+ options->values[options->count - 1] = value;
}
/******************************************************************************
* *
-* Paramètres : options = options à mettre à jour. *
-* rendering = type de rendu impliqué. *
-* state = nouvel état de l'option visée. *
+* Paramètres : options = options à consulter. *
+* index = indice de l'option concernée. *
* *
-* Description : Affiche (ou non) le code des instructions. *
+* Description : Fournit la valeur d'une option donnée. *
* *
-* Retour : - *
+* Retour : Valeur attribuée. *
* *
* Remarques : - *
* *
******************************************************************************/
-void g_rendering_options_show_code(GRenderingOptions *options, MainRendering rendering, bool state)
+bool g_display_options_get(const GDisplayOptions *options, size_t index)
{
- options->show_code[rendering] = state;
+ bool result; /* Valeur à renvoyer */
+
+ assert(index < options->count);
+
+ if (index < options->count)
+ result = options->values[index];
+
+ else
+ result = false;
+
+ return result;
}
/******************************************************************************
* *
-* Paramètres : options = options à consulter. *
-* rendering = type de rendu impliqué. *
+* Paramètres : options = options à mettre à jour. *
+* index = indice de l'option concernée. *
+* value = nouvelle valeur à intégrer. *
* *
-* Description : Indique si le code des instructions est à afficher. *
+* Description : Définit la valeur d'une option donnée. *
* *
-* Retour : Etat courant de l'option visée. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-bool g_rendering_options_has_to_show_code(const GRenderingOptions *options, MainRendering rendering)
+void g_display_options_set(GDisplayOptions *options, size_t index, bool value)
{
- return options->show_code[rendering];
+ bool changed; /* Note un changement */
+
+ assert(index < options->count);
+
+ if (index < options->count)
+ {
+ changed = (options->values[index] != value);
+ options->values[index] = value;
+ }
+
+ else
+ changed = false;
+
+ if (changed)
+ g_signal_emit_by_name(options, "value-changed", index, value);
}
diff --git a/src/glibext/gdisplayoptions.h b/src/glibext/gdisplayoptions.h
new file mode 100644
index 0000000..5697385
--- /dev/null
+++ b/src/glibext/gdisplayoptions.h
@@ -0,0 +1,68 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * gdisplayoptions.h - prototypes pour les options de rendus des lignes de code
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _GLIBEXT_GDISPLAYOPTIONS_H
+#define _GLIBEXT_GDISPLAYOPTIONS_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+
+#define G_TYPE_DISPLAY_OPTIONS g_display_options_get_type()
+#define G_DISPLAY_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DISPLAY_OPTIONS, GDisplayOptions))
+#define G_IS_DISPLAY_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DISPLAY_OPTIONS))
+#define G_DISPLAY_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DISPLAY_OPTIONS, GDisplayOptionsClass))
+#define G_IS_DISPLAY_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DISPLAY_OPTIONS))
+#define G_DISPLAY_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DISPLAY_OPTIONS, GDisplayOptionsClass))
+
+
+/* Options de représentation (instance) */
+typedef struct _GDisplayOptions GDisplayOptions;
+
+/* Options de représentation (classe) */
+typedef struct _GDisplayOptionsClass GDisplayOptionsClass;
+
+
+/* Indique le type défini pour des options de représentation. */
+GType g_display_options_get_type(void);
+
+/* Crée un un groupe d'options pour le rendu des lignes. */
+GDisplayOptions *g_display_options_new(void);
+
+/* Dénombre la quantité d'options représentées. */
+size_t g_display_options_count(const GDisplayOptions *);
+
+/* Ajoute une nouvelle option à l'ensemble. */
+void g_display_options_add(GDisplayOptions *, const char *, bool);
+
+/* Fournit la valeur d'une option donnée. */
+bool g_display_options_get(const GDisplayOptions *, size_t);
+
+/* Définit la valeur d'une option donnée. */
+void g_display_options_set(GDisplayOptions *, size_t, bool);
+
+
+
+#endif /* _GLIBEXT_GDISPLAYOPTIONS_H */
diff --git a/src/glibext/glinecursor.h b/src/glibext/glinecursor.h
index 1cf8d47..4fa93c1 100644
--- a/src/glibext/glinecursor.h
+++ b/src/glibext/glinecursor.h
@@ -21,8 +21,8 @@
*/
-#ifndef _GLIBEXT_LINECURSOR_H
-#define _GLIBEXT_LINECURSOR_H
+#ifndef _GLIBEXT_GLINECURSOR_H
+#define _GLIBEXT_GLINECURSOR_H
#include <glib-object.h>
@@ -106,4 +106,4 @@ bool g_line_cursor_prepare_db_statement(const GLineCursor *, const char *, bound
-#endif /* _GLIBEXT_LINECURSOR_H */
+#endif /* _GLIBEXT_GLINECURSOR_H */
diff --git a/src/glibext/gwidthtracker.c b/src/glibext/gwidthtracker.c
index 0741133..44a7ff0 100644
--- a/src/glibext/gwidthtracker.c
+++ b/src/glibext/gwidthtracker.c
@@ -1149,7 +1149,7 @@ void g_width_tracker_get_local_width_summary(GWidthTracker *tracker, size_t inde
/******************************************************************************
* *
* Paramètres : tracker = suivi de largeurs à consulter. *
-* display = règles d'affichage des colonnes modulables. *
+* options = règles d'affichage des colonnes modulables. *
* *
* Description : Fournit la largeur requise par une visualisation. *
* *
@@ -1159,13 +1159,14 @@ void g_width_tracker_get_local_width_summary(GWidthTracker *tracker, size_t inde
* *
******************************************************************************/
-gint g_width_tracker_get_width(GWidthTracker *tracker, const bool *display)
+gint g_width_tracker_get_width(GWidthTracker *tracker, const GDisplayOptions *options)
{
gint result; /* Taille à retourner */
const line_width_summary *summary; /* Accès rapide aux mesures */
gint col_width; /* Calcul selon les colonnes */
gint full_width; /* Calcul selon les fusions */
- BufferLineColumn i; /* Boucle de parcours */
+ size_t count; /* Qté de colonnes en option */
+ size_t i; /* Boucle de parcours */
g_width_tracker_ensure_valid_required_widths(tracker);
@@ -1176,11 +1177,17 @@ gint g_width_tracker_get_width(GWidthTracker *tracker, const bool *display)
col_width = 0;
full_width = 0;
+ count = g_display_options_count(options);
+
/* Première méthode */
for (i = 0; i < BLC_COUNT; i++)
{
- if (i < BLC_DISPLAY && !display[i]) continue;
+ if (i < count)
+ {
+ if (!g_display_options_get(options, i))
+ continue;
+ }
col_width += summary->max_widths[i];
@@ -1191,9 +1198,10 @@ gint g_width_tracker_get_width(GWidthTracker *tracker, const bool *display)
/* Seconde méthode */
- for (i = 0; i < BLC_DISPLAY; i++)
+ for (i = 0; i < count; i++)
{
- if (!display[i]) continue;
+ if (!g_display_options_get(options, i))
+ continue;
full_width += summary->max_widths[i] + COL_MARGIN;
@@ -1223,11 +1231,12 @@ gint g_width_tracker_get_width(GWidthTracker *tracker, const bool *display)
* *
******************************************************************************/
-gint g_width_tracker_get_margin(GWidthTracker *tracker, const bool *display)
+gint g_width_tracker_get_margin(GWidthTracker *tracker, const GDisplayOptions *options)
{
gint result; /* Taille à retourner */
const line_width_summary *summary; /* Accès rapide aux mesures */
- BufferLineColumn i; /* Boucle de parcours */
+ size_t count; /* Qté de colonnes en option */
+ size_t i; /* Boucle de parcours */
g_width_tracker_ensure_valid_required_widths(tracker);
@@ -1235,9 +1244,12 @@ gint g_width_tracker_get_margin(GWidthTracker *tracker, const bool *display)
summary = &tracker->summary;
- for (i = 0; i < BLC_DISPLAY; i++)
+ count = g_display_options_count(options);
+
+ for (i = 0; i < count; i++)
{
- if (!display[i]) continue;
+ if (!g_display_options_get(options, i))
+ continue;
result += summary->max_widths[i] + COL_MARGIN;
diff --git a/src/glibext/gwidthtracker.h b/src/glibext/gwidthtracker.h
index 2d9aef6..65e3df2 100644
--- a/src/glibext/gwidthtracker.h
+++ b/src/glibext/gwidthtracker.h
@@ -31,6 +31,7 @@
#include "delayed.h"
#include "gbufferline.h"
+#include "gdisplayoptions.h"
@@ -84,10 +85,10 @@ const line_width_summary *g_width_tracker_get_width_summary(GWidthTracker *);
void g_width_tracker_get_local_width_summary(GWidthTracker *, size_t, line_width_summary *);
/* Fournit la largeur requise par une visualisation. */
-gint g_width_tracker_get_width(GWidthTracker *, const bool *);
+gint g_width_tracker_get_width(GWidthTracker *, const GDisplayOptions *);
/* Fournit la largeur requise pour dépasser les marges gauches. */
-gint g_width_tracker_get_margin(GWidthTracker *, const bool *);
+gint g_width_tracker_get_margin(GWidthTracker *, const GDisplayOptions *);
diff --git a/src/gtkext/gtkblockdisplay.c b/src/gtkext/gtkblockdisplay.c
index 1e677ca..bc189a2 100644
--- a/src/gtkext/gtkblockdisplay.c
+++ b/src/gtkext/gtkblockdisplay.c
@@ -260,7 +260,7 @@ static gboolean gtk_block_display_button_press(GtkWidget *widget, GdkEventButton
view = gtk_buffer_display_get_view(GTK_BUFFER_DISPLAY(display));
- changed = g_buffer_view_highlight_segments(view, real_x, real_y, GTK_DISPLAY_PANEL(display)->display_options);
+ changed = g_buffer_view_highlight_segments(view, real_x, real_y, GTK_DISPLAY_PANEL(display)->options);
g_object_unref(G_OBJECT(view));
@@ -311,7 +311,7 @@ static gboolean gtk_block_display_query_tooltip(GtkWidget *widget, gint x, gint
real_y = y;
gtk_display_panel_compute_real_coord(panel, &real_x, &real_y);
- creator = g_buffer_view_find_creator(GTK_BUFFER_DISPLAY(display)->view, real_x, real_y, panel->display_options);
+ creator = g_buffer_view_find_creator(GTK_BUFFER_DISPLAY(display)->view, real_x, real_y, panel->options);
if (creator != NULL)
{
@@ -458,7 +458,7 @@ static bool gtk_block_display_notify_caret_relocation(GtkBlockDisplay *display,
view = gtk_buffer_display_get_view(GTK_BUFFER_DISPLAY(display));
- result = g_buffer_view_highlight_segments(view, area->x, area->y, GTK_DISPLAY_PANEL(display)->display_options);
+ result = g_buffer_view_highlight_segments(view, area->x, area->y, GTK_DISPLAY_PANEL(display)->options);
g_object_unref(G_OBJECT(view));
@@ -490,6 +490,6 @@ void gtk_block_display_override_view_index(GtkBlockDisplay *display, unsigned in
panel = GTK_DISPLAY_PANEL(display);
panel->view_index = index;
- panel->display_options = g_loaded_content_get_all_display_options(G_LOADED_CONTENT(panel->binary), index);
+ panel->options = g_loaded_content_get_display_options(G_LOADED_CONTENT(panel->binary), index);
}
diff --git a/src/gtkext/gtkbufferdisplay.c b/src/gtkext/gtkbufferdisplay.c
index 4a2c814..ea391bb 100644
--- a/src/gtkext/gtkbufferdisplay.c
+++ b/src/gtkext/gtkbufferdisplay.c
@@ -438,7 +438,7 @@ static gboolean gtk_buffer_display_draw(GtkWidget *widget, cairo_t *cr)
area.x -= virt_x;
virt_y += area.y;
- g_buffer_view_draw(display->view, cr, virt_y, &area, parent->display_options, selected);
+ g_buffer_view_draw(display->view, cr, virt_y, &area, parent->options, selected);
}
@@ -516,7 +516,7 @@ static gboolean gtk_buffer_display_key_press(GtkWidget *widget, GdkEventKey *eve
ctrl = (event->state & GDK_CONTROL_MASK);
area = display->caret;
- status = g_buffer_view_move_caret(display->view, ctrl, dir, panel->display_options, &area, &cursor);
+ status = g_buffer_view_move_caret(display->view, ctrl, dir, panel->options, &area, &cursor);
if (status)
{
@@ -552,7 +552,7 @@ static void gtk_buffer_display_compute_requested_size(GtkBufferDisplay *display,
if (width != NULL)
{
if (display->view != NULL)
- *width = g_buffer_view_get_width(display->view, GTK_DISPLAY_PANEL(display)->display_options);
+ *width = g_buffer_view_get_width(display->view, GTK_DISPLAY_PANEL(display)->options);
else
*width = 0;
}
@@ -682,7 +682,7 @@ static bool gtk_buffer_display_get_cursor_coordinates(const GtkBufferDisplay *di
if (result)
{
- *x += g_buffer_view_get_margin(display->view, GTK_DISPLAY_PANEL(display)->display_options);
+ *x += g_buffer_view_get_margin(display->view, GTK_DISPLAY_PANEL(display)->options);
height = gtk_widget_get_allocated_height(GTK_WIDGET(display));
@@ -737,7 +737,7 @@ GObject *gtk_buffer_display_get_active_object(const GtkBufferDisplay *display)
else
result = g_buffer_view_find_creator(display->view,
display->caret.x, display->caret.y,
- GTK_DISPLAY_PANEL(display)->display_options);
+ GTK_DISPLAY_PANEL(display)->options);
return result;
@@ -849,7 +849,7 @@ static bool _gtk_buffer_display_move_caret_to(GtkBufferDisplay *display, gint x,
panel = GTK_DISPLAY_PANEL(display);
- result = g_buffer_view_compute_caret_full(display->view, x, y, panel->display_options, &new, &cursor);
+ result = g_buffer_view_compute_caret_full(display->view, x, y, panel->options, &new, &cursor);
if (result)
gtk_buffer_display_relocate_caret(display, &new, cursor);
diff --git a/src/gtkext/gtkdisplaypanel-int.h b/src/gtkext/gtkdisplaypanel-int.h
index ffed3b1..9fdb702 100644
--- a/src/gtkext/gtkdisplaypanel-int.h
+++ b/src/gtkext/gtkdisplaypanel-int.h
@@ -90,7 +90,7 @@ struct _GtkDisplayPanel
bool show_border; /* Affichage d'une bordure ? */
unsigned int view_index; /* Indice du type de contenu */
- bool *display_options; /* Affichage des colonnes ? */
+ GDisplayOptions *options; /* Affichage des colonnes ? */
GLoadedBinary *binary; /* Binaire à visualiser */
diff --git a/src/gtkext/gtkdisplaypanel.c b/src/gtkext/gtkdisplaypanel.c
index 24436ca..706e8f7 100644
--- a/src/gtkext/gtkdisplaypanel.c
+++ b/src/gtkext/gtkdisplaypanel.c
@@ -46,6 +46,12 @@ static void gtk_display_panel_init(GtkDisplayPanel *);
/* Procède à l'initialisation de l'interface d'affichage. */
static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *);
+/* Supprime toutes les références externes. */
+static void gtk_display_panel_dispose(GtkDisplayPanel *);
+
+/* Procède à la libération totale de la mémoire. */
+static void gtk_display_panel_finalize(GtkDisplayPanel *);
+
/* Définit une propriété du composant d'affichage. */
static void gtk_display_panel_set_property(GObject *, guint, const GValue *, GParamSpec *);
@@ -86,7 +92,7 @@ static void gtk_display_panel_update_adjustment(GtkDisplayPanel *, GtkOrientatio
static void gtk_display_panel_adjustment_value_changed(GtkAdjustment *, GtkDisplayPanel *);
/* Réagit à un changement des règles d'affichage. */
-static void on_view_panel_binary_display_change(GLoadedBinary *, BinaryView, BufferLineColumn, GtkDisplayPanel *);
+static void on_view_panel_binary_option_change(GLoadedBinary *, BinaryView, BufferLineColumn, GtkDisplayPanel *);
@@ -133,30 +139,34 @@ G_DEFINE_TYPE_WITH_CODE(GtkDisplayPanel, gtk_display_panel, GTK_TYPE_FIXED,
static void gtk_display_panel_class_init(GtkDisplayPanelClass *class)
{
- GObjectClass *gobject_class; /* Plus haut niveau équivalent */
- GtkWidgetClass *widget_class; /* Classe de haut niveau */
- GtkDisplayPanelClass *panel_class; /* Classe de lus bas niveau */
+ GObjectClass *object; /* Plus haut niveau équivalent */
+ GtkWidgetClass *widget; /* Classe de haut niveau */
+ GtkDisplayPanelClass *panel; /* Classe de lus bas niveau */
- gobject_class = G_OBJECT_CLASS(class);
- widget_class = GTK_WIDGET_CLASS(class);
- panel_class = GTK_DISPLAY_PANEL_CLASS(class);
+ object = G_OBJECT_CLASS(class);
- gobject_class->set_property = gtk_display_panel_set_property;
- gobject_class->get_property = gtk_display_panel_get_property;
+ object->dispose = (GObjectFinalizeFunc/* ! */)gtk_display_panel_dispose;
+ object->finalize = (GObjectFinalizeFunc)gtk_display_panel_finalize;
+ object->set_property = gtk_display_panel_set_property;
+ object->get_property = gtk_display_panel_get_property;
/* Implémentation de l'interface "GtkScrollable" */
- g_object_class_override_property(gobject_class, VPP_HADJUSTMENT, "hadjustment");
- g_object_class_override_property(gobject_class, VPP_VADJUSTMENT, "vadjustment");
- g_object_class_override_property(gobject_class, VPP_HSCROLL_POLICY, "hscroll-policy");
- g_object_class_override_property(gobject_class, VPP_VSCROLL_POLICY, "vscroll-policy");
+ g_object_class_override_property(object, VPP_HADJUSTMENT, "hadjustment");
+ g_object_class_override_property(object, VPP_VADJUSTMENT, "vadjustment");
+ g_object_class_override_property(object, VPP_HSCROLL_POLICY, "hscroll-policy");
+ g_object_class_override_property(object, VPP_VSCROLL_POLICY, "vscroll-policy");
+
+ widget = GTK_WIDGET_CLASS(class);
- widget_class->destroy = gtk_display_panel_destroy;
- widget_class->realize = gtk_display_panel_realize;
- widget_class->size_allocate = gtk_display_panel_size_allocate;
- widget_class->get_preferred_height = gtk_display_panel_get_preferred_height;
- widget_class->get_preferred_width = gtk_display_panel_get_preferred_width;
+ widget->destroy = gtk_display_panel_destroy;
+ widget->realize = gtk_display_panel_realize;
+ widget->size_allocate = gtk_display_panel_size_allocate;
+ widget->get_preferred_height = gtk_display_panel_get_preferred_height;
+ widget->get_preferred_width = gtk_display_panel_get_preferred_width;
- panel_class->compute_inc = gtk_display_panel_compute_scroll_inc;
+ panel = GTK_DISPLAY_PANEL_CLASS(class);
+
+ panel->compute_inc = gtk_display_panel_compute_scroll_inc;
}
@@ -209,6 +219,47 @@ static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *iface
/******************************************************************************
* *
+* Paramètres : panel = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_display_panel_dispose(GtkDisplayPanel *panel)
+{
+ if (panel->options != NULL)
+ g_object_unref(G_OBJECT(panel->options));
+
+ G_OBJECT_CLASS(gtk_display_panel_parent_class)->dispose(G_OBJECT(panel));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_display_panel_finalize(GtkDisplayPanel *panel)
+{
+ G_OBJECT_CLASS(gtk_display_panel_parent_class)->finalize(G_OBJECT(panel));
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : object = instance de composant GTK à manipuler. *
* prop_id = identifiant de la propriété concernée. *
* value = valeur attribuée. *
@@ -822,7 +873,7 @@ void gtk_display_panel_draw_border(GtkDisplayPanel *panel, cairo_t *cr)
* *
******************************************************************************/
-static void on_view_panel_binary_display_change(GLoadedBinary *binary, BinaryView view, BufferLineColumn col, GtkDisplayPanel *panel)
+static void on_view_panel_binary_option_change(GLoadedBinary *binary, BinaryView view, BufferLineColumn col, GtkDisplayPanel *panel)
{
if (panel->view_index == view)
{
@@ -1011,14 +1062,14 @@ static void gtk_display_panel_set_content(GtkDisplayPanel *panel, GLoadedContent
{
panel->view_index = g_loaded_content_get_view_index(content, GTK_WIDGET(panel));
- panel->display_options = g_loaded_content_get_all_display_options(content, panel->view_index);
+ panel->options = g_loaded_content_get_display_options(content, panel->view_index);
panel->binary = G_LOADED_BINARY(content);
if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->attach != NULL) /* REMME */
GTK_DISPLAY_PANEL_GET_CLASS(panel)->attach(panel, panel->binary);
- g_signal_connect(content, "display-changed", G_CALLBACK(on_view_panel_binary_display_change), panel);
+ g_signal_connect(content, "value-changed", G_CALLBACK(on_view_panel_binary_option_change), panel);
}
diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c
index d446278..31726c7 100644
--- a/src/gui/menus/view.c
+++ b/src/gui/menus/view.c
@@ -199,7 +199,7 @@ void rebuild_menu_view(GtkWidget *widget, GLoadedPanel *panel, GMenuBar *bar)
GSList *found; /* Elément de menu à activer */
GLoadedContent *content; /* Contenu global représenté */
unsigned int view_index; /* Indice de représentation */
- const bool *display; /* Règles d'affichage courantes*/
+ GDisplayOptions *options; /* Règles d'affichage courantes*/
GtkWidget *submenuitem; /* Sous-élément de menu */
bool status; /* Consigne d'affichage */
@@ -252,7 +252,7 @@ void rebuild_menu_view(GtkWidget *widget, GLoadedPanel *panel, GMenuBar *bar)
view_index = g_loaded_content_get_view_index(content, GTK_WIDGET(panel));
- display = g_loaded_content_get_all_display_options(content, view_index);
+ options = g_loaded_content_get_display_options(content, view_index);
g_object_unref(G_OBJECT(content));
@@ -262,7 +262,7 @@ void rebuild_menu_view(GtkWidget *widget, GLoadedPanel *panel, GMenuBar *bar)
g_signal_handlers_disconnect_by_func(submenuitem, G_CALLBACK(mcb_view_display_column), NULL);
- status = display[BLC_PHYSICAL];
+ status = g_display_options_get(options, BLC_PHYSICAL);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(submenuitem), status);
g_signal_connect(submenuitem, "toggled", G_CALLBACK(mcb_view_display_column), NULL);
@@ -273,7 +273,7 @@ void rebuild_menu_view(GtkWidget *widget, GLoadedPanel *panel, GMenuBar *bar)
g_signal_handlers_disconnect_by_func(submenuitem, G_CALLBACK(mcb_view_display_column), NULL);
- status = display[BLC_VIRTUAL];
+ status = g_display_options_get(options, BLC_VIRTUAL);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(submenuitem), status);
g_signal_connect(submenuitem, "toggled", G_CALLBACK(mcb_view_display_column), NULL);
@@ -284,11 +284,13 @@ void rebuild_menu_view(GtkWidget *widget, GLoadedPanel *panel, GMenuBar *bar)
g_signal_handlers_disconnect_by_func(submenuitem, G_CALLBACK(mcb_view_display_column), NULL);
- status = display[BLC_BINARY];
+ status = g_display_options_get(options, BLC_BINARY);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(submenuitem), status);
g_signal_connect(submenuitem, "toggled", G_CALLBACK(mcb_view_display_column), NULL);
+ g_object_unref(G_OBJECT(options));
+
}
@@ -708,6 +710,7 @@ static void mcb_view_display_column(GtkCheckMenuItem *menuitem, gpointer unused)
GLoadedPanel *panel; /* Afficheur effectif de code */
GLoadedContent *content; /* Contenu représenté */
unsigned int index; /* Indice de la vue courante */
+ GDisplayOptions *options; /* Ensemble à mettre à jour */
option = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(menuitem), "kind_of_opt"));
@@ -718,7 +721,11 @@ static void mcb_view_display_column(GtkCheckMenuItem *menuitem, gpointer unused)
index = g_loaded_content_get_view_index(content, GTK_WIDGET(panel));
- g_loaded_content_set_display_option(content, index, option, active);
+ options = g_loaded_content_get_display_options(content, index);
+
+ g_display_options_set(options, option, active);
+
+ g_object_unref(G_OBJECT(options));
g_object_unref(G_OBJECT(content));
g_object_unref(G_OBJECT(panel));