def modified_contd(self, view): if view.settings().get( 'syntax') == 'Packages/Fountainhead/Fountainhead.tmLanguage': # if 'Fountainhead.tmLanguage' in view.settings().get('syntax'): self.cursor_position2 = view.rowcol(view.sel()[0].end()) # if sublime.load_settings('Fountainhead.sublime-settings').get('contd', False) and (self.cursor_position1 != self.cursor_position2): if view.settings().get('contd', False) and ( self.cursor_position1 != self.cursor_position2): s = SublimeHelper() # if s.cursor_scope(view) == 'text.fountain string entity.name.class ': if s.cursor_scope( view ) == fountain_scope + dialogue_scope + character_scope: self.cursor_row = view.rowcol(view.sel()[0].end())[0] - 1 self.cursor_position1 = self.cursor_position2 # elif s.cursor_scope(view) == 'text.fountain entity.name.function ': elif s.cursor_scope(view) == fountain_scope + scene_scope: self.cursor_row = view.rowcol(view.sel()[0].end())[0] self.cursor_position1 = self.cursor_position2 # elif s.cursor_scope(view) != 'text.fountain string entity.name.class ': elif s.cursor_scope( view ) != fountain_scope + dialogue_scope + character_scope: # print('cursor row ' + str(self.cursor_row)) # scope_array = view.find_by_selector('text.fountain entity.name.function ') scope_array = view.find_by_selector(fountain_scope + scene_scope) row_array = [] for position in scope_array: row_array.append( view.rowcol(sublime.Region.end(position))[0]) row_begin = 0 row_end = 0 for row in row_array: if row <= self.cursor_row: row_begin = row if row >= self.cursor_row and row_end == 0: row_end = row if row_end == 0 or row_end <= self.cursor_row: row = 0 text_point1 = 0 text_point2 = 1 while text_point1 != text_point2: text_point1 = view.text_point(row, 0) row += 1 text_point2 = view.text_point(row, 0) row_end = row self.update_contd(view, row_begin, row_end) self.cursor_position1 = self.cursor_position2
def modified_contd(self, view): if view.settings().get('syntax') == 'Packages/Fountainhead/Fountainhead.tmLanguage': # if 'Fountainhead.tmLanguage' in view.settings().get('syntax'): self.cursor_position2 = view.rowcol(view.sel()[0].end()) # if sublime.load_settings('Fountainhead.sublime-settings').get('contd', False) and (self.cursor_position1 != self.cursor_position2): if view.settings().get('contd', False) and (self.cursor_position1 != self.cursor_position2): s = SublimeHelper() # if s.cursor_scope(view) == 'text.fountain string entity.name.class ': if s.cursor_scope(view) == fountain_scope + dialogue_scope + character_scope: self.cursor_row = view.rowcol(view.sel()[0].end())[0] - 1 self.cursor_position1 = self.cursor_position2 # elif s.cursor_scope(view) == 'text.fountain entity.name.function ': elif s.cursor_scope(view) == fountain_scope + scene_scope: self.cursor_row = view.rowcol(view.sel()[0].end())[0] self.cursor_position1 = self.cursor_position2 # elif s.cursor_scope(view) != 'text.fountain string entity.name.class ': elif s.cursor_scope(view) != fountain_scope + dialogue_scope + character_scope: # print('cursor row ' + str(self.cursor_row)) # scope_array = view.find_by_selector('text.fountain entity.name.function ') scope_array = view.find_by_selector(fountain_scope + scene_scope) row_array = [] for position in scope_array: row_array.append(view.rowcol(sublime.Region.end(position))[0]) row_begin = 0 row_end = 0 for row in row_array: if row <= self.cursor_row: row_begin = row if row >= self.cursor_row and row_end == 0: row_end = row if row_end == 0 or row_end <= self.cursor_row: row = 0 text_point1 = 0 text_point2 = 1 while text_point1 != text_point2: text_point1 = view.text_point(row, 0) row += 1 text_point2 = view.text_point(row, 0) row_end = row self.update_contd(view, row_begin, row_end) self.cursor_position1 = self.cursor_position2
def modified_character(self, view): if view.settings().get('syntax') == 'Packages/Fountainhead/Fountainhead.tmLanguage': # if 'Fountainhead.tmLanguage' in view.settings().get('syntax'): # if sublime.load_settings('Fountainhead.sublime-settings').get('characters', True): if view.settings().get('characters', True): if self.characters == []: self.on_activated(view) view.set_status('CharacterList', '') if view.rowcol(view.sel()[0].end())[0] != self.current_line: self.previous_line = self.current_line self.current_line = view.rowcol(view.sel()[0].end())[0] # if view.scope_name(view.text_point(self.previous_line, 0)) == 'text.fountain dialogue entity.name.class ': # if view.scope_name(view.text_point(self.previous_line, 0)) == 'text.fountain dialogue entity.name.class ': if view.scope_name(view.text_point(self.previous_line, 0)) == fountain_scope + dialogue_scope + character_scope: # get character name from line s = SublimeHelper() self.current_character = view.substr(view.line(view.text_point(self.previous_line, 0))) character = s.line_string(view) name = self.current_character.split(' (O.S.)')[0] name = name.split(' (V.O.)')[0] name = name.split(' (OS)')[0] name = name.split(' (VO)')[0] name = name.split(" (CONT'D)")[0] name = name.split(' (ЗК)')[0] name = name.split(' (З.К.)')[0] name = name.split(' (ЗА КАДРОМ)')[0] name = name.split(' (ВПЗ)')[0] name = name.split(' (В.П.З.)')[0] name = name.split(' (ППЗ)')[0] name = name.split(' (П.П.З.)')[0] if name[0] == ' ' or name[0] == '\t': name = re.split(r'^\s*', name)[1] if name not in self.characters and name != '' and name is not None: self.characters.append(name) self.characters = sorted(self.characters) ShowCharactersCommand.characters = self.characters # Create Fountainhead directory if it doesn't exist packages_directory = sublime.packages_path() + '/User/Fountainhead/' if not os.path.exists(packages_directory): os.mkdir(packages_directory) completions_file = packages_directory + 'Characters.sublime-completions' # if user_os == 'Windows': # print("Sorry, not supported at this time.") # elif user_os == 'Darwin': completions = codecs.open(completions_file, 'w', 'utf8') # completions.write('{\n\t\t"scope": "text.fountain - comment - string - dialogue - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') completions.write('{\n\t\t"scope": ' + '"' + fountain_scope + '- ' + boneyard_scope + '- ' + action_scope + '- ' + dialogue_scope + '- ' + lyrics_scope + '- ' + character_scope + '- ' + parenthetical_scope + '- ' + note_scope + '- ' + scene_scope + '- ' + section_scope + '- ' + synopses_scope + '- ' + pagebreak_scope + '- ' + title_page_scope + '- ' + center_scope + '- ' + transition_scope[0:-1] + '",\n\n\t\t"completions":\n\t\t[') length = len(self.characters) character_counter = 0 for character in self.characters: if character_counter < length - 1: completions.write('"%s",' % character) character_counter += 1 else: completions.write('"%s"' % character) completions.write(']\n}') completions.close() # Not needed since characters are no longer converted to lowercase # if name[0] != '@': # if name.lower() not in self.lower_characters: # self.lower_characters.append(name.lower()) # self.lower_characters = sorted(self.lower_characters) # completions = codecs.open(completions_file, 'w', 'utf8') # completions.write('{\n\t\t"scope": "text.fountain - comment - string - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') # length = len(self.lower_characters) # character_counter = 0 # for character in self.lower_characters: # if character_counter < length - 1: # completions.write('"%s",' % character) # character_counter += 1 # else: # completions.write('"%s"' % character) # completions.write(']\n}') # completions.close() # elif name[0] == '@': # if name not in self.lower_characters: # self.lower_characters.append(name) # self.lower_characters = sorted(self.lower_characters) # completions = codecs.open(completions_file, 'w', 'utf8') # completions.write('{\n\t\t"scope": "text.fountain - comment - string - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') # length = len(self.lower_characters) # character_counter = 0 # for character in self.lower_characters: # if character_counter < length - 1: # completions.write('"%s",' % character) # character_counter += 1 # else: # completions.write('"%s"' % character) # completions.write(']\n}') # completions.close() # Clear out character list message view.set_status('CharacterList', '')
def modified_character(self, view): if view.settings().get('syntax') == 'Packages/Fountainhead/Fountainhead.tmLanguage': # if 'Fountainhead.tmLanguage' in view.settings().get('syntax'): # if sublime.load_settings('Fountainhead.sublime-settings').get('characters', True): if view.settings().get('characters', True): if self.characters == []: self.on_activated(view) view.set_status('CharacterList', '') if view.rowcol(view.sel()[0].end())[0] != self.current_line: self.previous_line = self.current_line self.current_line = view.rowcol(view.sel()[0].end())[0] # if view.scope_name(view.text_point(self.previous_line, 0)) == 'text.fountain dialogue entity.name.class ': # if view.scope_name(view.text_point(self.previous_line, 0)) == 'text.fountain dialogue entity.name.class ': if view.scope_name(view.text_point(self.previous_line, 0)) == fountain_scope + dialogue_scope + character_scope: # get character name from line s = SublimeHelper() self.current_character = view.substr(view.line(view.text_point(self.previous_line, 0))) character = s.line_string(view) name = self.current_character.split(' (O.S.)')[0] name = name.split(' (V.O.)')[0] name = name.split(' (OS)')[0] name = name.split(' (VO)')[0] name = name.split(" (CONT'D)")[0] if name[0] == ' ' or name[0] == '\t': name = re.split(r'^\s*', name)[1] if name not in self.characters and name != '' and name is not None: self.characters.append(name) self.characters = sorted(self.characters) ShowCharactersCommand.characters = self.characters # Create Fountainhead directory if it doesn't exist packages_directory = sublime.packages_path() + '/User/Fountainhead/' if not os.path.exists(packages_directory): os.mkdir(packages_directory) completions_file = packages_directory + 'Characters.sublime-completions' # if user_os == 'Windows': # print("Sorry, not supported at this time.") # elif user_os == 'Darwin': completions = codecs.open(completions_file, 'w', 'utf8') # completions.write('{\n\t\t"scope": "text.fountain - comment - string - dialogue - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') completions.write('{\n\t\t"scope": ' + '"' + fountain_scope + '- ' + boneyard_scope + '- ' + action_scope + '- ' + dialogue_scope + '- ' + lyrics_scope + '- ' + character_scope + '- ' + parenthetical_scope + '- ' + note_scope + '- ' + scene_scope + '- ' + section_scope + '- ' + synopses_scope + '- ' + pagebreak_scope + '- ' + title_page_scope + '- ' + center_scope + '- ' + transition_scope[0:-1] + '",\n\n\t\t"completions":\n\t\t[') length = len(self.characters) character_counter = 0 for character in self.characters: if character_counter < length - 1: completions.write('"%s",' % character) character_counter += 1 else: completions.write('"%s"' % character) completions.write(']\n}') completions.close() # Not needed since characters are no longer converted to lowercase # if name[0] != '@': # if name.lower() not in self.lower_characters: # self.lower_characters.append(name.lower()) # self.lower_characters = sorted(self.lower_characters) # completions = codecs.open(completions_file, 'w', 'utf8') # completions.write('{\n\t\t"scope": "text.fountain - comment - string - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') # length = len(self.lower_characters) # character_counter = 0 # for character in self.lower_characters: # if character_counter < length - 1: # completions.write('"%s",' % character) # character_counter += 1 # else: # completions.write('"%s"' % character) # completions.write(']\n}') # completions.close() # elif name[0] == '@': # if name not in self.lower_characters: # self.lower_characters.append(name) # self.lower_characters = sorted(self.lower_characters) # completions = codecs.open(completions_file, 'w', 'utf8') # completions.write('{\n\t\t"scope": "text.fountain - comment - string - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') # length = len(self.lower_characters) # character_counter = 0 # for character in self.lower_characters: # if character_counter < length - 1: # completions.write('"%s",' % character) # character_counter += 1 # else: # completions.write('"%s"' % character) # completions.write(']\n}') # completions.close() # Clear out character list message view.set_status('CharacterList', '')
def modified_character(self, view): if view.settings().get('syntax') == 'Packages/Fountainhead/Fountainhead.tmLanguage': # if 'Fountainhead.tmLanguage' in view.settings().get('syntax'): # if sublime.load_settings('Fountainhead.sublime-settings').get('characters', True): if view.settings().get('characters', True): if self.characters == []: self.on_activated(view) view.set_status('CharacterList', '') if view.rowcol(view.sel()[0].end())[0] != self.current_line: self.previous_line = self.current_line self.current_line = view.rowcol(view.sel()[0].end())[0] if view.scope_name(view.text_point(self.previous_line, 0)) == 'text.fountain string entity.name.class ': # get character name from line s = SublimeHelper() self.current_character = view.substr(view.line(view.text_point(self.previous_line, 0))) character = s.line_string(view) name = self.current_character.split(' (O.S.)')[0] name = name.split(' (V.O.)')[0] name = name.split(' (OS)')[0] name = name.split(' (VO)')[0] name = name.split(" (CONT'D)")[0] if name[0] == ' ' or name[0] == '\t': name = re.split(r'^\s*', name)[1] if name not in self.characters: self.characters.append(name) # Create Fountainhead directory if it doesn't exist packages_directory = sublime.packages_path() + '/User/Fountainhead/' if not os.path.exists(packages_directory): os.mkdir(packages_directory) completions_file = packages_directory + 'Characters.sublime-completions' # if user_os == 'Windows': # print("Sorry, not supported at this time.") # elif user_os == 'Darwin': if name[0] != '@': if name.lower() not in self.lower_characters: self.lower_characters.append(name.lower()) self.lower_characters = sorted(self.lower_characters) # proc_env = os.environ.copy() # encoding = sys.getfilesystemencoding() # for k, v in proc_env.items(): # proc_env[k] = os.path.expandvars(v).encode(encoding) # user = (proc_env['HOME']).decode(encoding='UTF-8') # completions = open(user + '/Library/Application Support/Sublime Text 3/Packages/Fountainhead/Characters.sublime-completions', 'w') completions = open(completions_file, 'w') completions.write('{\n\t\t"scope": "text.fountain - comment - string - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') length = len(self.lower_characters) character_counter = 0 for character in self.lower_characters: if character_counter < length - 1: completions.write('"%s",' % character) character_counter += 1 else: completions.write('"%s"' % character) completions.write(']\n}') completions.close() elif name[0] == '@': if name not in self.lower_characters: self.lower_characters.append(name) self.lower_characters = sorted(self.lower_characters) # proc_env = os.environ.copy() # encoding = sys.getfilesystemencoding() # for k, v in proc_env.items(): # proc_env[k] = os.path.expandvars(v).encode(encoding) # user = (proc_env['HOME']).decode(encoding='UTF-8') # completions = open(user + '/Library/Application Support/Sublime Text 3/Packages/Fountainhead/Characters.sublime-completions', 'w') completions = open(completions_file, 'w') completions.write('{\n\t\t"scope": "text.fountain - comment - string - entity.other.attribute-name - entity.other.inherited-class - foreground - meta.diff - entity.name.function - entity.name.tag - entity.name.class - variable.parameter",\n\n\t\t"completions":\n\t\t[') length = len(self.lower_characters) character_counter = 0 for character in self.lower_characters: if character_counter < length - 1: completions.write('"%s",' % character) character_counter += 1 else: completions.write('"%s"' % character) completions.write(']\n}') completions.close() # Clear out character list message view.set_status('CharacterList', '')