lib/languages | 2 +- lib/lyx2lyx/LyX.py | 31 +++++++++++++++++++++++++++++-- src/frontends/qt4/GuiWorkArea.cpp | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/languages b/lib/languages index 2756195..7a600ca 100644 --- a/lib/languages +++ b/lib/languages @@ -54,7 +54,7 @@ nynorsk nynorsk "Nynorsk" false iso8859-15 nn_NO "" polish polish "Polish" false iso8859-2 pl_PL "" portuguese portuges "Portuguese" false iso8859-15 pt_PT "" romanian romanian "Romanian" false iso8859-2 ro_RO "" -russian russian "Russian" false koi8 ru_RU "" +russian russian "Russian" false koi8-r ru_RU "" scottish scottish "Scottish" false iso8859-15 gd_GB "" serbian croatian "Serbian" false iso8859-5 sr_HR "" serbocroatian croatian "Serbo-Croatian" false iso8859-2 sh_HR "" diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index e0adfd2..bfc0ff3 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - from parser_tools import get_value, check_token, find_token,\ find_tokens, find_end_of import os.path @@ -25,6 +24,7 @@ import locale import sys import re import time +import types try: import lyx2lyx_version @@ -278,8 +278,13 @@ class LyX_Base: header = self.header[:i] + preamble + self.header[i:] else: header = self.header - + + # i dont know what to do with this auto in this situation, just put locale + if self.inputencoding == 'auto': + self.inputencoding = locale.getpreferredencoding().lower() for line in header + [''] + self.body: + if type(line) is types.StringType: + line = unicode(line, self.inputencoding) self.output.write(line.encode(self.encoding)+"\n") @@ -613,6 +618,28 @@ class NewFile(LyX_Base): self.body.extend(['','\\end_body', '\\end_document']) + def write(self): + " Writes the LyX file to self.output." + self.set_version() + self.set_format() + self.set_textclass() + if self.encoding == "auto": + self.encoding = get_encoding(self.language, self.encoding, self.format, self.cjk_encoding) + + if self.preamble: + i = find_token(self.header, '\\textclass', 0) + 1 + preamble = ['\\begin_preamble'] + self.preamble + ['\\end_preamble'] + if i == 0: + self.error("Malformed LyX file: Missing '\\textclass'.") + else: + header = self.header[:i] + preamble + self.header[i:] + else: + header = self.header + + for line in header + [''] + self.body: + self.output.write(line.encode(self.encoding)+"\n") + + class Paragraph: # unfinished implementation, it is missing the Text and Insets representation. diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index a6c08b1..5d9146e 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -557,13 +557,13 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev) */ if (need_resize_) { + need_resize_ = false; verticalScrollBar()->setPageStep(viewport()->height()); screen_ = QPixmap(viewport()->width(), viewport()->height()); resizeBufferView(); updateScreen(); WorkArea::hideCursor(); WorkArea::showCursor(); - need_resize_ = false; } QPainter pain(viewport());