1. Henning Schröder
  2. pyqtermwidget
  3. Issues
Issue #3 new

Improvement in backend.py csi_CTC()

Sergey Satskiy
created an issue

There is a member function csi_CTC in backend.py:

def csi_CTC(self, p):
    # Cursor tabulation control
    p = self.vt100_parse_params(p, ['0'], False)
    for m in p:
        if m == '0':
            try:
                ts = self.tab_stops.index(self.cx)
            except ValueError:
                tab_stops = self.tab_stops
                tab_stops.append(self.cx)
                tab_stops.sort()
                self.tab_stops = tab_stops
        elif m == '2':
            try:
                self.tab_stops.remove(self.cx)
            except ValueError:
                pass
        elif m == '5':
            self.tab_stops = [0]

It seems excessive to have a try ... except block (the first one) to test if a value is in a list. Should it be a simple if instead?

def csi_CTC(self, p):
    # Cursor tabulation control
    p = self.vt100_parse_params(p, ['0'], False)
    for m in p:
        if m == '0':
            if self.cx not in self.tab_stops:
                self.tab_stops.append(self.cx)
                self.tab_stops.sort()
        elif m == '2':
            try:
                self.tab_stops.remove(self.cx)
            except ValueError:
                pass
        elif m == '5':
            self.tab_stops = [0]

Comments (0)

  1. Log in to comment