Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move line numbers in arabic pane to right of screen #327

Closed
sgrieve opened this issue Jul 18, 2018 · 5 comments · Fixed by #400
Closed

Move line numbers in arabic pane to right of screen #327

sgrieve opened this issue Jul 18, 2018 · 5 comments · Fixed by #400
Labels
Milestone

Comments

@sgrieve
Copy link
Contributor

sgrieve commented Jul 18, 2018

This may require modifying the TextLineNumber Java class.

@sgrieve sgrieve added the arabic label Jul 18, 2018
@sgrieve sgrieve added this to the Right to left milestone Jul 18, 2018
@giordano
Copy link
Contributor

giordano commented Jun 27, 2019

I have looked into this, but it doesn't appear to be straightforward.

In the line-numbers-arabic branch you can find my attempt at addressing this issue. I made some minor adjustments to the Java class in order to be able to customise appearance of the line numbers panel depending on whether it's for a left-to-right or right-to-left text component.

The main problem is that the TextLineNumber class heavily relies on being attached to the text component with setRowHeader. In standard Java Swing there is no setRowFooter (note: there is in Jide: http://www.jidesoft.com/javadoc/com/jidesoft/swing/JideScrollPane.html). With @raquel-ucl, we tried attaching the line numbers to the panel in AtfAreaView.__init__ with:

        pref_size = Dimension(1, 500)
        self.edit_area.setPreferredSize(pref_size)
        self.container = JScrollPane(self.edit_area)
        outer_container = JPanel()
        outer_container.setLayout(BorderLayout())
        outer_container.add(self.container, BorderLayout.CENTER)
        outer_container.add(self.line_numbers_area, BorderLayout.EAST)
        outer_container.setPreferredSize(pref_size)
        self.add(outer_container, BorderLayout.CENTER)

In this way, TextLineNumber.paintComponent miscomputes clip = g.getClipBounds(), because g never changes. I tried setting clip = component.getVisibleRect(), but doesn't fully work and scrolling the text doesn't update the line numbers (probably because repainting is not triggered, as the text scrollbar now is somewhat separated from the line numbers).

I'll leave the branch here for reference in case anyone will want to have a look in the future.

@ageorgou
Copy link
Contributor

ageorgou commented Jul 4, 2019

According to this answer, switching the orientation of the JScrollPane that contains the numbers and the edit area should work. At the moment we're setting the orientation of the whole text pane (arabic_area), but not the scroll pane (secondary_editor), so maybe it's not "inherited" (or it's set after we create the scroll pane)?

Looking at it more, the JScrollPane's setComponentOrientation method does something beyond the default, so we probably need to invoke it, whereas for the JTextPane it's related to the text direction. Changing the orientiation of the scroll pane will also move the scroll bar to the left, but I guess that may be reasonable?

@giordano
Copy link
Contributor

giordano commented Jul 4, 2019

Changing the orientiation of the scroll pane will also move the scroll bar to the left, but I guess that may be reasonable?

I'm not familiar, but googling for Arabic text editors it seems that some of them do have scroll bar to the left, but not all.

@ageorgou
Copy link
Contributor

ageorgou commented Jul 4, 2019

Another (untested!) possible solution, with a variant of the TextLineNumber: https://stackoverflow.com/a/52326451/11658609

@giordano
Copy link
Contributor

giordano commented Jul 5, 2019

Well, it turned out that simply setting the orientation of the container of the Arabic line numbers to right-to-left was sufficient. I'm going to open a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants