def clamp_cursor_horizontally(self):
        """Keep cursor on the editing area horizontally.

        That is, we clamp the cursor to the editign area,
        whenever it goes off to the sides, moving the visible
        lines along with it.

        Discussion
        ==========

        We don't worry about moving the cursor (nor the
        visible lines) vertically, because the visible lines
        have their vertical positions fixed and characters
        are very often all of the same height.

        There might be, though, rare cases where a character
        has a height different than that of the vast majority
        of other character.

        We didn't address this possibility yet, because on
        top of being rare, the slight difference in height
        might not be enough to justify adjusting the position
        of objects vertically.

        That is, the character might still be visible enough
        to be comfortably identified by the user editing the
        text.

        Even so, further measures should be taken in the
        future if problems arise. Until the last time this
        method was update, there never was a case where
        such possibility was observed or was a concern
        otherwise.
        """
        ### reference the cursor rect and obtain a copy of
        ### it clamped to the editing area rect

        rect = self.rect
        clamped = rect.clamp(EDITING_AREA_RECT)

        ### if such rects have the same horizontal position,
        ### it means there is no need for horizontal clamping
        ### so we just return right away
        if clamped.x == rect.x:
            return

        ### otherwise, it means we need to clamp the cursor
        ### horizontally and move the visible lines
        ### accordingly

        ## calculate the difference between the x coordinate
        ## of the clamped rect and of the original rect
        delta_x = clamped.x - rect.x

        ## offset the cursor and visible lines in the x axis
        ## by the obtained delta

        rect.move_ip(delta_x, 0)
        self.visible_lines.rect.move_ip(delta_x, 0)
Keep cursor on the editing area horizontally.

        That is, we clamp the cursor to the editign area,
        whenever it goes off to the sides, moving the visible
        lines along with it.

        Discussion
        ==========

        We don't worry about moving the cursor (nor the
        visible lines) vertically, because the visible lines
        have their vertical positions fixed and characters
        are very often all of the same height.

        There might be, though, rare cases where a character
        has a height different than that of the vast majority
        of other character.

        We didn't address this possibility yet, because on
        top of being rare, the slight difference in height
        might not be enough to justify adjusting the position
        of objects vertically.

        That is, the character might still be visible enough
        to be comfortably identified by the user editing the
        text.

        Even so, further measures should be taken in the
        future if problems arise. Until the last time this
        method was update, there never was a case where
        such possibility was observed or was a concern
        otherwise.
        
nodezator/textman/editor/cursor/op.py