This file is indexed.

/usr/share/gEcrit/StcMode.py is in gecrit 2.8.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#  Copyright (C) 2011  Groza Cristian
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.


import wx
import wx.lib.inspection

class StcMode(object):
    """
    This class is an interface for all clases that want to implement a Mode for the StyledTextControl
    The children class must overwrite all the empty methods and all None instance variables.
    This class will be passed an wx.StyledTextCtrl and can have an enourmous amount of control over it.
    """
    lexer = None                # a lexer that will provide syntax highlight for the control.
                                # Must be part of wx.stc.STC_LEX####
    lang_name = ""              # language name eg: python, ruby...
    file_extensions = []       # a list of file extensions that this mode is candidate for. (format: ["py","pyw"])
    keywords = []             # a keyword list for this mode. (format: ["for","while"])
    def __init__(self, stc_ctrl):
        self.stc_ctrl = stc_ctrl
        
    def CommentSelection(self, comment_string):
        """
        This is a helper function for child classes.
        It appends @comment_string in front of every selected line.

        """
        # from drPython source code
        selstart, selend = self.stc_ctrl.GetSelection()
        #From the start of the first line selected
        oldcursorpos = self.stc_ctrl.GetCurrentPos()
        startline = self.stc_ctrl.LineFromPosition(selstart)
        self.stc_ctrl.GotoLine(startline)
        start = self.stc_ctrl.GetCurrentPos()
        #To the end of the last line selected
        #Bugfix Chris Wilson
        #Edited by Dan (selend fix)
        if selend == selstart:
            tend = selend
        else:
            tend = selend - 1

        docstring = comment_string

        end = self.stc_ctrl.GetLineEndPosition(self.stc_ctrl.LineFromPosition(tend))
        #End Bugfix Chris Wilson
        eol = self.stc_ctrl.GetEndOfLineCharacter()
        corr = 0
        l = len(self.stc_ctrl.GetText())
        # if self.prefs.doccommentmode == 0:
        self.stc_ctrl.SetSelection(start, end)
        text = docstring + self.stc_ctrl.GetSelectedText()
        text = text.replace(eol, eol + docstring)
        self.stc_ctrl.ReplaceSelection(text)
        corr = len(self.stc_ctrl.GetText()) - l
        self.stc_ctrl.GotoPos(oldcursorpos + corr)

    def UnCommentSelection(self, comment_string):
        """
        This is a helper function for child classes.
        It removes the leading @comment_string in selectod lines.
        """

        #from drPython source code
        #franz: pos is not used
        selstart, selend = self.stc_ctrl.GetSelection()
        #From the start of the first line selected
        startline = self.stc_ctrl.LineFromPosition(selstart)
        oldcursorpos = self.stc_ctrl.GetCurrentPos()
        self.stc_ctrl.GotoLine(startline)
        start = self.stc_ctrl.GetCurrentPos()
        #To the end of the last line selected
        #Bugfix Chris Wilson
        #Edited by Dan (selend fix)
        if selend == selstart:
            tend = selend
        else:
            tend = selend - 1
        end = self.stc_ctrl.GetLineEndPosition(self.stc_ctrl.LineFromPosition(tend))
        #End Bugfix Chris Wilson

        mask = self.stc_ctrl.GetModEventMask()
        self.stc_ctrl.SetModEventMask(0)
        lpos = start
        newtext = ""
        l = len(self.stc_ctrl.GetText())
        docstring = comment_string
        ldocstring = len(docstring)
        while lpos < end:
            lpos = self.stc_ctrl.PositionFromLine(startline)
            line = self.stc_ctrl.GetLine(startline)
            lc = line.find(docstring)
            if lc > -1:
                prestyle = self.stc_ctrl.GetStyleAt(lpos + lc - 1)
                style = self.stc_ctrl.GetStyleAt(lpos + lc)

                newtext += line[0:lc] + line[lc+ldocstring:]
            else:
                newtext += line
            startline += 1
            lpos = self.stc_ctrl.PositionFromLine(startline)
        self.stc_ctrl.SetModEventMask(mask)
        self.stc_ctrl.SetSelection(start, end)
        self.stc_ctrl.ReplaceSelection(newtext.rstrip(self.stc_ctrl.GetEndOfLineCharacter()))
        corr = len(self.stc_ctrl.GetText()) - l
        self.stc_ctrl.GotoPos(oldcursorpos + corr)

    # every method will be passed the event argument. The method must not event.Skip() it.
    #interface functions
    def OnComment(self, event):
        """This method will mangage commenting selections of text."""
        pass

    def OnUnComment(self, event):
        """ This method will manage uncommenting selections of text."""
        pass

    def AutoIndent(self, event):
        """
        This method will be called when the Enter key is pressed and autoindentation is enabled.
        This method must manage autoindentation.
        """
        pass

    def OnSelectCodeBlock(self, event):
        """
        This method manages selecting code blocks.
        """
        pass