def sync_cursor(self, selected_range):
        """
        Enforce the main screen cursor position to be the same as what it
        is shown on the terminal (TextView). This is mainly used for when
        user touch and change the cursor position/selection.
        """
        with self.main_screen.acquire_lock(blocking=False) as locked:
            if locked:
                self.main_screen.cursor_xs, self.main_screen.cursor_xe = selected_range
            # If lock cannot be required, it means other threads are updating the screen.
            # So there is no need to sync the cursor (as it will be changed by other
            # threads anyway).

        Enforce the main screen cursor position to be the same as what it
        is shown on the terminal (TextView). This is mainly used for when
        user touch and change the cursor position/selection.
        
system/shstreams.py