本文整理汇总了Python中pyqode.core.api.TextHelper.lstrip方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.lstrip方法的具体用法?Python TextHelper.lstrip怎么用?Python TextHelper.lstrip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.TextHelper
的用法示例。
在下文中一共展示了TextHelper.lstrip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_indent
# 需要导入模块: from pyqode.core.api import TextHelper [as 别名]
# 或者: from pyqode.core.api.TextHelper import lstrip [as 别名]
def _get_indent(self, cursor):
prev_line_text = TextHelper(self.editor).current_line_text()
if not self.editor.free_format:
prev_line_text = " " * 7 + prev_line_text[7:]
diff = len(prev_line_text) - len(prev_line_text.lstrip())
post_indent = " " * diff
min_column = self.editor.indenter_mode.min_column
if len(post_indent) < min_column:
post_indent = min_column * " "
# all regex are upper cases
text = cursor.block().text().upper()
# raise indentation level
patterns = [regex.PARAGRAPH_PATTERN, regex.STRUCT_PATTERN, regex.BRANCH_START, regex.LOOP_PATTERN]
for ptrn in patterns:
if ptrn.indexIn(text) != -1:
post_indent += self.editor.tab_length * " "
return "", post_indent
# use the previous line indentation
return "", post_indent