[gedit-latex] Remove Toggle Comment



commit 3ebb60d2fddf212ae65bda779d2d83e6df780104
Author: John Stowers <john stowers gmail com>
Date:   Fri Jun 24 14:18:31 2011 +1200

    Remove Toggle Comment

 latex/base/__init__.py |  128 ------------------------------------------------
 latex/base/config.py   |    5 +-
 latex/latex/actions.py |   11 ----
 3 files changed, 2 insertions(+), 142 deletions(-)
---
diff --git a/latex/base/__init__.py b/latex/base/__init__.py
index fcd4e88..9e0ece1 100644
--- a/latex/base/__init__.py
+++ b/latex/base/__init__.py
@@ -681,134 +681,6 @@ class Editor(object):
 		else:
 			return ""
 	
-	def toggle_comment(self, delimiter):
-		"""
-		Enable/disable the line comment of the current line or the selection.
-		
-		@param delimiter: The comment delimiter (for LaTeX this is "%")
-		"""
-		
-		# TODO: generalize this, for now we ignore the delimiter
-		
-		bounds = self._text_buffer.get_selection_bounds()
-		
-		if bounds:
-			startIt, endIt = bounds
-			
-			# first run: check current comment state
-			#
-			# We propose that EVERY line is commented and loop through
-			# the lines to verify that.
-			# Thus we may abort at the first line that is NOT commented.
-			
-			selectionCommented = True
-			
-			tmpIt = startIt.copy()
-			tmpIt.set_line_offset(0)
-			
-			while tmpIt.compare(endIt) < 0:
-				
-				# walk through the line: skip spaces and tabs and abort at "%"
-				lineCommented = True
-				
-				while True:
-					c = tmpIt.get_char()
-					if c == "%" or c == "\n":
-						break
-					elif c == " " or c == "\t":
-						tmpIt.forward_char()
-					else:
-						lineCommented = False
-						break
-				
-				if lineCommented:
-					tmpIt.forward_line()
-				else:
-					selectionCommented = False
-					break
-			
-			
-			# second run: (un)comment selected 
-			
-			tmpIt = startIt.copy()
-			tmpIt.set_line_offset(0)
-			
-			while tmpIt.compare(endIt) < 0:
-				
-				# we must use marks here because iterators are invalidated on buffer changes
-				tmpMark = self._text_buffer.create_mark(None, tmpIt, True)
-				endMark = self._text_buffer.create_mark(None, endIt, True)
-				
-				if selectionCommented:
-					# uncomment
-					
-					# walk through the line to find "%" character and delete it
-					while True:
-						c = tmpIt.get_char()
-						if c == "%":
-							delIt = tmpIt.copy()
-							delIt.forward_char()
-							self._text_buffer.delete(tmpIt, delIt)
-							break
-						elif c == "\n":
-							# empty line, skip it
-							break
-				
-				else:
-					# comment
-					self._text_buffer.insert(tmpIt, "%")
-				
-				# restore iterators from marks and delete the marks
-				tmpIt = self._text_buffer.get_iter_at_mark(tmpMark)
-				endIt = self._text_buffer.get_iter_at_mark(endMark)
-				
-				self._text_buffer.delete_mark(tmpMark)
-				self._text_buffer.delete_mark(endMark)
-				
-				# go to next line
-				tmpIt.forward_line()
-				
-		else:
-			# no selection, process the current line, no second run needed
-			
-			tmpIt = self._text_buffer.get_iter_at_mark(self._text_buffer.get_insert())
-			tmpIt.set_line_offset(0)
-			
-			# get comment status
-			lineCommented = True
-				
-			while True:
-				c = tmpIt.get_char()
-				if c == "%" or c == "\n":
-					break
-				elif c == " " or c == "\t":
-					tmpIt.forward_char()
-				else:
-					lineCommented = False
-					break
-			
-			tmpIt.set_line_offset(0)
-			
-			# toggle
-			if lineCommented:
-				# uncomment
-				
-				# walk through the line to find "%" character and delete it
-				while True:
-					c = tmpIt.get_char()
-					if c == "%":
-						delIt = tmpIt.copy()
-						delIt.forward_char()
-						self._text_buffer.delete(tmpIt, delIt)
-						break
-					elif c == "\n":
-						# empty line, skip it
-						break
-			
-			else:
-				# comment
-				self._text_buffer.insert(tmpIt, "%")
-	
 	def select(self, start_offset, end_offset):
 		"""
 		Select a range of text and scroll the view to the right position
diff --git a/latex/base/config.py b/latex/base/config.py
index a03e665..cfc9790 100644
--- a/latex/base/config.py
+++ b/latex/base/config.py
@@ -38,7 +38,6 @@ UI = """
 			<placeholder name="ExtraMenu_1">
 				<menu action="LaTeXMenuAction">
 					<menuitem action="LaTeXChooseMasterAction" />
-					<menuitem action="LaTeXCommentAction" />
 					<separator />
 					<menuitem action="LaTeXGraphicsAction" />
 					<menuitem action="LaTeXTableAction" />
@@ -130,7 +129,7 @@ UI = """
 
 # actions
 
-from ..latex.actions import LaTeXMenuAction, LaTeXNewAction, LaTeXCommentAction, LaTeXPreviewAction, LaTeXChooseMasterAction, \
+from ..latex.actions import LaTeXMenuAction, LaTeXNewAction, LaTeXPreviewAction, LaTeXChooseMasterAction, \
 		LaTeXItemizeAction, LaTeXEnumerateAction, LaTeXFontFamilyAction, LaTeXFontFamilyMenuAction, LaTeXBoldAction, \
 		LaTeXItalicAction, LaTeXEmphasizeAction, LaTeXDescriptionAction, LaTeXStructureMenuAction, LaTeXPartAction, LaTeXChapterAction, \
 		LaTeXSectionAction, LaTeXSubsectionAction, LaTeXParagraphAction,LaTeXSubparagraphAction, LaTeXStructureAction, \
@@ -144,7 +143,7 @@ from ..latex.actions import LaTeXMenuAction, LaTeXNewAction, LaTeXCommentAction,
 
 from ..bibtex.actions import BibTeXMenuAction, BibTeXNewEntryAction
 
-ACTIONS = [ LaTeXMenuAction, LaTeXNewAction, LaTeXCommentAction, LaTeXPreviewAction, LaTeXChooseMasterAction, 
+ACTIONS = [ LaTeXMenuAction, LaTeXNewAction, LaTeXPreviewAction, LaTeXChooseMasterAction, 
 		LaTeXItemizeAction, LaTeXEnumerateAction, LaTeXFontFamilyAction, LaTeXFontFamilyMenuAction, LaTeXBoldAction, 
 		LaTeXItalicAction, LaTeXEmphasizeAction, LaTeXDescriptionAction, LaTeXStructureMenuAction, LaTeXPartAction, LaTeXChapterAction, 
 		LaTeXSectionAction, LaTeXSubsectionAction, LaTeXParagraphAction,LaTeXSubparagraphAction, LaTeXStructureAction, 
diff --git a/latex/latex/actions.py b/latex/latex/actions.py
index 301e226..5614b37 100644
--- a/latex/latex/actions.py
+++ b/latex/latex/actions.py
@@ -233,20 +233,9 @@ class LaTeXUseBibliographyAction(LaTeXIconAction):
 			editor.insert_at_position(source + "\n\n", LaTeXEditor.POSITION_BIBLIOGRAPHY)
 	
 
-class LaTeXCommentAction(LaTeXAction):
-	label = "Toggle Comment"
-	stock_id = None
-	accelerator = "<Ctrl><Alt>C"
-	tooltip = "Toggle LaTeX comment on the selection"
-	
-	def activate(self, context):
-		context.active_editor.toggle_comment("%")
-
-
 from ..util import verbose
 from livepreview import LaTeXPreviews
 
-
 class LaTeXPreviewAction(LaTeXAction):
 	label = "Embedded Preview"
 	stock_id = Gtk.STOCK_ZOOM_FIT



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]