示例#1
0
    def updatePreviewAfterTypingPause(self):
        """
		Updates the preview when the user is making a pause while typing.
		"""
        preview_threshold = Preferences.getPreviewThreshold()
        time_delta = datetime.now() - self.last_time_content_changed
        elapsed_ms = time_delta.seconds * 1000 + time_delta.microseconds / 1000
        if elapsed_ms >= preview_threshold:
            self.updatePreview()
        else:
            wait_for = max(100, Preferences.getPreviewThreshold() / 2)
            QTimer.singleShot(wait_for, self.updatePreviewAfterTypingPause)
示例#2
0
	def updatePreviewAfterTypingPause(self):
		"""
		Updates the preview when the user is making a pause while typing.
		"""
		preview_threshold = Preferences.getPreviewThreshold()
		time_delta = datetime.now() - self.last_time_content_changed
		elapsed_ms = time_delta.seconds * 1000 + time_delta.microseconds / 1000
		if elapsed_ms >= preview_threshold:
			self.updatePreview()
		else:
			wait_for = max(100, Preferences.getPreviewThreshold() / 2)
			QTimer.singleShot(wait_for, self.updatePreviewAfterTypingPause)
示例#3
0
	def requestPreviewUpdate(self):
		if self._isEndOfInstruction():
			self.updatePreview()
		elif Preferences.getAutoPreview():
			self.updatePreviewAfterTypingPause()
		else:
			self.request_preview_update = False
示例#4
0
 def _convertSourceFileToPDF(self):
     latex2pdf_command = Template(Preferences.getLatexToPDFCommand())
     latex2pdf_command = latex2pdf_command.safe_substitute(
         OUTPUT_DIR=self.output_directory,
         FILE_NAME=self.unique_random_file_name,
         FILE_PATH=self.source_file_path)
     self._latex_process.start(latex2pdf_command)
示例#5
0
 def requestPreviewUpdate(self):
     if self._isEndOfInstruction():
         self.updatePreview()
     elif Preferences.getAutoPreview():
         self.updatePreviewAfterTypingPause()
     else:
         self.request_preview_update = False
示例#6
0
	def loadSnippets(self):
		snippets_menu = self.actions[actions.SNIPPETS_MENU]
		snippets_menu.clear()
		snippets = Preferences.getSnippets()
		for snippet_name in sorted(snippets.iterkeys()):
			snippet_code = snippets[snippet_name]
			action = ActionFactory.createAction(self, snippet_name, "Insert \"%s\" Snippet" % snippet_name, None, self.insertSnippet)
			action.setData(QVariant(snippet_code))
			snippets_menu.addAction(action)
示例#7
0
	def _initSubViews(self):
		self.editor_splitter = QSplitter(self)
		self.editor_splitter.setOrientation(Qt.Vertical)
		self.editor_splitter.addWidget(self.content_view)
		self.editor_splitter.addWidget(self.feedback_view)
		self.editor_splitter.setStretchFactor(0, 2)
		self.editor_splitter.setStretchFactor(1, 1)
		if Preferences.hasEditorSplitterState():
			self.editor_splitter.restoreState(Preferences.getEditorSplitterState())

		self.main_splitter = QSplitter(self)
		self.main_splitter.setOrientation(Qt.Horizontal)
		self.main_splitter.addWidget(self.editor_splitter)
		self.main_splitter.addWidget(self.preview_view)
		if Preferences.hasMainSplitterState():
			self.main_splitter.restoreState(Preferences.getMainSplitterState())
		else:
			self.main_splitter.setSizes([self.width() / 2] * 2)

		self.setCentralWidget(self.main_splitter)
示例#8
0
    def _initSubViews(self):
        self.editor_splitter = QSplitter(self)
        self.editor_splitter.setOrientation(Qt.Vertical)
        self.editor_splitter.addWidget(self.content_view)
        self.editor_splitter.addWidget(self.feedback_view)
        self.editor_splitter.setStretchFactor(0, 2)
        self.editor_splitter.setStretchFactor(1, 1)
        if Preferences.hasEditorSplitterState():
            self.editor_splitter.restoreState(
                Preferences.getEditorSplitterState())

        self.main_splitter = QSplitter(self)
        self.main_splitter.setOrientation(Qt.Horizontal)
        self.main_splitter.addWidget(self.editor_splitter)
        self.main_splitter.addWidget(self.preview_view)
        if Preferences.hasMainSplitterState():
            self.main_splitter.restoreState(Preferences.getMainSplitterState())
        else:
            self.main_splitter.setSizes([self.width() / 2] * 2)

        self.setCentralWidget(self.main_splitter)
示例#9
0
 def _sourceSelectionChanged(self):
     select_tags = Preferences.getSelectTags()
     if (not select_tags):
         source = self.source_editor_view
         (line_from, index_from, line_to, index_to) = source.getSelection()
         selection_changed = False
         if line_from == 0 and index_from < 19:
             index_from = 19
             selection_changed = True
         if line_to == source.lines() - 1:
             line_to = source.lines() - 2
             index_to = source.lineSize(line_to + 1)
             selection_changed = True
         if selection_changed:
             source.setSelection(line_from, index_from, line_to, index_to)
示例#10
0
 def _sourceCursorPositionChanged(self, line, index):
     select_tags = Preferences.getSelectTags()
     if (not select_tags):
         source = self.source_editor_view
         content = source.content
         if not (content.startswith("\\begin{tikzpicture}")
                 and content.startswith("\\begin{tikzpicture")):
             source.content = "\\begin{tikzpicture}" + content[18:]
         if line == 0 and index < 20:
             source.setCursorPosition(0, 19)
             source.setReadOnly(True)
         elif line == source.lines() - 1:
             source.setCursorPosition(source.lines() - 2,
                                      source.lineSize(source.lines() - 1))
             source.setReadOnly(True)
示例#11
0
	def loadUserPreferences(self):
		# editor font
		font = Preferences.getEditorFont()
		font.setPointSize(12)

		self.setFont(font)
		lexer = LexerTikZ()
		lexer.setDefaultFont(font)
		self.setLexer(lexer)

		# margins
		if self.show_margin:
			self._setMarginFont(font)
		else:
			self._hideMargin()

		# auto-wrap
		auto_wrap = Preferences.getAutoWrap()
		self.setWrapMode(auto_wrap)
		if auto_wrap:
			# hide horizontal scrollbar
			self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
		else:
			# show horizontal scrollbar
			self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)
			self.SendScintilla(QsciScintilla.SCI_SETSCROLLWIDTH, 1)
			self.SendScintilla(QsciScintilla.SCI_SETSCROLLWIDTHTRACKING, 1)

		# file encoding
		encoding = Preferences.getFileEncoding()
		self.setUtf8(encoding == Preferences.ENCODING_UTF8)

		# line endings
		line_endings = Preferences.getLineEndings()
		if line_endings == Preferences.LINE_ENDINGS_WINDOWS:
			self.setEolMode(EditorView.EolWindows)
		elif line_endings == Preferences.LINE_ENDINGS_MAC:
			self.setEolMode(EditorView.EolMac)
		else:
			self.setEolMode(EditorView.EolUnix)

		# indentation type
		indentation_type = Preferences.getIndentationType()
		self.setIndentationsUseTabs(indentation_type == Preferences.INDENT_TAB)

		# indentation size
		self.setTabWidth(Preferences.getIndentationSize())
示例#12
0
	def loadUserPreferences(self):
		# editor font
		font = Preferences.getEditorFont()
		self.setFont(font)
		lexer = LexerTikZ()
		lexer.setDefaultFont(font)
		self.setLexer(lexer)

		# margins
		if self.show_margin:
			self._setMarginFont(font)
		else:
			self._hideMargin()

		# auto-wrap
		auto_wrap = Preferences.getAutoWrap()
		self.setWrapMode(auto_wrap)
		if auto_wrap:
			# hide horizontal scrollbar
			self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
		else:
			# show horizontal scrollbar
			self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)
			self.SendScintilla(QsciScintilla.SCI_SETSCROLLWIDTH, 1)
			self.SendScintilla(QsciScintilla.SCI_SETSCROLLWIDTHTRACKING, 1)

		# file encoding
		encoding = Preferences.getFileEncoding()
		self.setUtf8(encoding == Preferences.ENCODING_UTF8)

		# line endings
		line_endings = Preferences.getLineEndings()
		if line_endings == Preferences.LINE_ENDINGS_WINDOWS:
			self.setEolMode(EditorView.EolWindows)
		elif line_endings == Preferences.LINE_ENDINGS_MAC:
			self.setEolMode(EditorView.EolMac)
		else:
			self.setEolMode(EditorView.EolUnix)

		# indentation type
		indentation_type = Preferences.getIndentationType()
		self.setIndentationsUseTabs(indentation_type == Preferences.INDENT_TAB)

		# indentation size
		self.setTabWidth(Preferences.getIndentationSize())
示例#13
0
 def _restoreAllSnippets(self):
     self.snippets = Preferences.defaultSnippets()
     self.snippetsChangedSignal.emit(self.snippets)
示例#14
0
 def _restoreWindowState(self):
     if Preferences.hasWindowGeometry():
         self.restoreGeometry(Preferences.getWindowGeometry())
示例#15
0
 def _initSelectedView(self):
     selected_view = Preferences.getSelectedFeedbackView()
     if selected_view == ERRORS_VIEW:
         self.showErrorsView()
     else:
         self.showLogsView()
示例#16
0
 def showErrorsView(self):
     self.stacked_widget.setCurrentWidget(self.errors_view)
     Preferences.setSelectedFeedbackView(ERRORS_VIEW)
     if not self.actions[actions.SHOW_ERRORS].isChecked():
         self.actions[actions.SHOW_ERRORS].setChecked(True)
示例#17
0
 def _restoreDefaultTemplate(self):
     self.latex_file_editor.content = Preferences.defaultLatexFileTemplate()
示例#18
0
 def _convertPDFToImage(self):
     pdf2image_command = Template(Preferences.getPDFToImageCommand())
     pdf2image_command = pdf2image_command.safe_substitute(
         PDF_PATH=self.pdf_file_path, IMAGE_PATH=self.png_file_path)
     self._convert_process.start(pdf2image_command)
示例#19
0
 def _restoreDefaultLatex2PDF(self):
     self.latex2pdf_text.setText(Preferences.defaultLatexToPDFCommand())
示例#20
0
	def _syncViewAndModel(self):
		self.view.editor.editor_font = Preferences.getEditorFont()
		self.view.editor.file_encoding = Preferences.getFileEncoding()
		self.view.editor.line_endings = Preferences.getLineEndings()
		self.view.editor.indentation_type = Preferences.getIndentationType()
		self.view.editor.indentation_size = Preferences.getIndentationSize()
		self.view.editor.auto_wrap = Preferences.getAutoWrap()
		self.view.editor.error_markers = Preferences.getShowErrorMarkers()
		self.view.editor.error_annotations = Preferences.getShowErrorAnnotations()
		self.view.editor.auto_preview = Preferences.getAutoPreview()
		self.view.editor.preview_threshold = Preferences.getPreviewThreshold()

		self.view.document.latex_file_template = Preferences.getLatexFileTemplate()
		self.view.document.preamble_template = Preferences.getPreambleTemplate()

		self.view.preview.preview_template = Preferences.getPreviewTemplate()
		self.view.preview.latex_to_pdf_command = Preferences.getLatexToPDFCommand()
		self.view.preview.pdf_to_image_command = Preferences.getPDFToImageCommand()

		self.view.snippets.snippets = Preferences.getSnippets()
示例#21
0
	def showErrorsView(self):
		self.stacked_widget.setCurrentWidget(self.errors_view)
		Preferences.setSelectedFeedbackView(ERRORS_VIEW)
		if not self.actions[actions.SHOW_ERRORS].isChecked():
			self.actions[actions.SHOW_ERRORS].setChecked(True)
示例#22
0
 def _restoreDefaultPreviewTemplate(self):
     self.preview_template_editor.content = Preferences.defaultPreviewTemplate(
     )
示例#23
0
	def showLogsView(self):
		self.stacked_widget.setCurrentWidget(self.logs_view)
		Preferences.setSelectedFeedbackView(LOGS_VIEW)
		if not self.actions[actions.SHOW_LOGS].isChecked():
			self.actions[actions.SHOW_LOGS].setChecked(True)
示例#24
0
	def _initSelectedView(self):
		selected_view = Preferences.getSelectedFeedbackView()
		if selected_view == ERRORS_VIEW:
			self.showErrorsView()
		else:
			self.showLogsView()
示例#25
0
	def _restoreWindowState(self):
		if Preferences.hasWindowGeometry():
			self.restoreGeometry(Preferences.getWindowGeometry())
示例#26
0
 def _restoreDefaultPDF2Image(self):
     self.pdf2image_text.setText(Preferences.defaultPDFToImageCommand())
示例#27
0
 def _restoreDefaultPDF2Image(self):
     self.pdf2image_text.setText(Preferences.defaultPDFToImageCommand())
示例#28
0
	def _convertPDFToImage(self):
		pdf2image_command = Template(Preferences.getPDFToImageCommand())
		pdf2image_command = pdf2image_command.safe_substitute(PDF_PATH=self.pdf_file_path, IMAGE_PATH=self.png_file_path)
		self._convert_process.start(pdf2image_command)
示例#29
0
 def _restoreDefaultPreviewTemplate(self):
     self.preview_template_editor.content = Preferences.defaultPreviewTemplate()
示例#30
0
 def _restoreDefaultPreamble(self):
     self.preamble_editor.content = Preferences.defaultPreambleTemplate()
示例#31
0
	def _restoreAllSnippets(self):
		self.snippets = Preferences.defaultSnippets()
		self.snippetsChangedSignal.emit(self.snippets)
示例#32
0
	def _convertSourceFileToPDF(self):
		latex2pdf_command = Template(Preferences.getLatexToPDFCommand())
		latex2pdf_command = latex2pdf_command.safe_substitute(OUTPUT_DIR=self.output_directory, FILE_NAME=self.unique_random_file_name, FILE_PATH=self.source_file_path)
		self._latex_process.start(latex2pdf_command)
示例#33
0
	def _restoreWindowState(self):
		if Preferences.hasWindowGeometry():
			self.restoreGeometry(Preferences.getWindowGeometry())
		else:
			self.setWindowState(Qt.WindowMaximized)
示例#34
0
	def loadUserPreferences(self):
		self.show_error_markers = Preferences.getShowErrorMarkers()
		self.show_error_annotations = Preferences.getShowErrorAnnotations()
		self.clearErrorMarginMarkersAndAnnotations()
		self._updateEditorsMarginsAndAnnotations()
示例#35
0
	def _saveWindowState(self):
		Preferences.setWindowGeometry(self.saveGeometry())
		Preferences.setEditorSplitterState(self.editor_splitter.saveState())
		Preferences.setMainSplitterState(self.main_splitter.saveState())
示例#36
0
 def showLogsView(self):
     self.stacked_widget.setCurrentWidget(self.logs_view)
     Preferences.setSelectedFeedbackView(LOGS_VIEW)
     if not self.actions[actions.SHOW_LOGS].isChecked():
         self.actions[actions.SHOW_LOGS].setChecked(True)
示例#37
0
	def _restoreDefaultTemplate(self):
		self.latex_file_editor.content = Preferences.defaultLatexFileTemplate()
示例#38
0
 def _restoreWindowState(self):
     if Preferences.hasWindowGeometry():
         self.restoreGeometry(Preferences.getWindowGeometry())
     else:
         self.setWindowState(Qt.WindowMaximized)
示例#39
0
	def _restoreDefaultPreamble(self):
		self.preamble_editor.content = Preferences.defaultPreambleTemplate()
示例#40
0
 def updatePreview(self):
     self.request_preview_update = False
     doc = self.doc_controller.model
     template = Preferences.getPreviewTemplate()
     source = documentIO.buildFileContentFromDocument(template, doc)
     self.latex2image_converter.convertLatexToImage(source)
示例#41
0
	def updatePreview(self):
		self.request_preview_update = False
		doc = self.doc_controller.model
		template = Preferences.getPreviewTemplate()
		source = documentIO.buildFileContentFromDocument(template, doc)
		self.latex2image_converter.convertLatexToImage(source)
示例#42
0
 def _saveWindowState(self):
     Preferences.setWindowGeometry(self.saveGeometry())
     Preferences.setEditorSplitterState(self.editor_splitter.saveState())
     Preferences.setMainSplitterState(self.main_splitter.saveState())
示例#43
0
 def _restoreDefaultLatex2PDF(self):
     self.latex2pdf_text.setText(Preferences.defaultLatexToPDFCommand())