diff -urdN lyx-1.2.0/acinclude.m4 CJK-LyX-1.2.0/acinclude.m4 --- lyx-1.2.0/acinclude.m4 Thu May 23 21:05:08 2002 +++ CJK-LyX-1.2.0/acinclude.m4 Tue Jul 9 15:55:40 2002 @@ -206,13 +206,13 @@ CXXFLAGS="$ac_save_CXXFLAGS" else case $gxx_version in - 2.95.1) CXXFLAGS="$lyx_opt -fpermissive -fno-rtti -fno-exceptions";; - 2.95.2) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - 2.95.*) CXXFLAGS="$lyx_opt -fno-exceptions";; - 2.96*) CXXFLAGS="$lyx_opt -fno-exceptions";; - 3.0*) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - *2.91.*) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - *) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; + 2.95.1) CXXFLAGS="-DI18N $lyx_opt -fpermissive -fno-rtti -fno-exceptions";; + 2.95.2) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + 2.95.*) CXXFLAGS="-DI18N $lyx_opt -fno-exceptions";; + 2.96*) CXXFLAGS="-DI18N $lyx_opt -fno-exceptions";; + 3.0*) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + *2.91.*) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + *) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; esac if test x$enable_debug = xyes ; then CXXFLAGS="-g $CXXFLAGS" @@ -220,9 +220,9 @@ fi if test x$enable_warnings = xyes ; then case $gxx_version in - 2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall";; - 2.96*) CXXFLAGS="$CXXFLAGS -W -Wall";; - *) CXXFLAGS="$CXXFLAGS -W -Wall";; + 2.95.*) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; + 2.96*) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; + *) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; esac if test $lyx_devel_version = yes ; then case $gxx_version in diff -urdN lyx-1.2.0/aclocal.m4 CJK-LyX-1.2.0/aclocal.m4 --- lyx-1.2.0/aclocal.m4 Thu May 23 21:05:10 2002 +++ CJK-LyX-1.2.0/aclocal.m4 Tue Jul 9 15:55:40 2002 @@ -216,13 +216,13 @@ CXXFLAGS="$ac_save_CXXFLAGS" else case $gxx_version in - 2.95.1) CXXFLAGS="$lyx_opt -fpermissive -fno-rtti -fno-exceptions";; - 2.95.2) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - 2.95.*) CXXFLAGS="$lyx_opt -fno-exceptions";; - 2.96*) CXXFLAGS="$lyx_opt -fno-exceptions";; - 3.0*) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - *2.91.*) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - *) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; + 2.95.1) CXXFLAGS="-DI18N $lyx_opt -fpermissive -fno-rtti -fno-exceptions";; + 2.95.2) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + 2.95.*) CXXFLAGS="-DI18N $lyx_opt -fno-exceptions";; + 2.96*) CXXFLAGS="-DI18N $lyx_opt -fno-exceptions";; + 3.0*) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + *2.91.*) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + *) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; esac if test x$enable_debug = xyes ; then CXXFLAGS="-g $CXXFLAGS" @@ -230,9 +230,9 @@ fi if test x$enable_warnings = xyes ; then case $gxx_version in - 2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall";; - 2.96*) CXXFLAGS="$CXXFLAGS -W -Wall";; - *) CXXFLAGS="$CXXFLAGS -W -Wall";; + 2.95.*) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; + 2.96*) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; + *) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; esac if test $lyx_devel_version = yes ; then case $gxx_version in diff -urdN lyx-1.2.0/config/lyxinclude.m4 CJK-LyX-1.2.0/config/lyxinclude.m4 --- lyx-1.2.0/config/lyxinclude.m4 Tue Apr 2 11:47:37 2002 +++ CJK-LyX-1.2.0/config/lyxinclude.m4 Tue Jul 9 15:55:40 2002 @@ -206,13 +206,13 @@ CXXFLAGS="$ac_save_CXXFLAGS" else case $gxx_version in - 2.95.1) CXXFLAGS="$lyx_opt -fpermissive -fno-rtti -fno-exceptions";; - 2.95.2) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - 2.95.*) CXXFLAGS="$lyx_opt -fno-exceptions";; - 2.96*) CXXFLAGS="$lyx_opt -fno-exceptions";; - 3.0*) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - *2.91.*) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; - *) CXXFLAGS="$lyx_opt -fno-rtti -fno-exceptions";; + 2.95.1) CXXFLAGS="-DI18N $lyx_opt -fpermissive -fno-rtti -fno-exceptions";; + 2.95.2) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + 2.95.*) CXXFLAGS="-DI18N $lyx_opt -fno-exceptions";; + 2.96*) CXXFLAGS="-DI18N $lyx_opt -fno-exceptions";; + 3.0*) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + *2.91.*) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; + *) CXXFLAGS="-DI18N $lyx_opt -fno-rtti -fno-exceptions";; esac if test x$enable_debug = xyes ; then CXXFLAGS="-g $CXXFLAGS" @@ -220,9 +220,9 @@ fi if test x$enable_warnings = xyes ; then case $gxx_version in - 2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall";; - 2.96*) CXXFLAGS="$CXXFLAGS -W -Wall";; - *) CXXFLAGS="$CXXFLAGS -W -Wall";; + 2.95.*) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; + 2.96*) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; + *) CXXFLAGS="-DI18N $CXXFLAGS -W -Wall";; esac if test $lyx_devel_version = yes ; then case $gxx_version in diff -urdN lyx-1.2.0/src/BufferView.C CJK-LyX-1.2.0/src/BufferView.C --- lyx-1.2.0/src/BufferView.C Tue Apr 23 22:35:41 2002 +++ CJK-LyX-1.2.0/src/BufferView.C Tue Jul 9 15:55:40 2002 @@ -46,6 +46,20 @@ return pimpl_->screen_.get(); } +#ifdef I18N +int BufferView::xpos() const +{ + return pimpl_->workarea_.xpos(); +} +int BufferView::ypos() const +{ + return pimpl_->workarea_.ypos(); +} +int BufferView::height() const +{ + return pimpl_->workarea_.height(); +} +#endif LyXView * BufferView::owner() const { diff -urdN lyx-1.2.0/src/BufferView.h CJK-LyX-1.2.0/src/BufferView.h --- lyx-1.2.0/src/BufferView.h Tue Apr 23 22:35:41 2002 +++ CJK-LyX-1.2.0/src/BufferView.h Tue Jul 9 15:55:40 2002 @@ -3,7 +3,7 @@ * Copyright 2002 the LyX Team * Read the file COPYING * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bj?nnes */ #ifndef BUFFER_VIEW_H @@ -29,7 +29,9 @@ class Language; class Painter; class UpdatableInset; - +#ifdef I18N + class LColor; +#endif /// class BufferView : boost::noncopyable { public: @@ -55,6 +57,11 @@ Painter & painter(); /// LyXScreen * screen() const; +#ifdef I18N + int xpos() const; + int ypos() const; + int height() const; +#endif /// void buffer(Buffer * b); /// @@ -85,6 +92,11 @@ bool available() const; /// LyXView * owner() const; +#ifdef I18N + LColor * getColor() { + return color; + } +#endif /// void beforeChange(LyXText *); /// @@ -223,6 +235,9 @@ friend struct BufferView::Pimpl; /// Pimpl * pimpl_; +#ifdef I18N + LColor * color; +#endif }; diff -urdN lyx-1.2.0/src/BufferView_pimpl.C CJK-LyX-1.2.0/src/BufferView_pimpl.C --- lyx-1.2.0/src/BufferView_pimpl.C Thu May 16 08:50:47 2002 +++ CJK-LyX-1.2.0/src/BufferView_pimpl.C Tue Jul 9 15:55:40 2002 @@ -87,6 +87,12 @@ using lyx::pos_type; using lyx::textclass_type; +#ifdef I18N +#include "BufferView.h" +#include "lyxim.h" + extern LyXIM lyxim; +#endif + /* the selection possible is needed, that only motion events are * used, where the bottom press event was on the drawing area too */ bool selection_possible = false; @@ -150,6 +156,10 @@ .connect(slot(this, &BufferView::Pimpl::doubleClick)); workarea_.workAreaTripleClick .connect(slot(this, &BufferView::Pimpl::tripleClick)); +#ifdef I18N + workarea_.workAreaCJK_IMprocess + .connect(slot(this, &BufferView::Pimpl::workAreaCJK_IMprocess)); +#endif workarea_.workAreaKeyPress .connect(slot(this, &BufferView::Pimpl::workAreaKeyPress)); workarea_.selectionRequested @@ -170,7 +180,6 @@ return workarea_.getPainter(); } - void BufferView::Pimpl::buffer(Buffer * b) { lyxerr[Debug::INFO] << "Setting buffer in BufferView (" @@ -470,6 +479,10 @@ else if (vbt->cursor.y() > last) vbt->setCursorFromCoordinates(bv_, 0, last); +#ifdef I18N + lyxim.SetIMSpot(); +#endif + waitForX(); } @@ -541,6 +554,12 @@ return 0; } +#ifdef I18N + void BufferView::Pimpl::workAreaCJK_IMprocess(int num_bytes, char * s_r) +{ + bv_->owner()->getLyXFunc()->CJK_IMprocess(num_bytes, s_r); +} +#endif void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, unsigned int state) { @@ -1078,6 +1097,9 @@ // always make sure that the scrollbar is sane. updateScrollbar(); +#ifdef I18N + lyxim.SetIMSpotAndArea(); +#endif owner_->updateLayoutChoice(); return; } @@ -1178,6 +1200,9 @@ if ((f & CHANGE)) { buffer_->markDirty(); } +#ifdef I18N + lyxim.SetIMSpot(); +#endif } diff -urdN lyx-1.2.0/src/BufferView_pimpl.h CJK-LyX-1.2.0/src/BufferView_pimpl.h --- lyx-1.2.0/src/BufferView_pimpl.h Tue Apr 23 22:35:43 2002 +++ CJK-LyX-1.2.0/src/BufferView_pimpl.h Tue Jul 9 15:55:40 2002 @@ -28,7 +28,7 @@ int xpos, int ypos, int width, int height); /// Painter & painter(); - /// + /// void buffer(Buffer *); /// void resize(int xpos, int ypos, int width, int height); @@ -65,6 +65,9 @@ /// int scrollDown(long time); /// +#ifdef I18N + void workAreaCJK_IMprocess(int, char * s_r); +#endif void workAreaKeyPress(KeySym, unsigned int state); /// void workAreaMotionNotify(int x, int y, unsigned int state); diff -urdN lyx-1.2.0/src/FontLoader.C CJK-LyX-1.2.0/src/FontLoader.C --- lyx-1.2.0/src/FontLoader.C Fri Mar 22 02:25:07 2002 +++ CJK-LyX-1.2.0/src/FontLoader.C Tue Jul 9 15:55:40 2002 @@ -63,9 +63,19 @@ for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) for (int i2 = 0; i2 < 2; ++i2) for (int i3 = 0; i3 < 4; ++i3) { +#ifdef I18N + for (int i4=0; i4<3; ++i4) + fontinfo[i4][i1][i2][i3] = 0; +#else fontinfo[i1][i2][i3] = 0; +#endif for (int i4 = 0; i4<10; ++i4) { +#ifdef I18N + fontset[i1][i2][i3][i4] = 0; + math[i1][i2][i3][i4] = 0; +#else fontstruct[i1][i2][i3][i4] = 0; +#endif } } } @@ -78,15 +88,34 @@ for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) for (int i2 = 0; i2 < 2; ++i2) for (int i3 = 0; i3 < 4; ++i3) { +#ifdef I18N + for (int i4=0; i4<3; ++i4) + if (fontinfo[i4][i1][i2][i3]) { + delete fontinfo[i4][i1][i2][i3]; + fontinfo[i4][i1][i2][i3] = 0; + }; +#else if (fontinfo[i1][i2][i3]) { delete fontinfo[i1][i2][i3]; fontinfo[i1][i2][i3] = 0; } +#endif for (int i4 = 0; i4 < 10; ++i4) { +#ifdef I18N + if (fontset[i1][i2][i3][i4]){ + XFreeFontSet(GUIRunTime::x11Display(), fontset[i1][i2][i3][i4]); + fontset[i1][i2][i3][i4] = 0; + } + if (math[i1][i2][i3][i4]) { + XFreeFont(GUIRunTime::x11Display(), math[i1][i2][i3][i4]); + math[i1][i2][i3][i4] = 0; + } +#else if (fontstruct[i1][i2][i3][i4]) { XFreeFont(GUIRunTime::x11Display(), fontstruct[i1][i2][i3][i4]); fontstruct[i1][i2][i3][i4] = 0; } +#endif } } } @@ -95,54 +124,95 @@ // Get font info /* Takes care of finding which font that can match the given request. Tries different alternatives. */ +#ifdef I18N + void FontLoader::getFontinfo(int fonttype, + LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape) + { + if (fontinfo[fonttype][family][series][shape] != 0) +#else void FontLoader::getFontinfo(LyXFont::FONT_FAMILY family, LyXFont::FONT_SERIES series, LyXFont::FONT_SHAPE shape) { // Do we have the font info already? if (fontinfo[family][series][shape] != 0) +#endif return; // Special fonts switch (family) { case LyXFont::SYMBOL_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific"); return; case LyXFont::CMR_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*"); return; case LyXFont::CMSY_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*"); return; case LyXFont::CMM_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*"); return; case LyXFont::CMEX_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*"); return; case LyXFont::MSA_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*"); return; case LyXFont::MSB_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*"); return; case LyXFont::EUFRAK_FAMILY: +#ifdef I18N + fontinfo[fonttype][family][series][shape] = +#else fontinfo[family][series][shape] = +#endif new FontInfo("-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*"); return; @@ -155,14 +225,47 @@ string ffamily; string fseries; string fshape; +#ifdef I18N + string norm; + if (fonttype==1 || fonttype==2) + norm = lyxrc.i18n_font_norm[fonttype-1]; + else + norm = lyxrc.font_norm; +#else string norm = lyxrc.font_norm; +#endif string fontname; FontInfo * fi = new FontInfo(); +#ifdef I18N + fontinfo[fonttype][family][series][shape] = fi; +#else fontinfo[family][series][shape] = fi; +#endif for (int cfam = 0; cfam < 2; ++cfam) { // Determine family name +#ifdef I18N + if (fonttype==1 || fonttype==2) + switch(series){ + case LyXFont::MEDIUM_SERIES: + switch (cfam) { + case 0: ffamily = lyxrc.i18n_normal_font_name[fonttype-1]; break; + case 1: ffamily = "-*-mincho"; + default: cfam = 100; + } + break; + case LyXFont::BOLD_SERIES: + switch (cfam) { + case 0: ffamily = lyxrc.i18n_gothic_font_name[fonttype-1]; break; + case 1: ffamily = "-*-gothic"; + default: cfam = 100; + } + break; + default: ; + } + else{ +#endif switch (family) { case LyXFont::ROMAN_FAMILY: switch (cfam) { @@ -187,15 +290,27 @@ break; default: ; } +#ifdef I18N + } +#endif +#ifdef I18N + for (int cser=0; cser < 5; ++cser) { +#else for (int cser = 0; cser < 4; ++cser) { +#endif // Determine series name switch (series) { case LyXFont::MEDIUM_SERIES: switch (cser) { case 0: fseries = "-medium"; break; case 1: fseries = "-book"; break; +#ifdef I18N + case 2: fseries = "-light"; break; + case 3: fseries = "-*"; +#else case 2: fseries = "-light"; +#endif default: cser = 100; } break; @@ -204,14 +319,22 @@ case 0: fseries = "-bold"; break; case 1: fseries = "-black"; break; case 2: fseries = "-demi"; break; +#ifdef I18N + case 3: fseries = "-demibold"; break; + case 4: fseries = "-*"; +#else case 3: fseries = "-demibold"; +#endif default: cser = 100; } break; default: ; } - +#ifdef I18N + for (int csha = 0; csha < 2; ++csha) { +#else for (int csha = 0; csha < 2; ++csha) { +#endif // Determine shape name switch (shape) { case LyXFont::UP_SHAPE: @@ -259,6 +382,15 @@ } // namespace anon /// Do load font +#ifdef I18N + XFontSet FontLoader::doLoad(LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape, + LyXFont::FONT_SIZE size) + { + int fonttype = 0; + getFontinfo(fonttype,family, series, shape); +#else XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family, LyXFont::FONT_SERIES series, LyXFont::FONT_SHAPE shape, @@ -279,21 +411,62 @@ } getFontinfo(family, series, shape); +#endif int fsize = int((lyxrc.font_sizes[size] * lyxrc.dpi * (lyxrc.zoom/100.0)) / 72.27 + 0.5); - +#ifdef I18N + string font = fontinfo[fonttype][family][series][shape]->getFontname(fsize); +#else string font = fontinfo[family][series][shape]->getFontname(fsize); +#endif +#ifdef I18N + for (int i=1;i<3;i++){ + if (lyxrc.i18n_font_use[i-1]){ + getFontinfo(i,family,series,shape); + font = font +","+ fontinfo[i][family][series][shape]->getFontname(fsize); + } + } +#endif if (font.empty()) { lyxerr << "No font matches request. Using 'fixed'." << endl; lyxerr << "Start LyX as 'lyx -dbg 515' to get more information." << endl; font = "fixed"; } +#ifdef I18N + XFontSet fs=0; +#else XFontStruct * fs = 0; +#endif current_view->owner()->messagePush(_("Loading font into X-Server...")); +#ifdef I18N + char **missing_list, *def_string; + int missing_count; + + // XFontSet fs=0; + // lyxerr << "Load fontset. " + font << endl; + fs=XCreateFontSet(GUIRunTime::x11Display(), font.c_str(),&missing_list,&missing_count,&def_string); + if (!fs) { + lyxerr << "Could not get fontset. " << font << " Using 'fixed'." << endl; + font = font +",*-fixed-*"; + fs=XCreateFontSet(GUIRunTime::x11Display(),font.c_str(),&missing_list,&missing_count,&def_string); + } + if (missing_count > 0) { + lyxerr << "Could not get fontset. " << font << endl; + for (int i = 0; i < missing_count; i++) { + lyxerr << "Cannot load fontset " << string(missing_list[i]) << endl; + } + + XFreeStringList(missing_list); + lyxerr << " Using 'fixed'." << endl; + XFreeFontSet(GUIRunTime::x11Display(), fs); + font = font +",*-fixed-*"; + fs=XCreateFontSet(GUIRunTime::x11Display(),font.c_str(),&missing_list,&missing_count,&def_string); + } +#else fs = XLoadQueryFont(GUIRunTime::x11Display(), font.c_str()); if (fs == 0) { @@ -318,10 +491,14 @@ lyxerr << "Font '" << f.stateText(0) << "' matched by\n" << font << endl; } - +#endif current_view->owner()->messagePop(); +#ifdef I18N + fontset[family][series][shape][size] = fs; +#else fontstruct[family][series][shape][size] = fs; +#endif return fs; } @@ -330,9 +507,68 @@ { if (!lyxrc.use_gui) return false; - +#ifdef I18N + if (!fontinfo[0][f.family()][f.series()][f.realShape()]) + getFontinfo(0,f.family(), f.series(), f.realShape()); + return fontinfo[0][f.family()][f.series()][f.realShape()] +#else if (!fontinfo[f.family()][f.series()][f.realShape()]) getFontinfo(f.family(), f.series(), f.realShape()); return fontinfo[f.family()][f.series()][f.realShape()] +#endif ->getFontname(f.size()).size(); } + +#ifdef I18N + XFontStruct * FontLoader::doLoadMath(LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape, + LyXFont::FONT_SIZE size) + { + getFontinfo(0,family,series,shape); + int fsize = (int) ( (lyxrc.font_sizes[size] * lyxrc.dpi * + (lyxrc.zoom/100.0) ) / 72.27 + 0.5 ); + + string font = fontinfo[0][family][series][shape]->getFontname(fsize); + + if (font.empty()) { + lyxerr << "No font matches request. Using 'fixed'." << endl; + lyxerr << "Start LyX as 'lyx -dbg 515' to get more information." << endl; + font = "fixed"; + } + + // current_view->owner()->getMiniBuffer()->Store(); + current_view->owner()->messagePush(_("Loading font into X-Server...")); + + XFontStruct * fs = XLoadQueryFont(GUIRunTime::x11Display(), font.c_str()); + + if (fs == 0) { + if (font == "fixed") { + lyxerr << "We're doomed. Can't get 'fixed' font." << endl; + } else { + lyxerr << "Could not get font. Using 'fixed'." << endl; + fs = XLoadQueryFont(GUIRunTime::x11Display(), "fixed"); + } + } else { + if (lyxerr.debugging(Debug::FONT)) { + // Tell user the font matching + LyXFont f; + f.setFamily(family); + f.setSeries(series); + f.setShape(shape); + f.setSize(size); + // The rest of the attributes are not interesting + f.setEmph(LyXFont::INHERIT); + f.setUnderbar(LyXFont::INHERIT); + f.setNoun(LyXFont::INHERIT); + f.setColor(LColor::inherit); + lyxerr << "Font '" << f.stateText(0) + << "' matched by\n" << font << endl; + } + } + current_view->owner()->messagePop(); + + math[family][series][shape][size] = fs; + return fs; + } + #endif diff -urdN lyx-1.2.0/src/FontLoader.h CJK-LyX-1.2.0/src/FontLoader.h --- lyx-1.2.0/src/FontLoader.h Fri Mar 22 02:25:07 2002 +++ CJK-LyX-1.2.0/src/FontLoader.h Tue Jul 9 15:55:40 2002 @@ -20,6 +20,10 @@ #include "lyxfont.h" #include "LString.h" +#ifdef I18N + class lyxstring; +#endif + class FontInfo; /** This class takes care of loading fonts. It uses FontInfo to make @@ -39,6 +43,29 @@ void update(); /// Load font +#ifdef I18N + /// Load fontset + XFontSet load(LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape, + LyXFont::FONT_SIZE size) + { + if (fontset[family][series][shape][size]!=0) + return fontset[family][series][shape][size]; + else + return doLoad(family,series,shape,size); + }; + XFontStruct* loadMath(LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape, + LyXFont::FONT_SIZE size) + { + if (math[family][series][shape][size]!=0) + return math[family][series][shape][size]; + else + return doLoadMath(family,series,shape,size); + }; +#else XFontStruct * load(LyXFont::FONT_FAMILY family, LyXFont::FONT_SERIES series, LyXFont::FONT_SHAPE shape, @@ -48,15 +75,26 @@ else return doLoad(family, series, shape, size); }; +#endif /// Do we have anything matching? bool available(LyXFont const & f); private: /// Array of font structs +#ifdef I18N + XFontSet fontset[LyXFont::NUM_FAMILIES][2][4][10]; + XFontStruct* math[LyXFont::NUM_FAMILIES][2][4][10]; + FontInfo * fontinfo[3][LyXFont::NUM_FAMILIES][2][4]; + void getFontinfo(int fonttype, + LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape); +#else XFontStruct * fontstruct[LyXFont::NUM_FAMILIES][2][4][10]; /// Array of font infos FontInfo * fontinfo[LyXFont::NUM_FAMILIES][2][4]; +#endif /// Reset font handler void reset(); @@ -65,15 +103,28 @@ void unload(); /// Get font info +#ifndef I18N void getFontinfo(LyXFont::FONT_FAMILY family, LyXFont::FONT_SERIES series, LyXFont::FONT_SHAPE shape); +#endif /** Does the actual loading of a font. Updates fontstruct. */ +#ifdef I18N + XFontSet doLoad(LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape, + LyXFont::FONT_SIZE size); + XFontStruct* doLoadMath(LyXFont::FONT_FAMILY family, + LyXFont::FONT_SERIES series, + LyXFont::FONT_SHAPE shape, + LyXFont::FONT_SIZE size); +#else XFontStruct * doLoad(LyXFont::FONT_FAMILY family, LyXFont::FONT_SERIES series, LyXFont::FONT_SHAPE shape, LyXFont::FONT_SIZE size); +#endif }; /// diff -urdN lyx-1.2.0/src/Makefile.am CJK-LyX-1.2.0/src/Makefile.am --- lyx-1.2.0/src/Makefile.am Tue Mar 26 07:07:48 2002 +++ CJK-LyX-1.2.0/src/Makefile.am Tue Jul 9 15:55:40 2002 @@ -228,8 +228,12 @@ vc-backend.h \ version.C \ version.h \ + lyxim.C \ + lyxim.h \ vspace.C \ - vspace.h + vspace.h \ + lyxcodeconv.C \ + lyxcodeconv.h lyx_main.o: lyx_main.C lyx_main.h config.h version.h lyx_gui.h \ lyxrc.h support/path.h support/filetools.h \ diff -urdN lyx-1.2.0/src/Painter.C CJK-LyX-1.2.0/src/Painter.C --- lyx-1.2.0/src/Painter.C Fri Mar 22 02:25:08 2002 +++ CJK-LyX-1.2.0/src/Painter.C Tue Jul 9 15:55:40 2002 @@ -35,6 +35,11 @@ #include +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#endif + using std::endl; using std::max; @@ -184,7 +189,17 @@ PainterBase & Painter::text(int x, int y, string const & s, LyXFont const & f) { +#ifdef I18N + if (f.family()== LyXFont::SYMBOL_FAMILY) + return text(x, y, s.data(), s.length(), f); + else { + wchar_t * wcs = new wchar_t[s.length()+1]; + int len=codeconverter.lyxmbstowcs(wcs,&s); + wcs[len] = '\0'; + return text(x, y, wcs, len, f);} +#else return text(x, y, s.data(), s.length(), f); +#endif } @@ -194,10 +209,55 @@ return text(x, y, s, 1, f); } +#ifdef I18N + PainterBase & Painter::text(int x, int y, wchar_t const * s, int ls, + LyXFont const & f) + { + if (lyxerr.debugging()) { + lyxerr << "text not called from " + "workarea::workhandler\n"; + lyxerr << "Painter drawable: " << owner.getPixmap() << endl; + } + GC gc = lyxColorHandler->getGCForeground(f.realColor()); + if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) { //printf("%s",1); + lyxfont::XSetFont(display(), gc, f); + XwcDrawString(display(), owner.getPixmap(), f.getXFontset(), gc, x, y, s, ls); + } else { + LyXFont smallfont(f); + smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE); + wchar_t c; + int tmpx = x; + for(size_t i = 0; i < ls; ++i) { + c = uppercase(s[i]); + // if (islower(static_cast(c))) { + // if ((c < 0xff) && (islower((unsigned char) c))){ + // c = toupper((unsigned char)c); + if(c != s[i]) { + lyxfont::XSetFont(display(), gc, smallfont); + XwcDrawString(display(), owner.getPixmap(), + f.getXFontset(), gc, tmpx, y, &c, 1); + tmpx += XwcTextEscapement(smallfont.getXFontset(), &c,1); + //tmpx += lyxfont::width(c, f); + } else { + lyxfont::XSetFont(display(), gc, f); + XwcDrawString(display(), owner.getPixmap(), + f.getXFontset(), gc, tmpx, y, &c, 1); + tmpx += XwcTextEscapement(f.getXFontset(), &c,1); + // tmpx += lyxfont::width(c, f); + } + } + } + + if (f.underbar() == LyXFont::ON) + underline(f, x, y, lyxfont::width(s, ls, f)); + return *this; + } +#endif PainterBase & Painter::text(int x, int y, char const * s, size_t ls, LyXFont const & f) { +#ifndef I18N if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) { boost::scoped_array xs(new XChar2b[ls]); Encoding const * encoding = f.language()->encoding(); @@ -217,6 +277,9 @@ text(x , y, xs.get(), ls, font); return *this; } +#endif + + GC gc = lyxColorHandler->getGCForeground(f.realColor()); if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) { @@ -249,7 +312,7 @@ return *this; } - +#ifndef I18N PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls, LyXFont const & f) { @@ -289,7 +352,7 @@ return *this; } - +#endif void Painter::underline(LyXFont const & f, int x, int y, int width) { diff -urdN lyx-1.2.0/src/Painter.h CJK-LyX-1.2.0/src/Painter.h --- lyx-1.2.0/src/Painter.h Fri Mar 22 02:25:09 2002 +++ CJK-LyX-1.2.0/src/Painter.h Tue Jul 9 15:55:40 2002 @@ -87,6 +87,11 @@ PainterBase & text(int x, int y, char const * str, size_t l, LyXFont const & f); +#ifdef I18N + PainterBase & text(int x, int y, wchar_t const * str, int l, + LyXFont const & f); +#endif + /// Draw a char at position x, y (y is the baseline) PainterBase & text(int x, int y, char c, LyXFont const & f); diff -urdN lyx-1.2.0/src/PainterBase.h CJK-LyX-1.2.0/src/PainterBase.h --- lyx-1.2.0/src/PainterBase.h Fri Mar 22 02:25:09 2002 +++ CJK-LyX-1.2.0/src/PainterBase.h Tue Jul 9 15:55:40 2002 @@ -151,6 +151,10 @@ /** Draw a string at position x, y (y is the baseline) This is just for fast drawing */ +#ifdef I18N + virtual PainterBase & text(int x, int y, wchar_t const * str, int l, + LyXFont const & f) = 0; +#endif virtual PainterBase & text(int x, int y, char const * str, size_t l, LyXFont const & f) = 0; diff -urdN lyx-1.2.0/src/WorkArea.C CJK-LyX-1.2.0/src/WorkArea.C --- lyx-1.2.0/src/WorkArea.C Thu May 2 07:17:05 2002 +++ CJK-LyX-1.2.0/src/WorkArea.C Tue Jul 9 15:55:40 2002 @@ -39,6 +39,11 @@ using std::abs; using std::hex; +#ifdef I18N +#include "lyxim.h" + extern LyXIM lyxim; +#endif + namespace { inline @@ -359,6 +364,9 @@ ev->xbutton.y - ob->y, ev->xbutton.button); //area->workAreaKeyPress(XK_Pointer_Button1, ev->xbutton.state); +#ifdef I18N + lyxim.SetIMSpot(); +#endif break; case FL_RELEASE: if (!ev || ev->xbutton.button == 0) break; @@ -367,6 +375,9 @@ area->workAreaButtonRelease(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, ev->xbutton.button); +#ifdef I18N + lyxim.SetIMSpot(); +#endif break; #if FL_REVISION < 89 case FL_MOUSE: @@ -393,12 +404,21 @@ lyxerr[Debug::WORKAREA] << "Workarea event: KEYBOARD" << endl; KeySym keysym = 0; +#ifdef I18N + char s_r[256]; +#else char dummy[1]; +#endif + XKeyEvent * xke = reinterpret_cast(ev); #if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5) // XForms < 0.89.5 does not have compose support // so we are using our own compose support +#ifdef I18N + int num_bytes = LyXLookupString(ev, s_r, 256, &keysym); +#else LyXLookupString(ev, dummy, 1, &keysym); +#endif #else XLookupString(xke, dummy, 1, &keysym, 0); // int num_keys = XLookupString(xke, dummy, 10, &keysym, &xcs); @@ -417,6 +437,11 @@ << keysym << "]" << endl; } +#ifdef I18N + if (keysym == 0 && num_bytes !=0) + area->workAreaCJK_IMprocess(num_bytes,s_r); +#endif + #if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5) if (keysym == NoSymbol) { lyxerr[Debug::KEY] @@ -503,10 +528,16 @@ case FL_FOCUS: lyxerr[Debug::WORKAREA] << "Workarea event: FOCUS" << endl; area->workAreaFocus(); +#ifdef I18N + lyxim.focusIn(); +#endif break; case FL_UNFOCUS: lyxerr[Debug::WORKAREA] << "Workarea event: UNFOCUS" << endl; area->workAreaUnfocus(); +#ifdef I18N + lyxim.focusOut(); +#endif break; case FL_ENTER: lyxerr[Debug::WORKAREA] << "Workarea event: ENTER" << endl; diff -urdN lyx-1.2.0/src/WorkArea.h CJK-LyX-1.2.0/src/WorkArea.h --- lyx-1.2.0/src/WorkArea.h Fri Mar 22 02:25:09 2002 +++ CJK-LyX-1.2.0/src/WorkArea.h Tue Jul 9 15:55:40 2002 @@ -107,6 +107,10 @@ /// SigC::Signal1 scrollCB; /// +#ifdef I18N + SigC::Signal2 workAreaCJK_IMprocess; +#endif + /// SigC::Signal2 workAreaKeyPress; /// SigC::Signal3 workAreaButtonPress; diff -urdN lyx-1.2.0/src/buffer.C CJK-LyX-1.2.0/src/buffer.C --- lyx-1.2.0/src/buffer.C Tue May 21 22:10:23 2002 +++ CJK-LyX-1.2.0/src/buffer.C Tue Jul 9 15:55:40 2002 @@ -7,7 +7,7 @@ * Copyright 1995-2001 The LyX Team. * * This file is Copyright 1996-2001 - * Lars Gullik Bjønnes + * Lars Gullik Bj?nnes * * ====================================================== */ @@ -130,6 +130,13 @@ using lyx::pos_type; using lyx::textclass_type; + +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#include "lyxim.h" +extern LyXIM lyxim; +#endif // all these externs should eventually be removed. extern BufferList bufferlist; @@ -487,11 +494,22 @@ ert_comp.contents += token; } else { #endif + +#ifdef I18N + wchar_t *wtoken = new wchar_t [token.length()+1]; + int len = codeconverter.lyxmbstowcs(wtoken,&token); + for (int i=0; i < len; i++) { + par->insertChar(pos, wtoken[i], font); + // par->SetFont(pos, font); + ++pos; + } +#else for (string::const_iterator cit = token.begin(); cit != token.end(); ++cit) { par->insertChar(pos, (*cit), font); ++pos; } +#endif #ifndef NO_COMPABILITY } #endif @@ -1261,7 +1279,7 @@ #endif } else if (token == "\\the_end") { #ifndef NO_COMPABILITY - // If we still have some ert active here we have to insert + //?If we still have some ert active here we have to insert // it so we don't loose it. (Lgb) insertErtContents(par, pos); #endif @@ -1496,9 +1514,21 @@ bool space_inserted = true; bool autobreakrows = !par->inInset() || static_cast(par->inInset())->getAutoBreakRows(); - for(string::const_iterator cit = str.begin(); - cit != str.end(); ++cit) { +#ifdef I18N + wchar_t *wstr = new wchar_t [str.length()+1]; + int len = codeconverter.lyxmbstowcs(wstr,&str); + for (int i=0; i < len; i++) { +#else + for(string::const_iterator cit = str.begin(); + cit != str.end(); ++cit) { +#endif + +#ifdef I18N + if (wstr[i] == '\n') { +#else if (*cit == '\n') { +#endif + if (autobreakrows && (par->size() || layout.keepempty)) { par->breakParagraph(params, pos, layout.isEnvironment()); @@ -1509,12 +1539,20 @@ continue; } // do not insert consecutive spaces if !free_spacing +#ifdef I18N + } else if ((wstr[i] == ' ' || wstr[i] == '\t') && +#else } else if ((*cit == ' ' || *cit == '\t') && +#endif space_inserted && !layout.free_spacing && !par->isFreeSpacing()) { continue; +#ifdef I18N + } else if (wstr[i] == '\t') { +#else } else if (*cit == '\t') { +#endif if (!layout.free_spacing && !par->isFreeSpacing()) { // tabs are like spaces here par->insertChar(pos, ' ', font); @@ -1528,14 +1566,25 @@ } space_inserted = true; } +#ifndef I18N } else if (!IsPrintable(*cit)) { +#endif // Ignore unprintables continue; } else { // just insert the character +#ifdef I18N + par->insertChar(pos, wstr[i], font); +#else par->insertChar(pos, *cit, font); +#endif ++pos; - space_inserted = (*cit == ' '); + +#ifdef I18N + space_inserted = (wstr[i] == ' '); +#else + space_inserted = (*cit == ' '); +#endif } } @@ -2043,7 +2092,11 @@ string word; for (pos_type i = 0; i < par->size(); ++i) { +#ifdef I18N + wchar_t c = par->getUChar(params, i); +#else char c = par->getUChar(params, i); +#endif switch (c) { case Paragraph::META_INSET: { @@ -3127,7 +3180,11 @@ os << "<" << tag_name(*j) << ">"; } +#ifdef I18N + wchar_t c = par->getChar(i); +#else char c = par->getChar(i); +#endif if (c == Paragraph::META_INSET) { Inset * inset = par->getInset(i); @@ -3139,7 +3196,11 @@ if (style.latexparam() == "CDATA") { // "TeX"-Mode on == > SGML-Mode on. if (c != '\0') +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif ++char_line_count; } else { string sgml_string; @@ -3156,7 +3217,11 @@ desc_on = false; } else { sgmlLineBreak(os, char_line_count, 1); +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif } } else { os << sgml_string; @@ -3560,12 +3625,20 @@ os << "getChar(i); +#else char c = par->getChar(i); +#endif string sgml_string; par->sgmlConvertChar(c, sgml_string); if (style.pass_thru) { +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif } else if (style.free_spacing || par->isFreeSpacing() || c != ' ') { os << sgml_string; } else if (desc_on ==1) { diff -urdN lyx-1.2.0/src/font.C CJK-LyX-1.2.0/src/font.C --- lyx-1.2.0/src/font.C Fri Mar 22 02:25:09 2002 +++ CJK-LyX-1.2.0/src/font.C Tue Jul 9 15:55:40 2002 @@ -23,37 +23,93 @@ #include +#ifdef I18N +#include "lyxfont.h" +#include "Painter.h" +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#endif namespace { - +#ifdef I18N + XFontSet LyXFont::getXFontset() const + { + return fontloader.load(LyXFont::family(),LyXFont::series(),LyXFont::realShape(),LyXFont::size()); + } + inline + XFontStruct* getMathFont(LyXFont const & f) + { + return fontloader.loadMath(f.family(),f.series(),f.realShape(),f.size()); + } +#else inline XFontStruct * getXFontstruct(LyXFont const & f) { return fontloader.load(f.family(), f.series(), f.realShape(), f.size()); } - +#endif inline XID getFontID(LyXFont const & f) { +#ifdef I18N + return getMathFont(f)->fid; +#else return getXFontstruct(f)->fid; +#endif } - +#ifdef I18N + XOC getFontSet(LyXFont const & f) { + return f.getXFontset(); + } +#endif } // namespace anon int lyxfont::maxAscent(LyXFont const & f) { +#ifdef I18N + XFontSetExtents* fset = XExtentsOfFontSet(f.getXFontset()); + return -fset->max_logical_extent.y; +#else return getXFontstruct(f)->ascent; +#endif } int lyxfont::maxDescent(LyXFont const & f) { +#ifdef I18N + XFontSetExtents* fset = XExtentsOfFontSet(f.getXFontset()); + return fset->max_logical_extent.height + fset->max_logical_extent.y; +#else return getXFontstruct(f)->descent; +#endif } +#ifdef I18N + int lyxfont::ascent(wchar_t c,LyXFont const & f) + { + if (f.family() == LyXFont::SYMBOL_FAMILY) + { + XFontStruct *finfo = getMathFont(f); + if (finfo->per_char + && (unsigned int) c >= finfo->min_char_or_byte2 + && (unsigned int) c <= finfo->max_char_or_byte2) { + unsigned int index = (unsigned int) c - finfo->min_char_or_byte2; + return finfo->per_char[index].ascent; + } else + return finfo->ascent; + }else{ + XFontSet fs = f.getXFontset(); + XRectangle ink,log; + XwcTextExtents(fs,&c,1,&ink,&log); + return -log.y; + } + + } +#else int lyxfont::ascent(char c, LyXFont const & f) { XFontStruct * finfo = getXFontstruct(f); @@ -65,8 +121,31 @@ else return finfo->ascent; } +#endif +#ifdef I18N + int lyxfont::descent(wchar_t c,LyXFont const & f) + { + if (f.family() == LyXFont::SYMBOL_FAMILY) + { + XFontStruct *finfo = getMathFont(f); + if (finfo->per_char + && (unsigned int) c >= finfo->min_char_or_byte2 + && (unsigned int) c <= finfo->max_char_or_byte2) { + unsigned int index = (unsigned int) c - finfo->min_char_or_byte2; + return finfo->per_char[index].descent; + } else + return finfo->descent; + } + else{ + XFontSet fs = f.getXFontset(); + XRectangle ink,log; + XwcTextExtents(fs,&c,1,&ink,&log); + return (log.height+log.y); + } + } +#else int lyxfont::descent(char c, LyXFont const & f) { XFontStruct * finfo = getXFontstruct(f); @@ -78,10 +157,38 @@ else return finfo->descent; } +#endif +#ifdef I18N +int lyxfont::lbearing(wchar_t c,LyXFont const & f) +{ + XFontStruct * finfo = getMathFont(f); + unsigned int uc = static_cast(c); + if (finfo->per_char + && uc >= finfo->min_char_or_byte2 + && uc <= finfo->max_char_or_byte2) + return finfo->per_char[uc - finfo->min_char_or_byte2].lbearing; + else + return 0; +} + + +int lyxfont::rbearing(wchar_t c,LyXFont const & f) +{ + XFontStruct * finfo = getMathFont(f); + unsigned int uc = static_cast(c); + if (finfo->per_char + && uc >= finfo->min_char_or_byte2 + && uc <= finfo->max_char_or_byte2) + return finfo->per_char[uc - finfo->min_char_or_byte2].rbearing; + else + return width(c,f); +} +#else int lyxfont::lbearing(char c, LyXFont const & f) { + XFontStruct * finfo = getXFontstruct(f); unsigned int uc = static_cast(c); if (finfo->per_char @@ -95,6 +202,7 @@ int lyxfont::rbearing(char c, LyXFont const & f) { + XFontStruct * finfo = getXFontstruct(f); unsigned int uc = static_cast(c); if (finfo->per_char @@ -104,13 +212,92 @@ else return width(c, f); } +#endif + +#ifdef I18N +int lyxfont::width(wchar_t c,LyXFont const & f) +{ + + XFontSet fs = f.getXFontset(); + XRectangle ink,log; + XwcTextExtents(fs,&c,1,&ink,&log); + return log.width; +} +int lyxfont::width(char c,LyXFont const & f) +{ + if (f.family()== LyXFont::SYMBOL_FAMILY) + { + if (f.realShape() != LyXFont::SMALLCAPS_SHAPE){ + return ::XTextWidth(getMathFont(f), &c, 1); + } else { + return width(&c, 1,f); + } + }else + { + wchar_t *wcs= new wchar_t [1]; + int len = codeconverter.lyxmbstowcs(wcs,&c,1); + return width(wcs, len,f); + } +} + +#endif + +#ifdef I18N +int lyxfont::width(char const *s, size_t n,LyXFont const & f) +{ + if (f.realShape() != LyXFont::SMALLCAPS_SHAPE){ + return ::XTextWidth(getMathFont(f), s, n); + } else { + // emulate smallcaps since X doesn't support this + unsigned int result = 0; + LyXFont smallfont(f); + smallfont.decSize(); + smallfont.decSize(); + smallfont.setShape(LyXFont::UP_SHAPE); + for (size_t i=0; i < n; i++){ + char const c = uppercase(s[i]); + if (c != s[i]) { + result += ::XTextWidth(getMathFont(smallfont), &c, 1); + } else { + result += ::XTextWidth(getMathFont(f), &c, 1); + } + } + return result; + } + +} + + +int lyxfont::width(wchar_t const *s, int n,LyXFont const & f) +{ + if (f.realShape() != LyXFont::SMALLCAPS_SHAPE){ + return XwcTextEscapement(f.getXFontset(), s, n); + } else { + // emulate smallcaps since X doesn't support this + unsigned int result = 0; + wchar_t c; + LyXFont smallfont(f); + smallfont.decSize(); + smallfont.decSize(); + smallfont.setShape(LyXFont::UP_SHAPE); + for (size_t i=0; i < n; i++){ + c = s[i]; + if (c !=s[i]) { + result += XwcTextEscapement(smallfont.getXFontset(), &c,1); + } else { + result += XwcTextEscapement(f.getXFontset(), &c,1); + } + } + return result; + } +} +#else int lyxfont::width(char const * s, size_t n, LyXFont const & f) { if (!lyxrc.use_gui) return n; - if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) { boost::scoped_array xs(new XChar2b[n]); Encoding const * encoding = f.language()->encoding(); @@ -132,6 +319,7 @@ } if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) { + return ::XTextWidth(getXFontstruct(f), s, n); } else { // emulate smallcaps since X doesn't support this @@ -149,20 +337,30 @@ return result; } } - +#endif int lyxfont::signedWidth(string const & s, LyXFont const & f) { if (s.empty()) return 0; +#ifdef I18N + wchar_t *wcs = new wchar_t [s.length() + 1]; + int len = codeconverter.lyxmbstowcs(wcs,&s); + if (wcs[0] == '-') + return width(wcs+1, len-1,f); + else + return width(wcs, len,f); +#else if (s[0] == '-') return -width(s.substr(1, s.length() - 1), f); else return width(s, f); +#endif } //int lyxfont::width(wstring const & s, int n, LyXFont const & f) +#ifndef I18N int lyxfont::width(XChar2b const * s, int n, LyXFont const & f) { if (!lyxrc.use_gui) @@ -192,18 +390,24 @@ return result; } } +#endif int lyxfont::XTextWidth(LyXFont const & f, char const * str, int count) { +#ifdef I18N + return ::XTextWidth(getMathFont(f), str, count); + +#else return ::XTextWidth(getXFontstruct(f), str, count); +#endif } - +#ifndef I18N int lyxfont::XTextWidth16(LyXFont const & f, XChar2b const * str, int count) { return ::XTextWidth16(getXFontstruct(f), str, count); } - +#endif void lyxfont::XSetFont(Display * display, GC gc, LyXFont const & f) { diff -urdN lyx-1.2.0/src/font.h CJK-LyX-1.2.0/src/font.h --- lyx-1.2.0/src/font.h Fri Mar 22 02:25:09 2002 +++ CJK-LyX-1.2.0/src/font.h Tue Jul 9 15:55:40 2002 @@ -20,6 +20,12 @@ #include "LString.h" +#ifdef I18N +#include "FontLoader.h" +#include "lyxcodeconv.h" + extern LyXCodeConv codeconverter; +#endif + class LyXFont; //namespace lyx { @@ -33,30 +39,73 @@ static int maxDescent(LyXFont const & f); /// +#ifdef I18N + static + int ascent(wchar_t c,LyXFont const & f) ; + + /// + static + int descent(wchar_t c,LyXFont const & f); +#else static int ascent(char c, LyXFont const & f); /// static int descent(char c, LyXFont const & f); +#endif /// +#ifdef I18N + static + int lbearing(wchar_t c,LyXFont const & f); + + /// + static + int rbearing(wchar_t c,LyXFont const & f); +#else static int lbearing(char c, LyXFont const & f); /// static int rbearing(char c, LyXFont const & f); +#endif /// +#ifdef I18N + static + int width(wchar_t c,LyXFont const & f); + static + int width(char c, LyXFont const & f); +#else static int width(char c, LyXFont const & f) { return width(&c, 1, f); } +#endif /// +#ifdef I18N + static + int width(wchar_t const *s, int n,LyXFont const & f) ; + +#endif static int width(char const * s, size_t n, LyXFont const & f); /// static int width(string const & s, LyXFont const & f) { if (s.empty()) return 0; +#ifdef I18N + else { + if (f.family()== LyXFont::SYMBOL_FAMILY) + return width(s.data(), s.length(), f); + else { + wchar_t * wcs = new wchar_t[s.length()+1]; + int len=codeconverter.lyxmbstowcs(wcs,&s); + wcs[len] = '\0'; + return width(wcs, len, f); + } + } +#else return width(s.data(), s.length(), f); +#endif } /// //static @@ -67,6 +116,10 @@ static int signedWidth(string const & s, LyXFont const & f); /// +#ifdef I18N + static + int XTextWidth(LyXFont const & f, wchar_t * str, int count); +#endif static int XTextWidth(LyXFont const & f, char const * str, int count); /// diff -urdN lyx-1.2.0/src/frontends/xforms/FormPreferences.C CJK-LyX-1.2.0/src/frontends/xforms/FormPreferences.C --- lyx-1.2.0/src/frontends/xforms/FormPreferences.C Wed May 1 18:46:36 2002 +++ CJK-LyX-1.2.0/src/frontends/xforms/FormPreferences.C Tue Jul 9 15:55:40 2002 @@ -74,7 +74,11 @@ colors_(*this), converters_(*this), inputs_misc_(*this), formats_(*this), interface_(*this), language_(*this), lnf_misc_(*this), outputs_misc_(*this), paths_(*this), - printer_(*this), screen_fonts_(*this), spelloptions_(*this) + printer_(*this), screen_fonts_(*this), +#ifdef I18N + cjk_fonts_(*this), +#endif + spelloptions_(*this) { // let the dialog be shown // This is a permanent connection so we won't bother @@ -191,6 +195,9 @@ paths_.build(); printer_.build(); screen_fonts_.build(); +#ifdef I18N + cjk_fonts_.build(); +#endif spelloptions_.build(); // Now add them to the tabfolder @@ -224,7 +231,11 @@ fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner, _("Misc"), lnf_misc_.dialog()->form); - +#ifdef I18N + fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner, + _("CJK Fonts"), + cjk_fonts_.dialog()->form); +#endif // then build converters fl_addto_tabfolder(converters_tab_->tabfolder_inner, _("Formats"), @@ -284,6 +295,9 @@ paths_.apply(); printer_.apply(); screen_fonts_.apply(); +#ifdef I18N + cjk_fonts_.apply(); +#endif spelloptions_.apply(); } @@ -318,6 +332,10 @@ str = screen_fonts_.feedback(ob); } else if (ob->form->fdui == spelloptions_.dialog()) { str = spelloptions_.feedback(ob); +#ifdef I18N + } else if (ob->form->fdui == cjk_fonts_.dialog()) { + str = cjk_fonts_.feedback(ob); +#endif } return str; @@ -349,6 +367,10 @@ return screen_fonts_.input(); else if (ob->form->fdui == spelloptions_.dialog()) return spelloptions_.input(ob); +#ifdef I18N + else if (ob->form->fdui == cjk_fonts_.dialog()) + return cjk_fonts_.input(); +#endif return true; } @@ -370,6 +392,9 @@ paths_.update(); printer_.update(); screen_fonts_.update(); +#ifdef I18N + cjk_fonts_.update(); +#endif spelloptions_.update(); } @@ -2288,7 +2313,195 @@ input(0); } +#ifdef I18N +FormPreferences::CJKFonts::CJKFonts( FormPreferences & p ) + : parent_(p) +{} + +FD_form_cjk_fonts const * FormPreferences::CJKFonts::dialog() +{ + return dialog_.get(); +} + +void FormPreferences::CJKFonts::apply() const +{ + bool changed = false; + + string str = fl_get_input(dialog_->input_i18n1_gothic); + if (lyxrc.i18n_gothic_font_name[0] != str) { + changed = true; + lyxrc.i18n_gothic_font_name[0] = str; + } + + str = fl_get_input(dialog_->input_i18n1_normal); + if (lyxrc.i18n_normal_font_name[0] != str) { + changed = true; + lyxrc.i18n_normal_font_name[0] = str; + } + + str = fl_get_input(dialog_->input_screen_i18n1_encoding); + if (lyxrc.i18n_font_norm[0] != str) { + changed = true; + lyxrc.i18n_font_norm[0] = str; + } + + str = fl_get_input(dialog_->input_i18n2_gothic); + if (lyxrc.i18n_gothic_font_name[1] != str) { + changed = true; + lyxrc.i18n_gothic_font_name[1] = str; + } + + str = fl_get_input(dialog_->input_i18n2_normal); + if (lyxrc.i18n_normal_font_name[1] != str) { + changed = true; + lyxrc.i18n_normal_font_name[1] = str; + } + + str = fl_get_input(dialog_->input_screen_i18n2_encoding); + if (lyxrc.i18n_font_norm[1] != str) { + changed = true; + lyxrc.i18n_font_norm[1] = str; + } + + if (changed) { + // Now update the buffers + // Can anything below here affect the redraw process? + parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE); + } +} + + +void FormPreferences::CJKFonts::build() +{ + dialog_.reset(parent_.build_cjk_fonts()); + + fl_set_input_return(dialog_->input_i18n1_gothic, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->input_i18n1_normal, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->input_screen_i18n1_encoding, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->input_i18n2_gothic, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->input_i18n2_normal, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->input_screen_i18n2_encoding, FL_RETURN_CHANGED); + + + // set up the feedback mechanism + setPrehandler(dialog_->input_i18n1_gothic); + setPrehandler(dialog_->input_i18n1_normal); + setPrehandler(dialog_->input_screen_i18n1_encoding); + setPrehandler(dialog_->input_i18n2_gothic); + setPrehandler(dialog_->input_i18n2_normal); + setPrehandler(dialog_->input_screen_i18n2_encoding); +} + + +string const +FormPreferences::CJKFonts::feedback(FL_OBJECT const * const ob) const +{ + string str; + + if (ob == dialog_->input_screen_i18n1_encoding) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_ENCODING); + else if (ob == dialog_->input_i18n1_gothic) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_GOTHIC); + else if (ob == dialog_->input_i18n1_normal) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_NORMAL); + else if (ob == dialog_->input_i18n1_use) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_ISUSE); + else if (ob == dialog_->input_screen_i18n2_encoding) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_ENCODING); + else if (ob == dialog_->input_i18n2_gothic) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_GOTHIC); + else if (ob == dialog_->input_i18n2_normal) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_NORMAL); + else if (ob == dialog_->input_i18n2_use) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_ISUSE); + else if (ob == dialog_->input_screen_i18n1_encoding) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_ENCODING); + else if (ob == dialog_->input_i18n1_gothic) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_GOTHIC); + else if (ob == dialog_->input_i18n1_normal) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_NORMAL); + else if (ob == dialog_->input_i18n1_use) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N1_ISUSE); + else if (ob == dialog_->input_screen_i18n2_encoding) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_ENCODING); + else if (ob == dialog_->input_i18n2_gothic) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_GOTHIC); + else if (ob == dialog_->input_i18n2_normal) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_NORMAL); + else if (ob == dialog_->input_i18n2_use) + str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_I18N2_ISUSE); + + return str; +} + +bool FormPreferences::CJKFonts::input() +{ + bool activate = true; + string str; + + // Make sure that all fonts all have positive entries + // Also note that an empty entry is returned as 0.0 by strToDbl +/* if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_script)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_small)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_large)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge)) + || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) { + activate = false; + str = N_("Fonts must be positive!"); + + // Fontsizes -- tiny < script < footnote etc. + } else if (strToDbl(fl_get_input(dialog_->input_tiny)) > + strToDbl(fl_get_input(dialog_->input_script)) || + strToDbl(fl_get_input(dialog_->input_script)) > + strToDbl(fl_get_input(dialog_->input_footnote)) || + strToDbl(fl_get_input(dialog_->input_footnote)) > + strToDbl(fl_get_input(dialog_->input_small)) || + strToDbl(fl_get_input(dialog_->input_small)) > + strToDbl(fl_get_input(dialog_->input_normal)) || + strToDbl(fl_get_input(dialog_->input_normal)) > + strToDbl(fl_get_input(dialog_->input_large)) || + strToDbl(fl_get_input(dialog_->input_large)) > + strToDbl(fl_get_input(dialog_->input_larger)) || + strToDbl(fl_get_input(dialog_->input_larger)) > + strToDbl(fl_get_input(dialog_->input_largest)) || + strToDbl(fl_get_input(dialog_->input_largest)) > + strToDbl(fl_get_input(dialog_->input_huge)) || + strToDbl(fl_get_input(dialog_->input_huge)) > + strToDbl(fl_get_input(dialog_->input_huger))) { + activate = false; + + str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger."); + } */ + + if (!activate) + parent_.postWarning(str); + + return activate; +} + + +void FormPreferences::CJKFonts::update() +{ + fl_set_input(dialog_->input_i18n1_gothic, + lyxrc.i18n_gothic_font_name[0].c_str()); + fl_set_input(dialog_->input_i18n1_normal, + lyxrc.i18n_normal_font_name[0].c_str()); + fl_set_input(dialog_->input_screen_i18n1_encoding, + lyxrc.i18n_font_norm[0].c_str()); + fl_set_input(dialog_->input_i18n2_gothic, + lyxrc.i18n_gothic_font_name[1].c_str()); + fl_set_input(dialog_->input_i18n2_normal, + lyxrc.i18n_normal_font_name[1].c_str()); + fl_set_input(dialog_->input_screen_i18n2_encoding, + lyxrc.i18n_font_norm[1].c_str()); +} +#endif FormPreferences::Printer::Printer(FormPreferences & p) : parent_(p) {} @@ -2597,6 +2810,7 @@ fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED); + fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED); fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED); diff -urdN lyx-1.2.0/src/frontends/xforms/FormPreferences.h CJK-LyX-1.2.0/src/frontends/xforms/FormPreferences.h --- lyx-1.2.0/src/frontends/xforms/FormPreferences.h Tue Apr 30 01:16:35 2002 +++ CJK-LyX-1.2.0/src/frontends/xforms/FormPreferences.h Tue Jul 9 15:55:40 2002 @@ -40,6 +40,9 @@ struct FD_form_preferences; struct FD_form_printer; struct FD_form_screen_fonts; +#ifdef I18N + struct FD_form_cjk_fonts; +#endif struct FD_form_spelloptions; @@ -107,6 +110,9 @@ FD_form_printer * build_printer(); /// FD_form_screen_fonts * build_screen_fonts(); +#ifdef I18N + FD_form_cjk_fonts * build_cjk_fonts(); +#endif /// FD_form_spelloptions * build_spelloptions(); @@ -506,6 +512,34 @@ /// friend class SpellOptions; +#ifdef I18N + class CJKFonts { + public: + /// + CJKFonts( FormPreferences & p ); + /// + FD_form_cjk_fonts const * dialog(); + /// + void apply() const; + /// + void build(); + /// + string const feedback(FL_OBJECT const * const) const; + /// + bool input(); + /// + void update(); + + private: + /// + FormPreferences & parent_; + /// + boost::scoped_ptr dialog_; + }; + /// + friend class CJKFonts; +#endif + /// /** The tab folders. */ @@ -531,6 +565,9 @@ Printer printer_; /// ScreenFonts screen_fonts_; +#ifdef I18N + CJKFonts cjk_fonts_; +#endif /// SpellOptions spelloptions_; diff -urdN lyx-1.2.0/src/frontends/xforms/form_preferences.C CJK-LyX-1.2.0/src/frontends/xforms/form_preferences.C --- lyx-1.2.0/src/frontends/xforms/form_preferences.C Wed May 1 18:46:36 2002 +++ CJK-LyX-1.2.0/src/frontends/xforms/form_preferences.C Tue Jul 9 15:55:40 2002 @@ -1124,6 +1124,47 @@ return fdui; } /*---------------------------------------*/ +#ifdef I18N +FD_form_cjk_fonts::~FD_form_cjk_fonts() +{ + if ( form->visible ) fl_hide_form( form ); + fl_free_form( form ); +} + + +FD_form_cjk_fonts * FormPreferences::build_cjk_fonts() +{ + FL_OBJECT *obj; + FD_form_cjk_fonts *fdui = new FD_form_cjk_fonts; + +fdui->form = fl_bgn_form(FL_NO_BOX, 455, 375); + fdui->form->u_vdata = this; + obj = fl_add_box(FL_FLAT_BOX, 0, 0, 455, 375, ""); + fdui->input_i18n1_gothic = obj = fl_add_input(FL_NORMAL_INPUT, 210, 5, 200, 30, _("i18n1 Gothic")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fdui->input_i18n1_normal = obj = fl_add_input(FL_NORMAL_INPUT, 210, 35, 200, 30, _("i18n1 Normal")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fdui->input_screen_i18n1_encoding = obj = fl_add_input(FL_NORMAL_INPUT, 210, 65, 200, 30, _("i18n1 Encoding")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fdui->input_i18n2_gothic = obj = fl_add_input(FL_NORMAL_INPUT, 210, 95, 200, 30, _("i18n2 Gothic")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fdui->input_i18n2_normal = obj = fl_add_input(FL_NORMAL_INPUT, 210, 125, 200, 30, _("i18n2 Normal")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fdui->input_screen_i18n2_encoding = obj = fl_add_input(FL_NORMAL_INPUT, 210, 155, 200, 30, _("i18n2 Encoding")); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_end_form(); + + fdui->form->fdui = fdui; + + return fdui; +} +#endif FD_form_outputs_misc::~FD_form_outputs_misc() { diff -urdN lyx-1.2.0/src/frontends/xforms/form_preferences.h CJK-LyX-1.2.0/src/frontends/xforms/form_preferences.h --- lyx-1.2.0/src/frontends/xforms/form_preferences.h Tue Mar 12 23:11:14 2002 +++ CJK-LyX-1.2.0/src/frontends/xforms/form_preferences.h Tue Jul 9 15:55:40 2002 @@ -76,6 +76,23 @@ FL_OBJECT *input_huge; FL_OBJECT *input_huger; }; + +#ifdef I18N + struct FD_form_cjk_fonts { + ~FD_form_cjk_fonts(); + + FL_FORM *form; + FL_OBJECT *input_screen_i18n1_encoding; + FL_OBJECT *input_i18n1_gothic; + FL_OBJECT *input_i18n1_normal; + FL_OBJECT *input_i18n1_use; + FL_OBJECT *input_screen_i18n2_encoding; + FL_OBJECT *input_i18n2_gothic; + FL_OBJECT *input_i18n2_normal; + FL_OBJECT *input_i18n2_use; + }; +#endif + struct FD_form_interface { ~FD_form_interface(); diff -urdN lyx-1.2.0/src/insets/insetert.C CJK-LyX-1.2.0/src/insets/insetert.C --- lyx-1.2.0/src/insets/insetert.C Thu May 9 21:53:09 2002 +++ CJK-LyX-1.2.0/src/insets/insetert.C Tue Jul 9 15:55:40 2002 @@ -32,6 +32,10 @@ #include "support/LOstream.h" +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#endif using std::ostream; using std::min; @@ -207,7 +211,11 @@ os << "\n\\layout " << layout << "\n"; pos_type siz = par->size(); for (pos_type i = 0; i < siz; ++i) { - Paragraph::value_type c = par->getChar(i); +#ifdef I18N + Paragraph::wchar_type c = par->getChar(i); +#else + Paragraph::value_type c = par->getChar(i); +#endif switch (c) { case Paragraph::META_INSET: case Paragraph::META_HFILL: @@ -220,7 +228,11 @@ os << "\n\\backslash \n"; break; default: +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif break; } } @@ -356,14 +368,22 @@ while (par) { pos_type siz = par->size(); for (pos_type i = 0; i < siz; ++i) { +#ifdef I18N + Paragraph::wchar_type c = par->getChar(i); +#else Paragraph::value_type c = par->getChar(i); +#endif switch (c) { case Paragraph::META_NEWLINE: os << '\n'; ++lines; break; default: +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif break; } } @@ -392,14 +412,23 @@ while (par) { pos_type siz = par->size(); for (pos_type i = 0; i < siz; ++i) { + +#ifdef I18N + Paragraph::wchar_type c = par->getChar(i); +#else Paragraph::value_type c = par->getChar(i); +#endif switch (c) { case Paragraph::META_NEWLINE: os << '\n'; ++lines; break; default: +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif break; } } @@ -421,14 +450,22 @@ while (par) { pos_type siz = par->size(); for (pos_type i = 0; i < siz; ++i) { +#ifdef I18N + Paragraph::wchar_type c = par->getChar(i); +#else Paragraph::value_type c = par->getChar(i); +#endif switch (c) { case Paragraph::META_NEWLINE: os << '\n'; ++lines; break; default: +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif break; } } diff -urdN lyx-1.2.0/src/insets/insetquotes.C CJK-LyX-1.2.0/src/insets/insetquotes.C --- lyx-1.2.0/src/insets/insetquotes.C Fri Mar 22 02:09:50 2002 +++ CJK-LyX-1.2.0/src/insets/insetquotes.C Tue Jul 9 15:55:40 2002 @@ -161,7 +161,11 @@ if (disp == "'") disp = "´"; else if (disp == "''") +#ifdef I18N + disp = "''" ; +#else disp = "´´"; +#endif } if (lyxrc.font_norm_type == LyXRC::ISO_8859_1 || lyxrc.font_norm_type == LyXRC::ISO_8859_9 diff -urdN lyx-1.2.0/src/insets/insettext.C CJK-LyX-1.2.0/src/insets/insettext.C --- lyx-1.2.0/src/insets/insettext.C Thu May 16 08:50:47 2002 +++ CJK-LyX-1.2.0/src/insets/insettext.C Tue Jul 9 15:55:40 2002 @@ -55,6 +55,11 @@ #include //#include +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#endif + using std::ostream; using std::ifstream; using std::endl; diff -urdN lyx-1.2.0/src/lyx_cb.C CJK-LyX-1.2.0/src/lyx_cb.C --- lyx-1.2.0/src/lyx_cb.C Fri Mar 22 02:25:10 2002 +++ CJK-LyX-1.2.0/src/lyx_cb.C Tue Jul 9 15:55:40 2002 @@ -41,6 +41,14 @@ #include #include +#ifdef I18N + #include "BufferView_pimpl.h" + #include "lyxcodeconv.h" + extern LyXCodeConv codeconverter; + #include "lyxim.h" + extern LyXIM lyxim; +#endif + using std::vector; using std::ifstream; using std::copy; diff -urdN lyx-1.2.0/src/lyxcodeconv.C CJK-LyX-1.2.0/src/lyxcodeconv.C --- lyx-1.2.0/src/lyxcodeconv.C Thu Jan 1 09:00:00 1970 +++ CJK-LyX-1.2.0/src/lyxcodeconv.C Tue Jul 9 15:55:40 2002 @@ -0,0 +1,159 @@ +#ifdef I18N + +#include +#include +#include +#include +#include +#include FORMS_H_LOCATION +#include "debug.h" +#include +#include "LString.h" +#include "lyxcodeconv.h" + +LyXCodeConv codeconverter; //global + +size_t LyXCodeConv::lyxmbstowcs(wchar_t *wcs, const char *cs, size_t n) +{ +#ifndef NOGLIBC + size_t len = mbstowcs(wcs,cs, n); + if (len < 0) + { + lyxerr << "LyXCodeConv::lyxmbstowcs Cannot convert mbs to wcs " + << cs << endl; + wcs[0]='\0'; + return 0; + } + + return len; + +#else + XTextProperty textprop; + wchar_t **wlist; + int count; + char *ptr; + + ptr = new char [n+1]; + strcpy(ptr,cs); + + if (XmbTextListToTextProperty(fl_display, &ptr, 1, XTextStyle, &textprop) + != Success) { + lyxerr << "LyXCodeConv:Cannot convert TextList to TextProperty " + << ptr << endl; + return (0); + } + if (XwcTextPropertyToTextList(fl_display, &textprop, &wlist, &count) + != Success) { + lyxerr << "LyXCodeConv:Cannot convert TextProperty to TextList" + << ptr << endl; + return (0); + } + delete [] ptr; + int i; + for ( i= 0 ; wlist[0][i] != 0;i++) + wcs[i]=list[0][i] ; + return i; + +#endif +} + +size_t LyXCodeConv::lyxmbstowcs(wchar_t *wcs, string const *cs) +{ + size_t len = mbstowcs(wcs,cs->c_str(), cs->length()); + if (len < 0) + { + lyxerr << "LyXCodeConv::lyxmbstowcs Cannot convert mbs to wcs " + << cs->c_str() << endl; + wcs[0]='\0'; + return 0; + } + + return len; +// return lyxmbstowcs(wcs,cs->c_str(),cs->length()); + +} + +int LyXCodeConv::lyxwclen(wchar_t const * wcs) +{ + int len=0; + if (wcs == 0) return 0; + while(*wcs++ != (wchar_t)0) len++; + return len; +} +size_t LyXCodeConv::lyxwcstombs(char *cs, const wchar_t *wcs, size_t n) +{ +#ifndef NOGLIBC + size_t len = wcstombs(cs,wcs,n); + if (0 > len){ + lyxerr << "LyXCodeConv::lyxwcstombs Cannot convert mbs to wcs" + << cs << endl; + cs[0] = '\0'; + return 0; + } + return len; + +#else // wrong + XTextProperty textprop; + char **list; + int count; + + int len = lyxwclen(wcs); + + wchar_t *ptr = new wchar_t [len+1]; + for (int i=0; i < len;i++) + ptr[i]=wcs[i]; + + ptr[len] = '\0'; + if (XwcTextListToTextProperty(fl_display,&ptr,1, XTextStyle, &textprop) + != Success) { + lyxerr << "LyXCodeConv:Cannot convert TextList to TextProperty" << endl; + return (0); + } + if (XmbTextPropertyToTextList(fl_display, &textprop, &list, &count)//wrong? + != Success) { + lyxerr << "LyXCodeConv:Cannot convert TextProperty to TextList" << endl; + return (0); + } + int len = strlen(list[0]); + for (int i=0;i +#include +#include +#include +#include + +#include +#include +using std::ofstream; +using std::ifstream; +using std::fstream; +using std::ios; +using std::setw; + +#include "support/lyxstring.h" +#include "LString.h" + +class LyXCodeConv +{ + public: +// wchar_t * lyxmbstowcs(char const *cs,int n); + size_t lyxmbstowcs(wchar_t *wcs, const char *cs, size_t n); + size_t lyxmbstowcs(wchar_t *wcs, string const *cs); +// wchar_t * lyxmbstowcs(LString const *cs); + int lyxwclen(wchar_t const * wcs); +// char * lyxwcstombs(wchar_t const *ws); + size_t lyxwcstombs(char *cs, const wchar_t *wcs, size_t n); +// char * lyxwcstombs(wchar_t const *ws,int); + size_t lyxwctomb(char *cs, wchar_t wc); + void lyxos(ostream & os, wchar_t); + void lyxofs(ofstream & ofs, wchar_t); + void lyxprintf (FILE *, wchar_t); + bool lyxIsLineSeparatorChar(wchar_t c); + +}; + +inline bool LyXCodeConv::lyxIsLineSeparatorChar(wchar_t c) +{ + /* How about (c > 0xa258) for BIG5, and + (c > 0xff && c < 0xa1a1) || (c > 0xa1fe) for WanSung?*/ + if ((unsigned long)c > 0x00ff) /* Japanese EUC */ + return True; + else + return 0; +} + +#endif +#endif + + + + + + + + + + diff -urdN lyx-1.2.0/src/lyxfont.h CJK-LyX-1.2.0/src/lyxfont.h --- lyx-1.2.0/src/lyxfont.h Fri Mar 22 02:25:12 2002 +++ CJK-LyX-1.2.0/src/lyxfont.h Tue Jul 9 15:55:40 2002 @@ -18,6 +18,10 @@ #include +#ifdef I18N +#include FORMS_H_LOCATION +#endif + #include "LString.h" #include "LColor.h" @@ -315,7 +319,11 @@ LyXFont const & next) const; /// Build GUI description of font state +/*#ifdef I18N + string stateText() const; +#endif */ string const stateText(BufferParams * params) const; + /// LColor::color realColor() const; @@ -326,6 +334,11 @@ /// Converts logical attributes to concrete shape attribute LyXFont::FONT_SHAPE realShape() const; + +#ifdef I18N + XFontSet getXFontset() const; +#endif + private: /// struct FontBits { diff -urdN lyx-1.2.0/src/lyxfunc.C CJK-LyX-1.2.0/src/lyxfunc.C --- lyx-1.2.0/src/lyxfunc.C Tue Apr 23 07:31:48 2002 +++ CJK-LyX-1.2.0/src/lyxfunc.C Tue Jul 9 15:55:40 2002 @@ -100,6 +100,12 @@ #include #include +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#include "lyxim.h" + extern LyXIM lyxim; +#endif using std::pair; using std::make_pair; @@ -338,7 +344,30 @@ verboseDispatch(action, false); } +#ifdef I18N + void LyXFunc::CJK_IMprocess(int num_bytes, char * s_r) + { + // this function should be used always [asierra060396] + + if (num_bytes !=0) { + s_r[num_bytes]='\0'; + string wstring(s_r); + LyXText * text = owner->view()->getLyXText(); + owner->view()->hideCursor(); + owner->view()->beforeChange(text); + + text->insertStringAsParagraphs(owner->view(), wstring); + text->selection.set(false); + + owner->view()->update(text,BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + text->selection.cursor = text->cursor; + moveCursorUpdate(text,false); + +// return 0; + } + } +#endif FuncStatus LyXFunc::getStatus(int ac) const { kb_action action; @@ -767,6 +796,7 @@ if (!s2.empty()) { verboseDispatch(s2, true); } + } diff -urdN lyx-1.2.0/src/lyxfunc.h CJK-LyX-1.2.0/src/lyxfunc.h --- lyx-1.2.0/src/lyxfunc.h Fri Mar 22 02:25:14 2002 +++ CJK-LyX-1.2.0/src/lyxfunc.h Tue Jul 9 15:55:40 2002 @@ -53,7 +53,9 @@ /// void processKeySym(KeySym k, unsigned int state); - +#ifdef I18N + void CJK_IMprocess(int num_bytes, char * s_r); +#endif /// we need one internal which is called from inside LyXAction and /// can contain the string argument. FuncStatus getStatus(int ac) const; diff -urdN lyx-1.2.0/src/lyxim.C CJK-LyX-1.2.0/src/lyxim.C --- lyx-1.2.0/src/lyxim.C Thu Jan 1 09:00:00 1970 +++ CJK-LyX-1.2.0/src/lyxim.C Tue Jul 9 15:55:40 2002 @@ -0,0 +1,314 @@ +#ifdef I18N + +#include + +#include +#include +#include +#include "config.h" +#include "lyxim.h" +#include "LyXView.h" +#include "minibuffer.h" +#include "BufferView.h" +#include "FontLoader.h" +#include "debug.h" +#include "lyxtext.h" +#include "lyxscreen.h" +#include "WorkArea.h" +#include "BufferView_pimpl.h" + +#define DUMMY_FONT_NAME "-*-*-*-R-Normal--14-130-75-75-*-*" + +//extern FD_form_main *fd_form_main; +extern MiniBuffer *minibuffer; +extern BufferView *current_view; +//extern WorkArea * wk; +extern FontLoader fontloader; + +LyXIM lyxim; //global +static XFontSet fontset,statusfont; + +void LyXIM::SetStatusArea() +{ + + status_rect.x = current_view->owner()->getMiniBuffer()->the_buffer->x + (current_view->owner()->getMiniBuffer()->the_buffer->w * 4/5); + status_rect.y = current_view->owner()->getMiniBuffer()->the_buffer->y +2; + status_rect.width = current_view->owner()->getMiniBuffer()->the_buffer->w * 1/5 -2; + status_rect.height = current_view->owner()->getMiniBuffer()->the_buffer->h -4; + // printf("status.x=%d, status.y=%d, status.width=%d, status.height=%d\n", + // status_rect.x, status_rect.y, status_rect.width, status_rect.height); +} +void LyXIM::SetPreeditArea() +{ + int left,right; //margin + + left = current_view->text->leftMargin(current_view,current_view->text->cursor.row()); + right = current_view->text->rightMargin(current_view->buffer(),current_view->text->cursor.row()); + + input_rect.x = current_view->xpos() + left; + input_rect.y = current_view->ypos(); + input_rect.width = current_view->workWidth() - left - right; + input_rect.height = current_view->height(); + // printf("edit.x=%d, edit.y=%d, edit.width=%d, edit.height=%d\n", + // input_rect.x, input_rect.y, input_rect.width, input_rect.height); +} + +/*void LyXIM::IMDestroy(XIM xim, XPointer client_data, XPointer call_data) +{ + xic = NULL; + XRegisterIMInstantiateCallback(fl_display, NULL, NULL, NULL, LyXIM::IMCreate, NULL); +} +*/ +/*void LyXIM::SetRegister() +{ + XRegisterIMInstantiateCallback(fl_display, NULL, NULL, NULL, + LyXIM::IMCreate, NULL); +} +*/ +void LyXIM::IMCreate(Window window) +{ + + char **missing_list; + int missing_count; + char *def_string; + XPoint spot; + unsigned long fevent; + XVaNestedList status_attr,preedit_attr; + XIMCallback ximcallback; + + + xic = NULL; + setlocale(LC_ALL,""); + if (!XSupportsLocale()) { + // lyxerr.print("IMCreate: X does not support this locale."); + return; + } + if (!XSetLocaleModifiers("")) { + // lyxerr.print("IMCreate: Could not set modifiers " + // "for this locale."); + return; + } + +// ximcallback.callback = IMDestroy; +// ximcallback.client_data = NULL; + + + xim = XOpenIM (fl_display, 0, 0, 0); + +// XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL); + + if (!xim) { + // lyxerr.print("IMCreate: could not open " + // "an input method."); + return; + } + + { // xim_style set + XIMStyle preedit[]={XIMPreeditPosition,XIMPreeditNothing,0}; + XIMStyle status[]={XIMStatusArea,XIMStatusNothing,0}; + XIMStyles *xim_styles = 0; + + if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, 0) || !xim_styles) { + lyxerr << "IMCreate:input method doesn't support any style" << endl; + XCloseIM(xim); + return; + } + int i=0; + int found=0; + while ((preedit[i]!=0)&& (found != 1)) + { + int j = 0; + while((status[j]!=0)&& (found != 1)) + { + for (int k=0;k < xim_styles->count_styles;k++) + { + if ((preedit[i] | status[j])==xim_styles->supported_styles[k]) + { + input_style=xim_styles->supported_styles[k]; + found = 1; + break; + } + } + j++; + } + i++; + } + } + + + fontset = XCreateFontSet(fl_display, DUMMY_FONT_NAME, &missing_list, + &missing_count, &def_string); + statusfont = XCreateFontSet(fl_display, DUMMY_FONT_NAME, &missing_list, + &missing_count, &def_string); + if (fontset == 0) + { + lyxerr << "IMCreate: create dummy fontset !" << endl; + return; + } + + + spot.x = current_view->xpos() + 42; //dummy + spot.y = current_view->ypos() + 40; + + input_rect.x = current_view->xpos(); //dummy + input_rect.y = current_view->ypos(); + input_rect.width = current_view->workWidth() - 20; + input_rect.height = current_view->height(); + + preedit_attr = XVaCreateNestedList(0, + XNSpotLocation, &spot, + XNFontSet, fontset, + //XNBackground,fl_get_pixel(FL_WHITE), + //XNBackgroundPixmap,current_view->getScreen()->getForeground(), + XNForeground,BlackPixel(fl_display,DefaultScreen(fl_display)), //for skkinput? + XNBackground,WhitePixel(fl_display, DefaultScreen(fl_display)), + XNArea,&input_rect, + 0); + + + + SetStatusArea(); + status_attr = XVaCreateNestedList(0, + XNArea, &status_rect, + XNFontSet, statusfont, //no effect + XNBackground,fl_get_pixel(FL_MCOL), //no effect + 0); + + xic = XCreateIC(xim, + XNInputStyle, input_style, + XNClientWindow, window, + XNPreeditAttributes, preedit_attr, + XNStatusAttributes, status_attr, + XNDestroyCallback, &ximcallback, + 0); + + XFree(preedit_attr); + XFree(status_attr); + + + if (!xic) { + lyxerr << "IMCreate: could not create " + "an input context" << endl; + XCloseIM (xim); + xim = 0; + return; + } + XGetICValues(xic, XNFilterEvents, &fevent, 0); + +} + +void LyXIM::SpotandFont() +{ + + preeditspot.x = current_view->text->cursor.x() + current_view->xpos(); + preeditspot.y = current_view->text->cursor.y() + current_view->ypos() + - current_view->text->first_y; + + current_font = current_view->text->real_current_font; + current_fontset= fontloader.load(current_font.family(),current_font.series(), + current_font.shape(),current_font.size()); +} + +void LyXIM::SetIMSpot() +{ + + XVaNestedList preedit_attr; + + + if (xic && current_view->available() ) { + + SpotandFont(); + SetPreeditArea(); + + preedit_attr = XVaCreateNestedList(0, + XNSpotLocation, &preeditspot, + XNFontSet,current_fontset, + XNArea,&input_rect, + XNBackgroundPixmap,current_view->getColor()->foreground, + 0); + + XSetICValues(xic, + XNPreeditAttributes,preedit_attr, + 0); + XFree(preedit_attr); + } +} + + + +void LyXIM::SetIMSpotAndArea() +{ + XVaNestedList status_attr; + if (xic && current_view->available() ) { + SetIMSpot(); + SetStatusArea(); + status_attr = XVaCreateNestedList(0, + XNArea, &status_rect, + XNFontSet, statusfont, + XNForeground,fl_get_pixel(FL_MCOL), + 0); + XSetICValues(xic, + XNStatusAttributes, status_attr, + 0); + XFree(status_attr); + } +} + +/* $XConsortium: NextEvent.c,v 11.19 94/04/17 20:20:19 kaleb Exp $ */ +/* + +Copyright (c) 1986 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + +*/ + +#define NEED_EVENTS +extern "C" { +#include +} + +/* + * Return next event in queue, or if none, flush output and wait for + * events. + */ + +extern "C" int +XNextEvent (register Display *dpy, register XEvent *event) +{ + register _XQEvent *qelt; + + LockDisplay(dpy); + + if (dpy->head == 0) + _XReadEvents(dpy); + qelt = dpy->head; + *event = qelt->event; + _XDeq(dpy, 0, qelt); + UnlockDisplay(dpy); + if (event->type == ClientMessage && XFilterEvent(event, None)) return XNextEvent(dpy, event); + return 0; +} + + +#endif + diff -urdN lyx-1.2.0/src/lyxim.h CJK-LyX-1.2.0/src/lyxim.h --- lyx-1.2.0/src/lyxim.h Thu Jan 1 09:00:00 1970 +++ CJK-LyX-1.2.0/src/lyxim.h Tue Jul 9 15:55:40 2002 @@ -0,0 +1,71 @@ +#ifndef __LYXIM_H__ +#define __LYXIM_H__ +#ifdef I18N +#include FORMS_H_LOCATION +#include "lyxfont.h" +#include "BufferView.h" +extern BufferView *current_view; + +class LyXIM +{ + public: + + void IMCreate(Window window); +// void SetRegister(); + void SetIMSpot(); + void SetIMSpotAndArea(); + XIC GetIC(); + void Close()const; + + + void focusIn(); + void focusOut(); + private: + void Restart(); + void SpotandFont(); + void SetStatusArea(); + void SetPreeditArea(); +// void IMDestroy(XIM xim, XPointer client_data, XPointer call_data); + + XIM xim; + XIC xic; + XRectangle input_rect; + XRectangle status_rect; + XPoint preeditspot; + + LyXFont current_font; + XFontSet current_fontset; + XIMStyle input_style; + +}; + +inline XIC LyXIM::GetIC() +{ + if (xic) + return xic; + else + return NULL; +} + +inline void LyXIM::Close() const +{ + if (xic) { + XDestroyIC(xic); + XCloseIM(xim); + } +} + +inline void LyXIM::focusIn() +{ + if (current_view->available() && xic) + XSetICFocus(xic); +} + +inline void LyXIM::focusOut() +{ + if (current_view->available() && xic) + XUnsetICFocus(xic); +} + +#endif +#endif diff -urdN lyx-1.2.0/src/lyxlookup.C CJK-LyX-1.2.0/src/lyxlookup.C --- lyx-1.2.0/src/lyxlookup.C Fri Mar 22 02:25:14 2002 +++ CJK-LyX-1.2.0/src/lyxlookup.C Tue Jul 9 15:55:40 2002 @@ -21,8 +21,17 @@ #include #include #ifdef HAVE_LOCALE_H + +#ifdef I18N +#include +#include "lyxim.h" +#include "BufferView.h" +#else #include #endif + +#endif + #include #include "lyxlookup.h" @@ -31,6 +40,11 @@ using std::endl; +#ifdef I18N + extern LyXIM lyxim; //global + extern BufferView *current_view; +XComposeStatus compose_status= {0, 0}; +#else namespace { XIM xim; @@ -38,11 +52,14 @@ XComposeStatus compose_status= {0, 0}; } // namespace anon - +#endif // This is called after the main LyX window has been created void InitLyXLookup(Display * display, Window window) { +#ifdef I18N + lyxim.IMCreate(window); +#else xic = 0; lyxerr[Debug::KEY] @@ -91,6 +108,7 @@ else lyxerr[Debug::KEY] << "InitLyXLookup: could not open " "an input method." << endl; +#endif } @@ -173,6 +191,9 @@ } int result = 0; +#ifdef I18N + if (lyxim.GetIC()){ +#else if (xic) { #if 1 // somehow it is necessary to do the lookup. Why? (JMarc) @@ -187,6 +208,18 @@ return 0; } #endif +#endif + +#ifdef I18N + if(current_view->available()){ + if (XFilterEvent (event, None)) { + //lyxerr.print("XFilterEvent"); + *keysym_return = NoSymbol; + return 0; + } + } + +#else #if 1 if (XFilterEvent (event, None)) { lyxerr[Debug::KEY] <<"XFilterEvent" << endl; @@ -194,11 +227,18 @@ return 0; } #endif +#endif Status status_return = 0; +#ifdef I18N + result = XmbLookupString(lyxim.GetIC(), &event->xkey, buffer_return, + bytes_buffer, keysym_return, + &status_return); +#else result = XmbLookupString(xic, &event->xkey, buffer_return, bytes_buffer, keysym_return, &status_return); +#endif switch (status_return) { case XBufferOverflow: lyxerr[Debug::KEY] << "XBufferOverflow" << endl; @@ -241,6 +281,9 @@ // This is called after the main window has been destroyed void CloseLyXLookup() { +#ifdef I18N + lyxim.Close(); +#else if (xic) { lyxerr[Debug::KEY] << "CloseLyXLookup: destroying input context" << endl; @@ -248,6 +291,7 @@ xic = 0; XCloseIM(xim); } +#endif } diff -urdN lyx-1.2.0/src/lyxrc.C CJK-LyX-1.2.0/src/lyxrc.C --- lyx-1.2.0/src/lyxrc.C Wed Apr 3 02:04:22 2002 +++ CJK-LyX-1.2.0/src/lyxrc.C Tue Jul 9 15:55:40 2002 @@ -125,6 +125,14 @@ { "\\screen_font_popup", LyXRC::RC_POPUP_NORMAL_FONT }, { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN }, { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS }, +#ifdef I18N + { "\\screen_font_i18n1_encoding", LyXRC::RC_SCREEN_FONT_I18N1_ENCODING }, + { "\\screen_font_i18n2_encoding", LyXRC::RC_SCREEN_FONT_I18N2_ENCODING }, + { "\\screen_font_i18n1_gothic", LyXRC::RC_SCREEN_FONT_I18N1_GOTHIC }, + { "\\screen_font_i18n2_gothic", LyXRC::RC_SCREEN_FONT_I18N2_GOTHIC }, + { "\\screen_font_i18n1_normal", LyXRC::RC_SCREEN_FONT_I18N1_NORMAL }, + { "\\screen_font_i18n2_normal", LyXRC::RC_SCREEN_FONT_I18N2_NORMAL }, +#endif { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE }, { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES }, { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER }, @@ -215,6 +223,16 @@ font_norm = "iso8859-1"; font_norm_type = ISO_8859_1; popup_font_encoding.erase(); +#ifdef I18N + i18n_font_use[0] = true; + i18n_normal_font_name[0] = "-*-mincho"; + i18n_gothic_font_name[0] = "-*-gothic"; + i18n_font_norm[0] = "ksc5601.1987-0"; + i18n_font_use[1] = true; + i18n_normal_font_name[1] = "-*-mincho"; + i18n_gothic_font_name[1] = "-*-gothic"; + i18n_font_norm[1] = "ksc5601.1987-0"; +#endif override_x_deadkeys = true; autosave = 300; auto_region_delete = true; @@ -600,7 +618,46 @@ if (lexrc.next()) use_scalable_fonts = lexrc.getBool(); break; +#ifdef I18N + case RC_SCREEN_FONT_I18N1_ISUSE: //japanese + if (lexrc.next()) + i18n_font_use[0] = lexrc.getBool(); + break; + case RC_SCREEN_FONT_I18N1_ENCODING: //japanes + if (lexrc.next()) + i18n_font_norm[0] = lexrc.getString(); + break; + case RC_SCREEN_FONT_I18N1_GOTHIC: + if (lexrc.next()) + i18n_gothic_font_name[0] = lexrc.getString(); + break; + + case RC_SCREEN_FONT_I18N1_NORMAL: + if (lexrc.next()) + i18n_normal_font_name[0] = lexrc.getString(); + break; + + case RC_SCREEN_FONT_I18N2_ISUSE: //japanese + if (lexrc.next()) + i18n_font_use[1] = lexrc.getBool(); + break; + case RC_SCREEN_FONT_I18N2_ENCODING: //japanese + if (lexrc.next()) + i18n_font_norm[1] = lexrc.getString(); + break; + + case RC_SCREEN_FONT_I18N2_GOTHIC: + if (lexrc.next()) + i18n_gothic_font_name[1] = lexrc.getString(); + break; + + case RC_SCREEN_FONT_I18N2_NORMAL: + if (lexrc.next()) + i18n_normal_font_name[1] = lexrc.getString(); + break; + +#endif case RC_AUTOSAVE: if (lexrc.next()) autosave = lexrc.getInteger(); @@ -1204,6 +1261,39 @@ os << "\\screen_font_encoding \"" << font_norm << "\"\n"; } +#ifdef I18N + case RC_SCREEN_FONT_I18N1_ENCODING: + if (font_norm != system_lyxrc.i18n_font_norm[0]) { + os << "\\screen_font_i18n1_encoding \"" << i18n_font_norm[0] + << "\"\n"; + } + case RC_SCREEN_FONT_I18N2_ENCODING: + if (font_norm != system_lyxrc.i18n_font_norm[1]) { + os << "\\screen_font_i18n2_encoding \"" << i18n_font_norm[1] + << "\"\n"; + } + case RC_SCREEN_FONT_I18N1_GOTHIC: + if (roman_font_name != system_lyxrc.i18n_gothic_font_name[0]) { + os << "\\screen_font_i18n1_gothic \"" << i18n_gothic_font_name[0] + << "\"\n"; + } + case RC_SCREEN_FONT_I18N2_GOTHIC: + if (roman_font_name != system_lyxrc.i18n_gothic_font_name[1]) { + os << "\\screen_font_i18n2_gothic \"" << i18n_gothic_font_name[1] + << "\"\n"; + } + case RC_SCREEN_FONT_I18N1_NORMAL: + if (roman_font_name != system_lyxrc.i18n_normal_font_name[0]) { + os << "\\screen_font_i18n1_normal \"" << i18n_normal_font_name[0] + << "\"\n"; + } + case RC_SCREEN_FONT_I18N2_NORMAL: + if (roman_font_name != system_lyxrc.i18n_normal_font_name[1]) { + os << "\\screen_font_i18n2_normal \"" << i18n_normal_font_name[1] + << "\"\n"; + } + +#endif case RC_SCREEN_FONT_SIZES: if (font_sizes[LyXFont::SIZE_TINY] != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] || @@ -1783,7 +1873,24 @@ case RC_POPUP_FONT_ENCODING: str = _("The encoding for the menu/popups fonts."); break; - +#ifdef I18N + case RC_SCREEN_FONT_I18N1_ISUSE: + break; + case RC_SCREEN_FONT_I18N1_NORMAL: + break; + case RC_SCREEN_FONT_I18N1_GOTHIC: + break; + case RC_SCREEN_FONT_I18N1_ENCODING: + break; + case RC_SCREEN_FONT_I18N2_ISUSE: + break; + case RC_SCREEN_FONT_I18N2_NORMAL: + break; + case RC_SCREEN_FONT_I18N2_GOTHIC: + break; + case RC_SCREEN_FONT_I18N2_ENCODING: + break; +#endif case RC_SET_COLOR: break; diff -urdN lyx-1.2.0/src/lyxrc.h CJK-LyX-1.2.0/src/lyxrc.h --- lyx-1.2.0/src/lyxrc.h Fri Mar 22 02:25:15 2002 +++ CJK-LyX-1.2.0/src/lyxrc.h Tue Jul 9 15:55:40 2002 @@ -55,6 +55,16 @@ RC_SCREEN_FONT_SANS, RC_SCREEN_FONT_TYPEWRITER, RC_SCREEN_FONT_ENCODING, +#ifdef I18N + RC_SCREEN_FONT_I18N1_ISUSE, + RC_SCREEN_FONT_I18N1_NORMAL, + RC_SCREEN_FONT_I18N1_GOTHIC, + RC_SCREEN_FONT_I18N1_ENCODING, + RC_SCREEN_FONT_I18N2_ISUSE, + RC_SCREEN_FONT_I18N2_NORMAL, + RC_SCREEN_FONT_I18N2_GOTHIC, + RC_SCREEN_FONT_I18N2_ENCODING, +#endif RC_POPUP_BOLD_FONT, RC_POPUP_NORMAL_FONT, RC_POPUP_FONT_ENCODING, @@ -246,6 +256,15 @@ string popup_normal_font; /// string font_norm; +#ifdef I18N + bool i18n_font_use[2]; + /// + string i18n_normal_font_name[2]; + /// + string i18n_gothic_font_name[2]; + /// + string i18n_font_norm[2]; +#endif /// enum FontEncoding { /// diff -urdN lyx-1.2.0/src/lyxtext.h CJK-LyX-1.2.0/src/lyxtext.h --- lyx-1.2.0/src/lyxtext.h Fri May 3 18:22:06 2002 +++ CJK-LyX-1.2.0/src/lyxtext.h Tue Jul 9 15:55:40 2002 @@ -173,7 +173,11 @@ /** insert a character, moves all the following breaks in the same Paragraph one to the right and make a little rebreak */ +#ifdef I18N + void insertChar(BufferView *, wchar_t c); +#else void insertChar(BufferView *, char c); +#endif /// void insertInset(BufferView *, Inset * inset); @@ -508,6 +512,13 @@ return bidi_start == -1 || (bidi_start <= pos && pos <= bidi_end); } +#ifdef I18N + int leftMargin(BufferView *, Row const *row) const; + /// + int rightMargin(Buffer const *, Row const *row) const; + /// +#endif + private: /// mutable Row * firstrow; @@ -634,8 +645,13 @@ int singleWidth(BufferView *, Paragraph * par, lyx::pos_type pos) const; /// +#ifdef I18N + int singleWidth(BufferView *, Paragraph *par, + lyx::pos_type pos, wchar_t c) const; +#else int singleWidth(BufferView *, Paragraph * par, lyx::pos_type pos, char c) const; +#endif /// draw normal chars @@ -671,9 +687,11 @@ in LaTeX the beginning of the text fits in some cases (for example sections) exactly the label-width. */ +#ifndef I18N int leftMargin(BufferView *, Row const * row) const; /// int rightMargin(Buffer const *, Row const * row) const; +#endif /// int labelEnd (BufferView *, Row const * row) const; diff -urdN lyx-1.2.0/src/mathed/math_support.C CJK-LyX-1.2.0/src/mathed/math_support.C --- lyx-1.2.0/src/mathed/math_support.C Thu Apr 4 23:48:39 2002 +++ CJK-LyX-1.2.0/src/mathed/math_support.C Tue Jul 9 15:55:40 2002 @@ -579,7 +579,13 @@ int mathed_char_width(LyXFont const & font, unsigned char c) { - return lyxfont::width(c, font); + return lyxfont::width( +#ifdef I18N + (char)c, +#else + c, +#endif + font); } diff -urdN lyx-1.2.0/src/mathed/math_symbolinset.C CJK-LyX-1.2.0/src/mathed/math_symbolinset.C --- lyx-1.2.0/src/mathed/math_symbolinset.C Fri Mar 22 02:42:56 2002 +++ CJK-LyX-1.2.0/src/mathed/math_symbolinset.C Tue Jul 9 15:55:40 2002 @@ -149,6 +149,12 @@ { if (name() == "cdot") os << '*'; + else if (name() == "pi") + os << "Pi"; + else if (name() == "infty") + os << "infinity"; + else if (name() == "Gamma") + os << "GAMMA"; else os << name(); } diff -urdN lyx-1.2.0/src/minibuffer.h CJK-LyX-1.2.0/src/minibuffer.h --- lyx-1.2.0/src/minibuffer.h Fri Mar 22 02:25:15 2002 +++ CJK-LyX-1.2.0/src/minibuffer.h Tue Jul 9 15:55:40 2002 @@ -63,6 +63,11 @@ //SigC::Signal0 escape; /// SigC::Signal0 timeout; + +#ifdef I18N + FL_OBJECT *the_buffer; +#endif + private: /// void activate(); @@ -101,7 +106,9 @@ /// the dropdown menu DropDown * dropdown_; /// +#ifndef I18N FL_OBJECT * the_buffer; +#endif /// std::vector completion_; /// diff -urdN lyx-1.2.0/src/paragraph.C CJK-LyX-1.2.0/src/paragraph.C --- lyx-1.2.0/src/paragraph.C Tue May 14 18:40:53 2002 +++ CJK-LyX-1.2.0/src/paragraph.C Tue Jul 9 15:55:40 2002 @@ -56,6 +56,13 @@ using lyx::pos_type; +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#include "lyxim.h" +extern LyXIM lyxim; +#endif + int tex_code_break_column = 72; // needs non-zero initialization. set later. // this is a bad idea, but how can Paragraph find its buffer to get // parameters? (JMarc) @@ -63,10 +70,15 @@ extern string bibitemWidest(Buffer const *); // this is a minibuffer +#ifdef I18N + wchar_t minibuffer_char; +#endif namespace { - +#ifndef I18N char minibuffer_char; +#endif + LyXFont minibuffer_font; Inset * minibuffer_inset; @@ -273,7 +285,12 @@ font1 = font2; } +#ifdef I18N + wchar_type const c = getChar(i); +#else value_type const c = getChar(i); +#endif + switch (c) { case META_INSET: { @@ -320,7 +337,11 @@ // this check is to amend a bug. LyX sometimes // inserts '\0' this could cause problems. if (c != '\0') +#ifdef I18N + codeconverter.lyxos(os,c); +#else os << c; +#endif else lyxerr << "ERROR (Paragraph::writeFile):" " NULL char in structure." << endl; @@ -500,16 +521,23 @@ return true; } - +#ifdef I18N + void Paragraph::insertChar(pos_type pos, Paragraph::wchar_type c) +#else void Paragraph::insertChar(pos_type pos, Paragraph::value_type c) +#endif { LyXFont const f(LyXFont::ALL_INHERIT); insertChar(pos, c, f); } - +#ifdef I18N + void Paragraph::insertChar(pos_type pos, Paragraph::wchar_type c, + LyXFont const & font) +#else void Paragraph::insertChar(pos_type pos, Paragraph::value_type c, LyXFont const & font) +#endif { pimpl_->insertChar(pos, c, font); } @@ -726,15 +754,26 @@ return maxsize; } - +#ifdef I18N + Paragraph::wchar_type +#else Paragraph::value_type +#endif Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const { +#ifdef I18N + wchar_type c = getChar(pos); +#else value_type c = getChar(pos); +#endif if (!lyxrc.rtl_support) return c; +#ifdef I18N + wchar_type uc = c; +#else value_type uc = c; +#endif switch (c) { case '(': uc = ')'; @@ -1144,8 +1183,13 @@ if (i < size() && getChar(i) != Paragraph::META_NEWLINE) { ++i; +#ifdef I18N + wchar_t previous_char = 0; + wchar_t temp = 0; +#else char previous_char = 0; char temp = 0; +#endif if (i < size() && (previous_char = getChar(i)) != Paragraph::META_NEWLINE) { // Yes, this ^ is supposed to be "= " not "==" @@ -1637,7 +1681,11 @@ column += startTeXParParams(bparams, os); } +#ifdef I18N + wchar_type c = getChar(i); +#else value_type c = getChar(i); +#endif // Fully instantiated font LyXFont font = getFont(bparams, i); @@ -1755,8 +1803,11 @@ return return_value; } - +#ifdef I18N +bool Paragraph::sgmlConvertChar(wchar_t c, string & sgml_string) +#else bool Paragraph::sgmlConvertChar(char c, string & sgml_string) +#endif { bool retval = false; switch (c) { @@ -1948,7 +1999,11 @@ bool Paragraph::isLineSeparator(pos_type pos) const { +#ifdef I18N + wchar_type const c = getChar(pos); +#else value_type const c = getChar(pos); +#endif return IsLineSeparatorChar(c) || (IsInsetChar(c) && getInset(pos) && getInset(pos)->isLineSeparator()); @@ -1964,7 +2019,11 @@ /// Used by the spellchecker bool Paragraph::isLetter(pos_type pos) const { +#ifdef I18N + wchar_type const c = getChar(pos); +#else value_type const c = getChar(pos); +#endif if (IsLetterChar(c)) return true; if (isInset(pos)) @@ -2054,7 +2113,11 @@ string::size_type const len = s.size(); for (pos_type i = 0; i < size(); ++i) { +#ifdef I18N + wchar_type c = getChar(i); +#else value_type c = getChar(i); +#endif if (IsPrintable(c)) s += c; else if (c == META_INSET && @@ -2081,7 +2144,11 @@ ost << params().labelString() << ' '; for (pos_type i = beg; i < end; ++i) { +#ifdef I18N + wchar_type const c = getUChar(buffer->params,i); +#else value_type const c = getUChar(buffer->params, i); +#endif if (IsPrintable(c)) ost << c; else if (c == META_NEWLINE) @@ -2150,8 +2217,11 @@ return pimpl_->size(); } - +#ifdef I18N +Paragraph::wchar_type Paragraph::getChar(pos_type pos) const +#else Paragraph::value_type Paragraph::getChar(pos_type pos) const +#endif { return pimpl_->getChar(pos); } @@ -2221,8 +2291,11 @@ pimpl_->counter_[i]++; } - +#ifdef I18N +void Paragraph::setChar(pos_type pos, wchar_type c) +#else void Paragraph::setChar(pos_type pos, value_type c) +#endif { pimpl_->setChar(pos, c); } diff -urdN lyx-1.2.0/src/paragraph.h CJK-LyX-1.2.0/src/paragraph.h --- lyx-1.2.0/src/paragraph.h Fri Mar 22 02:25:18 2002 +++ CJK-LyX-1.2.0/src/paragraph.h Tue Jul 9 15:55:40 2002 @@ -76,6 +76,9 @@ META_INSET }; /// +#ifdef I18N + typedef wchar_t wchar_type; +#endif typedef char value_type; /// The same as ParameterStruct::depth_type typedef unsigned int depth_type; @@ -256,11 +259,23 @@ LyXFont const getLayoutFont(BufferParams const &) const; LyXFont const getLabelFont(BufferParams const &) const; /// +#ifdef I18N + wchar_type getChar(lyx::pos_type pos) const; +#else value_type getChar(lyx::pos_type pos) const; +#endif /// +#ifdef I18N //contributed by Satoru GOTO + wchar_type getUChar(BufferParams const &, lyx::pos_type pos) const; +#else value_type getUChar(BufferParams const &, lyx::pos_type pos) const; +#endif /// The position must already exist. +#ifdef I18N + void setChar(lyx::pos_type pos, wchar_type c); +#else void setChar(lyx::pos_type pos, value_type c); +#endif /// void setFont(lyx::pos_type pos, LyXFont const & font); /// Returns the height of the highest font in range @@ -268,9 +283,17 @@ lyx::pos_type endpos, LyXFont::FONT_SIZE const def_size) const; /// +#ifdef I18N + void insertChar(lyx::pos_type pos, wchar_type c); +#else void insertChar(lyx::pos_type pos, value_type c); +#endif /// +#ifdef I18N + void insertChar(lyx::pos_type pos, wchar_type c, LyXFont const &); +#else void insertChar(lyx::pos_type pos, value_type c, LyXFont const &); +#endif /// bool checkInsertChar(LyXFont &); /// @@ -333,7 +356,11 @@ void unsetPExtraType(BufferParams const &); #endif /// +#ifdef I18N + bool sgmlConvertChar(wchar_t c, string & sgml_string); +#else bool sgmlConvertChar(char c, string & sgml_string); +#endif /// bool isFreeSpacing() const; diff -urdN lyx-1.2.0/src/paragraph_pimpl.C CJK-LyX-1.2.0/src/paragraph_pimpl.C --- lyx-1.2.0/src/paragraph_pimpl.C Tue Apr 23 06:38:53 2002 +++ CJK-LyX-1.2.0/src/paragraph_pimpl.C Tue Jul 9 15:55:40 2002 @@ -31,6 +31,11 @@ using std::upper_bound; using std::lower_bound; +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#endif + extern int tex_code_break_column; @@ -86,8 +91,11 @@ text = par->pimpl_->text; } - +#ifdef I18N +Paragraph::wchar_type Paragraph::Pimpl::getChar(pos_type pos) const +#else Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const +#endif { lyx::Assert(pos <= size()); // This is stronger, and I belive that this is the assertion @@ -100,15 +108,22 @@ return text[pos]; } - +#ifdef I18N + void Paragraph::Pimpl::setChar(pos_type pos, wchar_type c) +#else void Paragraph::Pimpl::setChar(pos_type pos, value_type c) +#endif { text[pos] = c; } - +#ifdef I18N + void Paragraph::Pimpl::insertChar(pos_type pos, wchar_type c, + LyXFont const & font) +#else void Paragraph::Pimpl::insertChar(pos_type pos, value_type c, LyXFont const & font) +#endif { lyx::Assert(pos <= size()); @@ -292,10 +307,19 @@ LyXLayout const & style, pos_type & i, int & column, +#ifdef I18N + wchar_type const c) +#else value_type const c) +#endif { if (style.pass_thru) { +#ifdef I18N + if (c != '\0') + codeconverter.lyxos(os, c); +#else if (c != '\0') os << c; +#endif return; } // Two major modes: LaTeX or plain @@ -375,21 +399,29 @@ << '}'; column += 13; } else { +#ifdef I18N + codeconverter.lyxos(os, c); +#else os << c; +#endif } break; case '|': case '<': case '>': // In T1 encoding, these characters exist if (lyxrc.fontenc == "T1") { +#ifdef I18N + codeconverter.lyxos(os, c); +#else os << c; +#endif //... but we should avoid ligatures if ((c == '>' || c == '<') && i <= size() - 2 && getChar(i + 1) == c) { //os << "\\textcompwordmark{}"; // Jean-Marc, have a look at - // this. I think this works + // this. I?think this works // equally well: os << "\\,{}"; // Lgb @@ -399,7 +431,11 @@ } // Typewriter font also has them if (font.family() == LyXFont::TYPEWRITER_FAMILY) { +#ifdef I18N + codeconverter.lyxos(os, c); +#else os << c; +#endif break; } // Otherwise, we use what LaTeX @@ -441,14 +477,23 @@ os << "\\pounds{}"; column += 8; } else { +#ifdef I18N + codeconverter.lyxos(os, c); +#else os << c; +#endif } break; case '$': case '&': case '%': case '#': case '{': case '}': case '_': +#ifdef I18N + os << '\\' ; + codeconverter.lyxos(os, c); +#else os << '\\' << c; +#endif column += 1; break; @@ -464,7 +509,12 @@ case '*': case '[': case ']': // avoid being mistaken for optional arguments +#ifdef I18N + os << '{' ; codeconverter.lyxos(os, c); + os << '}' ; +#else os << '{' << c << '}'; +#endif column += 2; break; @@ -481,7 +531,11 @@ // I assume this is hack treating typewriter as verbatim if (font.family() == LyXFont::TYPEWRITER_FAMILY) { if (c != '\0') { +#ifdef I18N + codeconverter.lyxos(os, c); +#else os << c; +#endif } break; } @@ -504,7 +558,12 @@ } if (pnr == phrases_nr && c != '\0') { + +#ifdef I18N + codeconverter.lyxos(os, c); +#else os << c; +#endif } break; } diff -urdN lyx-1.2.0/src/paragraph_pimpl.h CJK-LyX-1.2.0/src/paragraph_pimpl.h --- lyx-1.2.0/src/paragraph_pimpl.h Fri Mar 22 02:25:18 2002 +++ CJK-LyX-1.2.0/src/paragraph_pimpl.h Tue Jul 9 15:55:40 2002 @@ -25,7 +25,11 @@ struct Paragraph::Pimpl { /// +#ifdef I18N + typedef std::vector TextContainer; +#else typedef std::vector TextContainer; +#endif /// Pimpl(Paragraph * owner); @@ -40,11 +44,23 @@ /// void setContentsFromPar(Paragraph const * par); /// +#ifdef I18N + wchar_type getChar(lyx::pos_type pos) const; +#else value_type getChar(lyx::pos_type pos) const; +#endif /// +#ifdef I18N + void setChar(lyx::pos_type pos, wchar_type c); +#else void setChar(lyx::pos_type pos, value_type c); +#endif /// - void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font); +#ifdef I18N + void insertChar(lyx::pos_type pos, wchar_type c, LyXFont const & font); +#else + void insertChar(lyx::pos_type pos, value_type c, LyXFont const & font); +#endif /// void insertInset(lyx::pos_type pos, Inset * inset, LyXFont const & font); /// @@ -140,7 +156,12 @@ LyXFont & basefont, bool & open_font, LyXLayout const & style, lyx::pos_type & i, - int & column, value_type const c); + int & column, +#ifdef I18N + wchar_type const c); +#else + value_type const c); +#endif /// Paragraph * getParFromID(int id) const; /// diff -urdN lyx-1.2.0/src/screen.C CJK-LyX-1.2.0/src/screen.C --- lyx-1.2.0/src/screen.C Fri May 3 18:22:06 2002 +++ CJK-LyX-1.2.0/src/screen.C Tue Jul 9 15:55:40 2002 @@ -99,7 +99,7 @@ void LyXScreen::expose(int x, int y, int exp_width, int exp_height) -{ +{ // cout<<"TEST3\n"<refresh_y - text->first_y), 0); drawFromTo(text, bv, y, owner.height(), y_offset, x_offset); + text->refresh_y = 0; // otherwise this is called ONLY from BufferView_pimpl(update) // or we should see to set this flag accordingly if (text != bv->text) text->status(bv, LyXText::UNCHANGED); expose(0, y, owner.workWidth(), owner.height() - y); + } break; case LyXText::NEED_VERY_LITTLE_REFRESH: diff -urdN lyx-1.2.0/src/support/StrPool.C CJK-LyX-1.2.0/src/support/StrPool.C --- lyx-1.2.0/src/support/StrPool.C Fri Mar 22 02:06:35 2002 +++ CJK-LyX-1.2.0/src/support/StrPool.C Tue Jul 9 15:55:40 2002 @@ -13,7 +13,10 @@ #include #include "StrPool.h" - +#ifdef I18N +#include "lyxcodeconv.h" +extern LyXCodeConv codeconverter; +#endif StrPool::~StrPool() { @@ -28,6 +31,16 @@ bit slower, but memory requirements would be lower in the long run. I expect that it would be fast enough anyway. (Lgb) */ +#ifdef I18N +wchar_t const * StrPool::add(string const & str) +{ string::size_type s = str.length(); + wchar_t * buf = new wchar_t [s + 1]; + int len = codeconverter.lyxmbstowcs(buf,&str); + buf[len] = '\0'; + pool_.push_back(buf); + return buf; +} +#else char const * StrPool::add(string const & str) { string::size_type s = str.length(); @@ -37,5 +50,6 @@ pool_.push_back(buf); return buf; } +#endif //StrPool strPool; diff -urdN lyx-1.2.0/src/support/StrPool.h CJK-LyX-1.2.0/src/support/StrPool.h --- lyx-1.2.0/src/support/StrPool.h Fri Mar 22 02:06:35 2002 +++ CJK-LyX-1.2.0/src/support/StrPool.h Tue Jul 9 15:55:40 2002 @@ -25,11 +25,19 @@ /// delete all the strings that have been allocated by add() ~StrPool(); /// Make a copy of the string, and remember it in the pool +#ifdef I18N + wchar_t const * add(string const & str); +#else char const * add(string const & str); +#endif private: /// +#ifdef I18N + typedef std::vector Pool; +#else typedef std::vector Pool; +#endif /// Pool pool_; }; diff -urdN lyx-1.2.0/src/support/lstrings.C CJK-LyX-1.2.0/src/support/lstrings.C --- lyx-1.2.0/src/support/lstrings.C Mon Apr 15 21:05:07 2002 +++ CJK-LyX-1.2.0/src/support/lstrings.C Tue Jul 9 15:55:40 2002 @@ -628,7 +628,12 @@ enc += hexdigit[c>>4]; enc += hexdigit[c & 15]; } else { - enc += c; +#ifdef I18N + enc += (char)c; +#else + enc += c; +#endif + } } return enc; diff -urdN lyx-1.2.0/src/support/lyxstring.C CJK-LyX-1.2.0/src/support/lyxstring.C --- lyx-1.2.0/src/support/lyxstring.C Thu May 2 23:12:44 2002 +++ CJK-LyX-1.2.0/src/support/lyxstring.C Tue Jul 9 15:55:40 2002 @@ -25,6 +25,14 @@ #include "debug.h" + +#ifdef I18N + #include "lyxcodeconv.h" + extern LyXCodeConv codeconverter; + static const unsigned short xtra = 4; +#endif + + using std::min; using std::istream; using std::ostream; @@ -76,9 +84,17 @@ /// The total amount of data reserved for this representaion size_t res; /// Data. At least 1 char for trailing null. +#ifdef I18N + lyxstring::wchar_type * w; +#endif + lyxstring::value_type * s; /// +#ifdef I18N + Srep(lyxstring::size_type nsz, const lyxstring::wchar_type * p); +#endif + Srep(lyxstring::size_type nsz, const lyxstring::value_type * p); /// Srep(lyxstring::size_type nsz, lyxstring::value_type ch); @@ -94,6 +110,9 @@ /// void assign(lyxstring::size_type nsz, const lyxstring::value_type * p); /// +#ifdef I18N + void assign(lyxstring::size_type nsz, const lyxstring::wchar_type * p); +#endif void assign(lyxstring::size_type nsz, lyxstring::value_type ch); /// void append(lyxstring::size_type asz, const lyxstring::value_type * p); @@ -115,6 +134,25 @@ Srep & operator=(const Srep &); }; +#ifdef I18N + lyxstring::Srep::Srep(lyxstring::size_type nsz, const wchar_t * p) + { + int wclen = codeconverter.lyxwclen(p) ; + char *mbs=new char [wclen * 2 + 1]; + sz = nsz; + ref = 1; + res = sz ? sz : 1; + s = new value_type[res + 1]; // add space for terminator + if (p && sz) { + // if sz = 0 nothing gets copied and we have an error + memcpy(s, mbs, sz); + } else { + // possibly allows for large but empty string + sz = 0; // this line should be redundant + s[0] = '\0'; + } + } + #endif lyxstring::Srep::Srep(lyxstring::size_type nsz, const value_type * p) { @@ -150,6 +188,32 @@ } } +#ifdef I18N + void lyxstring::Srep::assign(lyxstring::size_type nsz, const wchar_type * p) + { + // can be called with p == 0 + // by lyxstring::assign(const value_type *, size_type) + + int wclen = codeconverter.lyxwclen(p) ; + char *mbs=new char [wclen * 2 + 1]; + if (res < nsz) { + delete[] s; + sz = nsz; + res = sz ? sz : 1; + s = new value_type[res + 1]; // add space for terminator + } else { + sz = nsz; + } + if (p && sz) { + // if sz = 0 nothing gets copied and we have an error + memcpy(s, mbs, sz); + } else { + // stops segfaults + sz = 0; // this line should be redundant + s[0] = '\0'; + } + } +#endif void lyxstring::Srep::assign(lyxstring::size_type nsz, const value_type * p) { @@ -418,7 +482,6 @@ } } - lyxstring::lyxstring(value_type const * s, size_type n) { lyx::Assert(s && n < npos); // STD! @@ -431,6 +494,22 @@ } } +#ifdef I18N +lyxstring::lyxstring(wchar_type const * s) + { + lyx::Assert(s); // STD! + static Srep empty_rep(0, ""); + int wclen = codeconverter.lyxwclen(s) ; + char *mbs=new char [wclen * 2 + 1]; + register unsigned int const len = codeconverter.lyxwcstombs(mbs,s,wclen*2+1); + if (*s) { // s is not empty string + rep = new Srep(len, s); + } else { + ++empty_rep.ref; + rep = &empty_rep; + } + } + #endif lyxstring::lyxstring(value_type const * s) { @@ -575,6 +654,17 @@ return assign(s); } +#ifdef I18N +lyxstring & lyxstring::operator=(wchar_type c) +{ + + char *mbs=new char [3]; + int len = codeconverter.lyxwctomb(mbs,c); + mbs[len] = '\0'; + return operator=(mbs); + +} +#endif lyxstring & lyxstring::operator=(value_type c) { @@ -589,7 +679,7 @@ rep = new Srep(1, s); } return *this; -} +} lyxstring & lyxstring::assign(lyxstring const & x) @@ -724,13 +814,13 @@ } -lyxstring & lyxstring::operator+=(value_type c) + lyxstring & lyxstring::operator+=(value_type c) { TestlyxstringInvariant(this); push_back(c); return *this; -} +} void lyxstring::push_back(value_type c) @@ -1774,7 +1864,7 @@ while (extracted < n && c != eof && !isspace(c)) { - str += c; + str += (char)c; ++extracted; c = sb->snextc(); } @@ -1823,3 +1913,14 @@ cout << a.rfind("d") << endl; } #endif + +#ifdef I18N + lyxstring & lyxstring::operator+=(wchar_t wc) + { + char *mbs=new char [3]; + + int len = codeconverter.lyxwctomb(mbs,wc); + mbs[len] = '\0'; + return operator+=(mbs); + } +#endif diff -urdN lyx-1.2.0/src/support/lyxstring.h CJK-LyX-1.2.0/src/support/lyxstring.h --- lyx-1.2.0/src/support/lyxstring.h Fri Mar 22 02:06:35 2002 +++ CJK-LyX-1.2.0/src/support/lyxstring.h Tue Jul 9 15:55:40 2002 @@ -93,6 +93,9 @@ /* Typedefs */ /// +#ifdef I18N + typedef wchar_t wchar_type; +#endif typedef char value_type; /// @@ -157,9 +160,17 @@ lyxstring(lyxstring const &, size_type pos = 0, size_type n = npos); /// #lyxstring x("abc", 2) -> "ab"# +#ifdef I18N + lyxstring(wchar_type const *, size_type n); +#endif + lyxstring(value_type const *, size_type n); // #lyxstring x("abc")# +#ifdef I18N + lyxstring(wchar_type const*); +#endif + lyxstring(value_type const *); /// lyxstring(5, 'n') -> "nnnnn" @@ -212,6 +223,9 @@ lyxstring & operator=(value_type const *); /// +#ifdef I18N + lyxstring & operator=(wchar_type); +#endif lyxstring & operator=(value_type); /// @@ -221,12 +235,20 @@ lyxstring & assign(lyxstring const &, size_type pos, size_type n); /// +#ifdef I18N + lyxstring & assign(wchar_type const * p, size_type n); +#endif + lyxstring & assign(value_type const * p, size_type n); /// lyxstring & assign(value_type const * p); /// +#ifdef I18N + lyxstring & assign(size_type n, wchar_type c); +#endif + lyxstring & assign(size_type n, value_type c); #if 1 @@ -265,6 +287,9 @@ lyxstring & operator+=(value_type const *); /// +#ifdef I18N + lyxstring& operator+=(wchar_type); +#endif lyxstring & operator+=(value_type); /// diff -urdN lyx-1.2.0/src/support/textutils.h CJK-LyX-1.2.0/src/support/textutils.h --- lyx-1.2.0/src/support/textutils.h Fri Mar 22 02:06:35 2002 +++ CJK-LyX-1.2.0/src/support/textutils.h Tue Jul 9 15:57:51 2002 @@ -14,41 +14,77 @@ /// inline -bool IsNewlineChar(char c) { +bool IsNewlineChar( +#ifdef I18N + wchar_t c +#else + char c +#endif + ) { return (c == Paragraph::META_NEWLINE); } /// inline -bool IsSeparatorChar(char c) { +bool IsSeparatorChar( +#ifdef I18N + wchar_t c +#else + char c +#endif + ) { return (c == ' '); } /// inline -bool IsHfillChar(char c) { +bool IsHfillChar( +#ifdef I18N + wchar_t c +#else + char c +#endif + ) { return (c == Paragraph::META_HFILL); } /// inline -bool IsInsetChar(char c) { +bool IsInsetChar( +#ifdef I18N + wchar_t c +#else + char c +#endif + ) { return (c == Paragraph::META_INSET); } /// inline -bool IsLineSeparatorChar(char c) { +bool IsLineSeparatorChar( +#ifdef I18N + wchar_t c +#else + char c +#endif + ) { return (c == ' '); } /// inline -bool IsKommaChar(char c) { +bool IsKommaChar( +#ifdef I18N + wchar_t c +#else + char c +#endif + ) { return (c == ',' || c == '(' || c == ')' @@ -87,11 +123,18 @@ /// +#ifdef I18N +inline +bool IsPrintable(wchar_t c) { + return true; +} +#endif + inline bool IsPrintable(unsigned char c) { return ((c & 127) >= ' '); } - +//#endif /// inline diff -urdN lyx-1.2.0/src/text.C CJK-LyX-1.2.0/src/text.C --- lyx-1.2.0/src/text.C Tue May 14 18:40:54 2002 +++ CJK-LyX-1.2.0/src/text.C Tue Jul 9 15:55:40 2002 @@ -47,6 +47,11 @@ using std::pair; using lyx::pos_type; +#ifdef I18N + #include "lyxcodeconv.h" + extern LyXCodeConv codeconverter; +#endif + namespace { int const LYX_PAPER_MARGIN = 20; @@ -190,13 +195,22 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par, pos_type pos) const { +#ifdef I18N + wchar_t c = par->getChar(pos); +#else char const c = par->getChar(pos); +#endif + return singleWidth(bview, par, pos, c); } - +#ifdef I18N + int LyXText::singleWidth(BufferView * bview, Paragraph * par, + pos_type pos, wchar_t c) const +#else int LyXText::singleWidth(BufferView * bview, Paragraph * par, pos_type pos, char c) const +#endif { LyXFont const font = getFont(bview->buffer(), par, pos); @@ -620,7 +634,11 @@ // collect as much similar chars as we can while (vpos <= last && (pos = vis2log(vpos)) >= 0) { +#ifdef I18N + wchar_t c = p.row->par()->getChar(pos); +#else char c = p.row->par()->getChar(pos); +#endif if (!IsPrintableNonspace(c)) break; @@ -652,7 +670,11 @@ float const orig_x = p.x; +#ifdef I18N + wchar_t const c = par->getChar(pos); +#else char const c = par->getChar(pos); +#endif if (IsNewlineChar(c)) { ++vpos; @@ -1006,7 +1028,11 @@ bool doitonetime = true; while (doitonetime || ((x < width) && (i < last))) { doitonetime = false; +#ifdef I18N + wchar_t c = par->getChar(i); +#else char const c = par->getChar(i); +#endif Inset * in = 0; if (c == Paragraph::META_INSET) in = par->getInset(i); @@ -1053,6 +1079,10 @@ } else { if (par->isLineSeparator(i)) last_separator = i; +#ifdef I18N + if (codeconverter.lyxIsLineSeparatorChar(c)) + last_separator = i-1; +#endif x += singleWidth(bview, par, i, c); } ++i; @@ -1836,7 +1866,11 @@ /* insert a character, moves all the following breaks in the * same Paragraph one to the right and make a rebreak */ +#ifdef I18N + void LyXText::insertChar(BufferView * bview, wchar_t c) +#else void LyXText::insertChar(BufferView * bview, char c) +#endif { setUndo(bview, Undo::INSERT, cursor.par(), cursor.par()->next()); @@ -1870,7 +1904,11 @@ number(bview); // Set current_font.number to ON if (cursor.pos() > 0) { +#ifdef I18N + wchar_t const c = cursor.par()->getChar(cursor.pos() - 1); +#else char const c = cursor.par()->getChar(cursor.pos() - 1); +#endif if (contains(number_unary_operators, c) && (cursor.pos() == 1 || cursor.par()->isSeparator(cursor.pos() - 2) || @@ -2512,7 +2550,7 @@ cursorRight(bview); else { LyXCursor tmpcursor = cursor; - tmpcursor.row(0); // ?? + tmpcursor.row(0); //??? selection.set(true); // to avoid deletion cursorRightOneWord(bview); setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); @@ -2555,7 +2593,7 @@ LyXCursor tmpcursor = cursor; // We can't store the row over a regular setCursor // so we set it to 0 and reset it afterwards. - tmpcursor.row(0); // ?? + tmpcursor.row(0); //??? selection.set(true); // to avoid deletion cursorEnd(bview); setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); @@ -2657,8 +2695,13 @@ // We are at the end of a paragraph. if (tmppos == tmppar->size() - 1) return; - unsigned char c1 = tmppar->getChar(tmppos); +#ifdef I18N + wchar_t c1 = tmppar->getChar(tmppos); + wchar_t c2 = tmppar->getChar(tmppos - 1); +#else + unsigned char c1 = tmppar->getChar(tmppos); unsigned char c2 = tmppar->getChar(tmppos - 1); +#endif if (c1 != Paragraph::META_INSET && c2 != Paragraph::META_INSET) { diff -urdN lyx-1.2.0/src/text2.C CJK-LyX-1.2.0/src/text2.C --- lyx-1.2.0/src/text2.C Thu May 2 21:45:27 2002 +++ CJK-LyX-1.2.0/src/text2.C Tue Jul 9 15:58:52 2002 @@ -45,6 +45,13 @@ #include "support/textutils.h" #include "support/lstrings.h" +#ifdef I18N +#include "lyxcodeconv.h" + extern LyXCodeConv codeconverter; +#include "lyxim.h" + extern LyXIM lyxim; +#endif + using std::vector; using std::copy; using std::find; @@ -1894,7 +1901,7 @@ linestr[i] = ' '; newline_inserted = true; } - } else if (IsPrintable(linestr[i])) { + } else if (IsPrintable((unsigned char)linestr[i])) { newline_inserted = false; } }