[libgda/gtk3] GdaSql & GdaBrowser: limit width of printed data models to terminal width
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/gtk3] GdaSql & GdaBrowser: limit width of printed data models to terminal width
- Date: Tue, 7 Dec 2010 20:15:47 +0000 (UTC)
commit 7a4ec39ac459ded1bd40850a1605877bfa8cc64d
Author: Vivien Malerba <malerba gnome-db org>
Date: Tue Dec 7 21:08:59 2010 +0100
GdaSql & GdaBrowser: limit width of printed data models to terminal width
tools/browser/main.c | 21 +++++++++++++++++----
tools/gda-sql.c | 10 ++++++++--
2 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/tools/browser/main.c b/tools/browser/main.c
index 0241800..bf74c5f 100644
--- a/tools/browser/main.c
+++ b/tools/browser/main.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <unistd.h>
#include <glib/gi18n-lib.h>
#include <glib/gprintf.h>
#include <string.h>
@@ -93,8 +94,14 @@ main (int argc, char *argv[])
model = config_info_list_all_providers ();
if (model) {
- g_setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
- g_setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);
+ if (! getenv ("GDA_DATA_MODEL_DUMP_TITLE"))
+ g_setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
+ if (! getenv ("GDA_DATA_MODEL_NULL_AS_EMPTY"))
+ g_setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);
+ if (isatty (fileno (stdout))) {
+ if (! getenv ("GDA_DATA_MODEL_DUMP_TRUNCATE"))
+ g_setenv ("GDA_DATA_MODEL_DUMP_TRUNCATE", "-1", TRUE);
+ }
gda_data_model_dump (model, NULL);
g_object_unref (model);
}
@@ -108,8 +115,14 @@ main (int argc, char *argv[])
if (list_configs) {
gda_init ();
GdaDataModel *model = config_info_list_all_dsn ();
- g_setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
- g_setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);
+ if (! getenv ("GDA_DATA_MODEL_DUMP_TITLE"))
+ g_setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
+ if (! getenv ("GDA_DATA_MODEL_NULL_AS_EMPTY"))
+ g_setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);
+ if (isatty (fileno (stdout))) {
+ if (! getenv ("GDA_DATA_MODEL_DUMP_TRUNCATE"))
+ g_setenv ("GDA_DATA_MODEL_DUMP_TRUNCATE", "-1", TRUE);
+ }
gda_data_model_dump (model, NULL);
g_object_unref (model);
return 0;
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index 9d43ed1..7b382f1 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -1688,8 +1688,14 @@ data_model_to_string (SqlConsole *console, GdaDataModel *model)
OutputFormat of;
if (!env_set) {
- g_setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
- g_setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);
+ if (! getenv ("GDA_DATA_MODEL_DUMP_TITLE"))
+ g_setenv ("GDA_DATA_MODEL_DUMP_TITLE", "Yes", TRUE);
+ if (! getenv ("GDA_DATA_MODEL_NULL_AS_EMPTY"))
+ g_setenv ("GDA_DATA_MODEL_NULL_AS_EMPTY", "Yes", TRUE);
+ if (! main_data->output_stream || isatty (main_data->output_stream)) {
+ if (! getenv ("GDA_DATA_MODEL_DUMP_TRUNCATE"))
+ g_setenv ("GDA_DATA_MODEL_DUMP_TRUNCATE", "-1", TRUE);
+ }
env_set = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]