+2000-03-09 André Pönitz <poenitz@mathematik.tu-chemnitz.de>
+
+ * src/lyxrc.*: Added support for running without Gui
+ (\use_gui false)
+
+ * src/FontLoader.C: sensible defaults if no fonts are needed
+
+ * src/lyx_cb.C: New function ShowMessage (writes either to the
+ minibuffer or cout in case of no gui
+ New function AskOverwrite for common stuff
+ Consequently various changes to call these functions
+
+ * src/lyx_main.C: allow gui = false and handle lyxrc \use_gui false
+ wild guess at sensible screen resolution when having no gui
+
+ * src/lyxfont.C: no gui, no fonts... set some defaults
+
2000-03-20 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/LColor.C: made the command inset background a bit lighter.
return;
}
- char ** list = XListFonts(fl_display, pattern.c_str(), 100, &matches);
+ char ** list = 0;
+ if (lyxrc.use_gui)
+ list = XListFonts(fl_display, pattern.c_str(), 100, &matches);
if (list == 0) {
// No fonts matched
}
}
+
+// A dummy fontstruct used when there is no gui. Only the last 3 have
+// well-thought values...
+static XFontStruct dummyXFontStruct = {
+ /*XExtData *ext_data; */ 0,
+ /* Font fid; */ 0,
+ /* unsigned direction; */ FontLeftToRight,
+ /* unsigned min_char_or_byte2; */ 0,
+ /* unsigned max_char_or_byte2; */ 0,
+ /* unsigned min_byte1; */ 0,
+ /* unsigned max_byte1; */ 0,
+ /* Bool all_chars_exist; */ 0,
+ /* unsigned default_char; */ 0,
+ /* int n_properties; */ 0,
+ /* XFontProp *properties; */ 0,
+ /* XCharStruct min_bounds; */ 0,
+ /* XCharStruct max_bounds; */ 0,
+ /* XCharStruct *per_char; */ 0, // no character specific info
+ /* int ascent; */ 1, // unit ascent on character displays
+ /* int descent; */ 0, // no descent on character displays
+};
+
+
/// Do load font
XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family,
LyXFont::FONT_SERIES series,
LyXFont::FONT_SHAPE shape,
LyXFont::FONT_SIZE size)
{
+ if (!lyxrc.use_gui) {
+ return &dummyXFontStruct;
+ }
+
getFontinfo(family, series, shape);
int fsize = int( (lyxrc.font_sizes[size] * lyxrc.dpi *
(lyxrc.zoom/100.0) ) / 72.27 + 0.5 );
font = "fixed";
}
+ XFontStruct * fs = 0;
+
current_view->owner()->getMiniBuffer()->Store();
current_view->owner()->getMiniBuffer()->Set(_("Loading font into X-Server..."));
-
- XFontStruct * fs = XLoadQueryFont(fl_display, font.c_str());
-
+ fs = XLoadQueryFont(fl_display, font.c_str());
+
if (fs == 0) {
if (font == "fixed") {
lyxerr << "We're doomed. Can't get 'fixed' font." << endl;
bittable[i] = char(~k);
}
- fl_add_canvas_handler(figinset_canvas, ClientMessage,
- GhostscriptMsg, current_view->owner()->getMainForm());
-
// allocate color cube on pseudo-color display
// first get visual
gs_color = false;
- local_gc_copy = createGC();
+ if (lyxrc.use_gui) {
+ fl_add_canvas_handler(figinset_canvas, ClientMessage,
+ GhostscriptMsg, current_view->owner()->getMainForm());
- Visual * vi = DefaultVisual(fl_display, DefaultScreen(fl_display));
- if (lyxerr.debugging()) {
- printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
- vi->visualid, vi->c_class,
- vi->bits_per_rgb, vi->map_entries);
- }
- color_visual = ( (vi->c_class == StaticColor) ||
- (vi->c_class == PseudoColor) ||
- (vi->c_class == TrueColor) ||
- (vi->c_class == DirectColor) );
- if ((vi->c_class & 1) == 0) return;
- // now allocate colors
- if (vi->c_class == GrayScale) {
- // allocate grayscale
- AllocGrays(vi->map_entries/2);
- } else {
- // allocate normal color
- int i = 5;
- while (i * i * i * 2 > vi->map_entries) --i;
- AllocColors(i);
+ local_gc_copy = createGC();
+
+ Visual * vi = DefaultVisual(fl_display, DefaultScreen(fl_display));
+ if (lyxerr.debugging()) {
+ printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
+ vi->visualid, vi->c_class,
+ vi->bits_per_rgb, vi->map_entries);
+ }
+ color_visual = ( (vi->c_class == StaticColor) ||
+ (vi->c_class == PseudoColor) ||
+ (vi->c_class == TrueColor) ||
+ (vi->c_class == DirectColor) );
+ if ((vi->c_class & 1) == 0) return;
+ // now allocate colors
+ if (vi->c_class == GrayScale) {
+ // allocate grayscale
+ AllocGrays(vi->map_entries/2);
+ } else {
+ // allocate normal color
+ int i = 5;
+ while (i * i * i * 2 > vi->map_entries) --i;
+ AllocColors(i);
+ }
+ gs_allcolors = vi->map_entries;
}
- gs_allcolors = vi->map_entries;
}
tmp->pswid = pswid;
tmp->pshgh = pshgh;
tmp->fname = fname;
- if (!fname.empty() && (flags & 3) && !lyxrc.ps_command.empty()) {
+ if (!fname.empty() && (flags & 3) && !lyxrc.ps_command.empty()
+ && lyxrc.use_gui) {
// do not display if there is
// "do not display" chosen (Matthias 260696)
tmp->figure->data = getfigdata(wid, hgh, fname, psx, psy,
void MenuLayoutSave();
+void ShowMessage(Buffer * buf, string const & msg1,
+ string const & msg2 = string(), string const & msg3 = string(), int delay=6)
+{
+ if (lyxrc.use_gui) {
+ buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2, msg3, delay);
+ }
+ else {
+ // can somebody think of something more clever? cerr?
+ cout << msg1 << msg2 << msg3 << endl;
+ }
+}
+
// How should this actually work? Should it prohibit input in all BufferViews,
// or just in the current one? If "just the current one", then it should be
// placed in BufferView. If "all BufferViews" then LyXGUI (I think) should
buffer->fileName(s);
buffer->markDirty();
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Document renamed to '"),
- MakeDisplayPath(s),
- _("', but not saved..."));
+ ShowMessage(buffer, _("Document renamed to '"),
+ MakeDisplayPath(s), _("', but not saved..."));
}
return;
} // Check whether the file exists
#ifdef WITH_WARNINGS
#warning What should we do here?
#endif
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("Executing command:"), cmd);
+ ShowMessage(buffer, _("Executing command:"), cmd);
result = one.startscript(Systemcalls::System, cmd);
} else {
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("Executing command:"), cmd);
+ ShowMessage(buffer, _("Executing command:"), cmd);
result = one.startscript(wait ? Systemcalls::Wait
: Systemcalls::DontWait, cmd);
}
}
+bool AskOverwrite(Buffer * buffer, string const & s)
+{
+ if (lyxrc.use_gui) {
+ // be friendly if there is a gui
+ FileInfo fi(s);
+ if (fi.readable() &&
+ !AskQuestion(_("File already exists:"),
+ MakeDisplayPath(s, 50),
+ _("Do you want to overwrite the file?"))) {
+ ShowMessage(buffer, _("Canceled"));
+ return false;
+ }
+ }
+ return true;
+}
+
void MenuMakeLaTeX(Buffer * buffer)
{
// Why care about this?
// Get LaTeX-Filename
string s = buffer->getLatexName(false);
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
- return;
- }
+ if (!AskOverwrite(buffer, s))
+ return;
if (buffer->isDocBook())
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("DocBook does not have a latex backend"));
+ ShowMessage(buffer, _("DocBook does not have a latex backend"));
else {
if (buffer->isLinuxDoc())
RunLinuxDoc(buffer->getUser(), 0, buffer->fileName());
else
buffer->makeLaTeXFile(s, string(), true);
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("Nice LaTeX file saved as"), MakeDisplayPath(s));
+ ShowMessage(buffer, _("Nice LaTeX file saved as"),
+ MakeDisplayPath(s));
buffer->markDviDirty();
}
}
// Get LinuxDoc-Filename
string s = ChangeExtension(buffer->fileName(),
".sgml", false);
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
+
+ if (!AskOverwrite(buffer, s))
return;
- }
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Building LinuxDoc SGML file `"),
+ ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
MakeDisplayPath(s),"'...");
buffer->makeLinuxDocFile(s, 65);
buffer->redraw();
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("LinuxDoc SGML file save as"),
+ ShowMessage(buffer, _("LinuxDoc SGML file save as"),
MakeDisplayPath(s));
}
// Get DocBook-Filename
string s = ChangeExtension(buffer->fileName(),
".sgml", false);
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
+
+ if (!AskOverwrite(buffer, s))
return;
- }
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Building DocBook SGML file `"),
+ ShowMessage(buffer, _("Building DocBook SGML file `"),
MakeDisplayPath(s), "'...");
buffer->makeDocBookFile(s, 65);
buffer->redraw();
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("DocBook SGML file save as"),
+ ShowMessage(buffer, _("DocBook SGML file save as"),
MakeDisplayPath(s));
}
string s = ChangeExtension (buffer->fileName(),
".txt", false);
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
+
+ if (!AskOverwrite(buffer, s))
return;
- }
buffer->writeFileAscii(s, lyxrc.ascii_linelen);
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Ascii file saved as"), MakeDisplayPath(s));
+ ShowMessage(buffer, _("Ascii file saved as"), MakeDisplayPath(s));
}
Systemcalls one;
int res = one.startscript(Systemcalls::System, tmp);
if (res == 0) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Document exported as HTML to file `")
+ ShowMessage(buffer, _("Document exported as HTML to file `")
+ MakeDisplayPath(result) +'\'');
} else {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Unable to convert to HTML the file `")
+ ShowMessage(buffer, _("Unable to convert to HTML the file `")
+ MakeDisplayPath(infile)
+ '\'');
}
MenuMakeHTML(buffer);
}
else {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Unknown export type: ") + extyp);
+ ShowMessage(buffer, _("Unknown export type: ") + extyp);
}
}
// Initialization of LyX (reads lyxrc and more)
lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
- init(argc, argv);
+ init(argc, argv, gui);
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
lyxGUI->init();
if (last_loaded != 0) {
lyxerr.debug() << "Yes we loaded some files." << endl;
- lyxGUI->regBuf(last_loaded);
+ if (lyxrc.use_gui)
+ lyxGUI->regBuf(last_loaded);
}
// Execute batch commands if available
extern "C" void error_handler(int err_sig);
-void LyX::init(int */*argc*/, char **argv)
+void LyX::init(int */*argc*/, char **argv, bool gui)
{
// Install the signal handlers
signal(SIGHUP, error_handler);
}
// Calculate screen dpi as average of x-DPI and y-DPI:
- Screen * scr = DefaultScreenOfDisplay(fl_get_display());
- lyxrc.dpi = ((HeightOfScreen(scr)* 25.4 / HeightMMOfScreen(scr)) +
- (WidthOfScreen(scr)* 25.4 / WidthMMOfScreen(scr))) / 2;
- lyxerr[Debug::INFO] << "DPI setting detected to be "
- << lyxrc.dpi + 0.5 << endl;
+ // Disable gui when either lyxrc or easyparse says so
+ if (!gui)
+ lyxrc.use_gui = false;
+
+ // Calculate screen dpi as average of x-DPI and y-DPI:
+ if (lyxrc.use_gui) {
+ Screen * scr = DefaultScreenOfDisplay(fl_get_display());
+ lyxrc.dpi = ((HeightOfScreen(scr)* 25.4 / HeightMMOfScreen(scr)) +
+ (WidthOfScreen(scr)* 25.4 / WidthMMOfScreen(scr))) / 2;
+ lyxerr[Debug::INFO] << "DPI setting detected to be "
+ << lyxrc.dpi + 0.5 << endl;
+ } else {
+ lyxrc.dpi = 1; // I hope this is safe
+ }
//
// Read configuration files
"ps...] after ")
<< arg << _(" switch!") << endl;
}
+ gui = false;
}
return gui;
}
///
void runtime();
///
- void init(int * argc, char * argv[]);
+ void init(int * argc, char * argv[], bool);
///
void queryUserLyXDir();
///
}
-// Specialized after profiling. (Asger)
-int LyXFont::width(char c) const
-{
- if (realShape() != LyXFont::SMALLCAPS_SHAPE){
- return XTextWidth(getXFontstruct(), &c, 1);
- } else {
- return textWidth(&c, 1);
- }
-}
-
-
int LyXFont::lbearing(char c) const
{
XFontStruct * finfo = getXFontstruct();
}
+// Specialized after profiling. (Asger)
+int LyXFont::width(char c) const
+{
+ if (realShape() != LyXFont::SMALLCAPS_SHAPE){
+ return lyxrc.use_gui ? XTextWidth(getXFontstruct(), &c, 1) : 1;
+ } else {
+ return textWidth(&c, 1);
+ }
+}
+
+
int LyXFont::textWidth(char const * s, int n) const
{
+ if (!lyxrc.use_gui)
+ return n;
+
if (realShape() != LyXFont::SMALLCAPS_SHAPE){
return XTextWidth(getXFontstruct(), s, n);
} else {
RC_DVI_TO_PS_COMMAND,
RC_DATE_INSERT_FORMAT,
RC_SHOW_BANNER,
+ RC_USE_GUI,
RC_LAST
};
{ "\\begin_toolbar", RC_BEGINTOOLBAR },
{ "\\bind", RC_BIND },
{ "\\bind_file", RC_BINDFILE },
- { "\\build_command", RC_BUILD_COMMAND },
- { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
+ { "\\build_command", RC_BUILD_COMMAND },
+ { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
{ "\\check_lastfiles", RC_CHECKLASTFILES },
{ "\\chktex_command", RC_CHKTEX_COMMAND },
{ "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
{ "\\template_path", RC_TEMPLATEPATH },
{ "\\use_alt_language", RC_USE_ALT_LANG },
{ "\\use_escape_chars", RC_USE_ESC_CHARS },
+ { "\\use_gui", RC_USE_GUI },
{ "\\use_input_encoding", RC_USE_INP_ENC },
{ "\\use_personal_dictionary", RC_USE_PERS_DICT },
{ "\\use_tempdir", RC_USETEMPDIR },
print_to_printer = "-P";
print_to_file = "-o ";
print_file_extension = ".ps";
- print_paper_flag = "-t";
+ print_paper_flag = "-t";
print_paper_dimension_flag = "-T";
document_path = GetEnvPath("HOME");
tempdir_path = "/tmp";
///
date_insert_format = "%A, %e %B %Y";
show_banner = true;
+ use_gui = true;
//
defaultKeyBindings();
}
if (lexrc.next())
show_banner = lexrc.GetBool();
break;
+ case RC_USE_GUI:
+ if (lexrc.next())
+ use_gui = lexrc.GetBool();
+ break;
case RC_LAST: break; // this is just a dummy
}
}
<< "\"\n";
case RC_SHOW_BANNER:
os << "\\show_banner " << tostr(show_banner) << "\n";
+ case RC_USE_GUI:
+ os << "\\use_gui " << tostr(show_banner) << "\n";
}
os.flush();
}
string auto_mathmode;
///
bool show_banner;
+ /// Do we have to use a GUI?
+ bool use_gui;
///
typedef map<string, int> Bindings;
///