omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Outliner with drag/drop reordering

    Pythonista
    10
    1003
    660267
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ihf
      ihf last edited by

      @cvp thanks. I will certainly continue to use the script. Have a great weekend!

      cvp 3 Replies Last reply Reply Quote 0
      • JonB
        JonB last edited by

        @cvp Are you logging function enter AND exit? What could have happened is set_content_inset was the last method called, but then whatever the calling function was failed

        cvp 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @JonB last edited by cvp

          @JonB we are not yet sure, we only one trace that the crash is always at same line

          	@on_main_thread
          	def set_content_inset(self,bb):
          		mytrace(inspect.stack())
          		# Standard TextView has a top positive inset by default
          		ObjCInstance(bb).textContainerInset = UIEdgeInsets(0,0,0,0)
          

          called in TableView_cell_for_row but a lot of lines after that...I can't trace all
          See a comment "a lot of segmentation errors when we scroll"
          Sincerely, as the errors are not reproductive, il is almost impossible to debug.

          
          		self.set_content_inset(bb)
          		bb.row = row
          		ObjCInstance(bb).tv = bb
          		bb.text = txt
          		bb.text_color = 'blue'
          		#bb.border_width = 1
          		bb.font = ft
          		bb.number_of_lines = 0
          		#bb.frame = (x,0,self.width-x-4,ft[1])
          		w = bb.width
          		bb.size_to_fit()
          		ho = bb.height
          		bb.frame = (bb.x,bb.y,w,ho)
          		#print('bb:',self.font_size,ho)
          		if self.select:
          			bb.touch_enabled = False
          		else:
          			swipe(bb, self.swipe_left_handler,direction=LEFT)
          			swipe(bb, self.swipe_right_handler,direction=RIGHT)
          
          		#bb.border_width = 1
          		cell.content_view.add_subview(bb)
          		
          		if not hidden:	
          			# separation line
          			if self.show_lines_separator == 'yes':					
          				sep = ui.Label()
          				sep.frame = (0,hrow-1,self.tv.width,1)
          				sep.border_width = 1
          				sep.border_color = 'lightgray'
          				cell.content_view.add_subview(sep)	
          				
          			self.redraw_textview_attributes(bb,opts)
          	
          		# a lot of segmentation errors when we scroll (which set_cursor)	
          		# does only if last action = add row
          		if row == self.cursor[0] and len(self.undo_multiples) > 0:
          			if self.undo_multiples[-1][0] in  ['CR','tab','back']:# or (row == 0 and txt == ''):
          				bb.begin_editing()
          				ui.delay(partial(self.textview_did_begin_editing,bb),0.1)
          				c = self.cursor[1]
          				if c >= len(bb.text):
          					c = max(0,len(bb.text))
          				#bb.selected_range = (c,c)
          				# Pythonista does not allow to set c = len(text) to put cursor at end
          				range = NSRange(c,c)
          				ObjCInstance(bb).setSelectedRange_(range)
          
          1 Reply Last reply Reply Quote 0
          • cvp
            cvp @ihf last edited by cvp

            @ihf New V01.00 and outline.versions with

            Version V01.00
              - add some traces in tableview_cell_for_row at place supposed to be crash origin
            
            1 Reply Last reply Reply Quote 0
            • cvp
              cvp @ihf last edited by

              @ihf New V01.01 and outline.versions with

              Version V01.01
                - use only one InputAccessoryView and share it for TextView of each row,
                  adviced by @jonB to gain memory
              
              1 Reply Last reply Reply Quote 0
              • cvp
                cvp @ihf last edited by

                @ihf Finally, I feel too lazy to convert the TableView to a ScrollvView, with the risk of encountering the same scrolling issues. On the other hand, I am always available to continue to try to correct problems if they are clearly identifiable.

                1 Reply Last reply Reply Quote 0
                • ihf
                  ihf last edited by

                  @cvp this is not at all urgent but perhaps you could add it to the to do list. I wanted someone else to try out outline and I realized that there are several files that they need to download in order to make it work. Would it be possible to either check for those files and download what is needed in the script or if that doesn’t make sense, perhaps a set up script that they could run once?

                  cvp 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @ihf last edited by cvp

                    @ihf I think, if I remember, that you only need now the outline.versions.
                    The outline.prm is automatically created if it does not exist.
                    I've moved the program elsewhere and run it, it seems to work (I wrote"it works" but I don't dare anymore to say that something works) Plus some imported modules of course.

                    As soon as possible, I'll do a version that will check if all needed files are present

                    1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp last edited by cvp

                      @ihf V01.02 and outline.versions with

                      Version V01.02
                        - check if all imported modules exist and, if not, print their list
                          and url's where to find them
                      

                      Not sure all are there but wait and see with first new user.

                      Added in my todo list to automatically download missing ones but not for coming days.

                      List is

                      Needed files
                      ============
                      SetTextFieldPad.py at https://github.com/cvpe/Pythonista-scripts/blob/master/SetTextFieldPad.py
                      File_Picker.py     at https://github.com/cvpe/Pythonista-scripts/blob/master/File_Picker.py
                      gestures.py        at https://github.com/mikaelho/pythonista-gestures/blob/master/gestures.py
                      blackmamba folder  at https://github.com/zrzka/blackmamba/tree/master/blackmamba
                      swizzle.py         at https://github.com/jsbain/objc_hacks/blob/master/swizzle.py
                      
                      all previous modules should be copied in site-packages
                      
                      outline.versions   at https://github.com/cvpe/Pythonista-scripts/blob/master/Gists/outline.versions
                      
                      previous file should be copied in same folder as outline.py
                      
                      1 Reply Last reply Reply Quote 0
                      • ihf
                        ihf last edited by

                        @cvp The menu that permits setting bold, italic, etc. is no longer coming up.

                        cvp 1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp @ihf last edited by cvp

                          @ihf said:

                          The menu that permits setting bold, italic, etc. is no longer coming up.

                          You know that some text needs to be selected first.
                          If so, and you select "bold..." in the popup menu, that works.
                          But the "bold" key does not work.

                          It seems that from V01.01 where I had put a modification to share the same InputAccessoryView for all rows prevents the keys of keyboard extra row to work. Not only the "bold" key but also promote
                          and demote keys.

                          Thus next version will remove this modification.

                          V01.03 and outline.versions with

                          Version V01.03
                            - remove sharing of one InputAccessoryView (set V01.01) which prevent keys of
                              keyboard extra row to work
                          
                          1 Reply Last reply Reply Quote 0
                          • JonB
                            JonB last edited by

                            I'm curious why that broke -- are you holding onto a reference to the text view itself? That seems dangerous unless you store tableviewcells after creation so that you can reuse the actual cell and its contents when cell_for_row is called.

                            cvp 2 Replies Last reply Reply Quote 0
                            • cvp
                              cvp @JonB last edited by ccc

                              @JonB sorry, never seen this post. I'm in holidays for some days. i'll answer this weekend

                              1 Reply Last reply Reply Quote 0
                              • cvp
                                cvp @JonB last edited by

                                @JonB said:

                                are you holding onto a reference to the text view itself?

                                No but I store the TableView row into the InputAccessoryView. Then, when a key is pressed in the supplementary keyboard row, I can call textview_should_change with the right row which is the index in TableView. And I don't need anything more, even the TextView it-self.

                                1 Reply Last reply Reply Quote 0
                                • ihf
                                  ihf last edited by

                                  @cvp when I type a new outline item, and I hit the return, the keyboard disappears. I think it would be better if the keyboard remained so that you could continue typing since you are positioned on the next outline line. Does that make sense?

                                  cvp 2 Replies Last reply Reply Quote 0
                                  • cvp
                                    cvp @ihf last edited by cvp

                                    @ihf said:

                                    when I type a new outline item, and I hit the return, the keyboard disappears. I think it would be better if the keyboard remained so that you could continue typing since you are positioned on the next outline line. Does that make sense?

                                    Yes sir. I had remarked this problem yesterday, sorry for you. I'll try to correct it tomorrow.
                                    That should be an old bug and I can't remember if I have already tried to solve it, and if yes, obviously without success

                                    1 Reply Last reply Reply Quote 0
                                    • cvp
                                      cvp @ihf last edited by

                                      @ihf V01.04 and outline.versions with

                                      Version V01.04
                                        - correction of bug "keyboard was disappearing after an enter 
                                          to create a new outline row"
                                      

                                      This bug was not so old, it should have appeared from V00.96 when I removed the undo/redo process and a part of this process variables is checked for cursor process.

                                      1 Reply Last reply Reply Quote 0
                                      • ihf
                                        ihf last edited by

                                        @cvp This is a (low priority) idea for the wish list: I sometimes want to read my outlines on the Mac. What I do now is save them in pdf or some other format that the Mac understands. This works fine but I have to remember to do it after any change so that the outline will be up-to-date. A reader script in python would permit me to view an outline on the Mac or on anything that runs python and has access to the iCloud files.

                                        1 Reply Last reply Reply Quote 0
                                        • ccc
                                          ccc last edited by ccc

                                          Given that this is the 1,002nd entry in this thread, perhaps it would be good to stop adding to this thread and create a new one to continue the discussion.
                                          The Forum software is not very efficient at buffering up and paginating tons of content especially when it contains images. Thoughts?

                                          1 Reply Last reply Reply Quote 0
                                          • ccc
                                            ccc last edited by

                                            CONTINUED AT https://forum.omz-software.com/topic/7248/outliner-with-drag-drop-reordering-part-2 ...

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors