Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 08-25-2024, 05:25 AM   #1
quocsan
Enthusiast
quocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it is
 
Posts: 32
Karma: 2204
Join Date: Jul 2009
Device: none
How to change style of Code View

Dear All,

I want to change height of lines in Code View so that lines will be easier to read. But I do not know how to do that with ‘qt_styles.qss’ file.
Could you please show me what to do?
Thanks for your help.
quocsan is offline   Reply With Quote
Old 08-25-2024, 08:34 AM   #2
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,219
Karma: 19000635
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Go to: Edit/Preferences/Appearance...then make sure you select the 'Code View' tab on the right pane.

That will change things like Font, Special Characters, and Color.

At the bottom right of the main ui window you can see the zoom bar that will change the font size.

If you right click on the CV window you can select 'Reformat HTML/Mend and Prettify Code' to rearrange and put a line space between each tag. You can also get there from 'Tools/Reformat HTML/Mend and Prettify Code'.

I haven't messed with the ‘qt_styles.qss’ file as I haven't needed to with the above options. There will likely be others that pop in with suggestions there.
Turtle91 is offline   Reply With Quote
Advert
Old 08-25-2024, 08:58 AM   #3
quocsan
Enthusiast
quocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it isquocsan knows what time it is
 
Posts: 32
Karma: 2204
Join Date: Jul 2009
Device: none
Quote:
Originally Posted by Turtle91 View Post
Go to: Edit/Preferences/Appearance...then make sure you select the 'Code View' tab on the right pane.
That will change things like Font, Special Characters, and Color.
Thank you for your reply, Turtle91!
I've known the settings you mentioned. But I want to change line height in Code View, i.e. 105% and so.
quocsan is offline   Reply With Quote
Old 08-25-2024, 09:18 AM   #4
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
Sigil Preferences allow you to set both the CodeView interface font and default font size, but I find clicking on CodeView and then using the zoom bar of the bottom right of Sigil to go to 110% makes CodeView much easier to see and work in. Just make sure the cursor is in CodeView before playing with the zoom bar settings, as they work on Preview as well.

Last edited by KevinH; 08-25-2024 at 10:33 AM.
KevinH is offline   Reply With Quote
Old 08-25-2024, 10:59 AM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm not sure the line-height of an entire document can be changed with qss. @BeckyEbook will probably know better.

In C++ code, QTextBlockFormat would be used to set line height.

Last edited by DiapDealer; 08-25-2024 at 12:06 PM.
DiapDealer is offline   Reply With Quote
Advert
Old 08-25-2024, 12:23 PM   #6
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 781
Karma: 2298438
Join Date: Jan 2017
Location: Poland
Device: Various
This cannot be done through a qss file.
Line height is sewn inside the font and depends on the size of the font offset.
I don't know if I'm using the right vocabulary, but it's simply a font metric that stores the height for the entire font and font family to maintain consistency.

In this exceptional case, for use in Sigil's Code View and without changing the program code (which is unnecessary, by the way) I think the best solution would be to edit the font and, for example, add 100 points ascender and 100 points descender.

An example below using the IBM Plex Mono font as an example.
One screenshot shows the original font and the other the modified one.

As you can see, in Sigil itself there is no control over this parameter of the Code View window.
Attached Thumbnails
Click image for larger version

Name:	sigil-ibm-plex-mono-standard.png
Views:	53
Size:	56.4 KB
ID:	210401   Click image for larger version

Name:	sigil-ibm-plex-mono-modified.png
Views:	56
Size:	53.7 KB
ID:	210402  
BeckyEbook is offline   Reply With Quote
Old 08-25-2024, 12:36 PM   #7
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
But instead of editing fonts which can be tricky, perhaps we really should add a new Preference to Sigil CodeView preferences to set line spacing from single, 1.5, or double using QTextBlockFormat as DiapDealer suggested.
KevinH is offline   Reply With Quote
Old 08-25-2024, 12:52 PM   #8
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I've not tested, but something along the lines of the following should work:

Code:
QTextBlockFormat bf = this->textCursor().blockFormat();
bf.setLineHeight(lineSpacing, QTextBlockFormat::LineDistanceHeight) ;
this->textCursor().setBlockFormat(bf);
I wouldn't think adding a preference with very limited options would prove terribly difficult. Might need to check there's no performance hit, though.
DiapDealer is offline   Reply With Quote
Old 08-25-2024, 12:55 PM   #9
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
But it needs to be set for each block in the document, after every change, right? At least that is what the stack google search I found seemed to imply.

So on initial load, and then after every change?

Last edited by KevinH; 08-25-2024 at 12:57 PM.
KevinH is offline   Reply With Quote
Old 08-25-2024, 01:00 PM   #10
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
But it needs to be set for each block in the document, after every change, right?
I've seen some similar snippets that claim to work for the whole document. It would probably need to be added to where our QTextEdit subclass is initiated.

Here's a short discussion on it: https://stackoverflow.com/questions/...g-in-qtextedit

EDIT: you're probably already looking at the same thing I am.
DiapDealer is offline   Reply With Quote
Old 08-25-2024, 02:09 PM   #11
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
I just tried it using that exact same approach on a QPlainTextEdit (which is what CV is) and could see no changes at all even though the code compiled just fine.

Code:
    QTextBlockFormat fmt;
    fmt.setLineHeight(150, QTextBlockFormat::ProportionalHeight);
    QTextCursor tc = textCursor();
    tc.clearSelection();
    tc.select(QTextCursor::Document);
    tc.mergeBlockFormat(fmt);

So something in QPlainTextEdit is preventing the change.

Last edited by KevinH; 08-25-2024 at 02:23 PM.
KevinH is offline   Reply With Quote
Old 08-25-2024, 02:15 PM   #12
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
Yep, known bug in Qt going back literally decades:

https://bugreports.qt.io/browse/QTBUG-51891

So doing it programmatically is out! I really do not want to rewrite our highly customized CodeViewEditor class as a QTextEdit class.

This is so silly of Qt.

The only options would be to:

1. Use a font specially modified ala BeckyEbook
2. Use Zoom which helps text readability in general but not line height
3. Use Mend and Prettify to double space text in CodeView then use Zoom to make things cleaner

I am leaning toward BeckyEbook's idea. Perhaps we can modify a set of fixed width fonts (Courier, et al ) and use FontForge to manually adjust the font metrics for 1.5 and double spacing and include them as optional fonts alongside Sigil.

Last edited by KevinH; 08-25-2024 at 02:36 PM.
KevinH is offline   Reply With Quote
Old 08-25-2024, 03:14 PM   #13
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Fonts could get tricky on Linux. Courier, Arial, Times New Roman are often merely aliases that point to other fonts. Customizing those aliases is not for the faint of heart.
DiapDealer is offline   Reply With Quote
Old 08-25-2024, 03:17 PM   #14
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
Okay, but that will really not leave us a path forward to fix this one. I am okay with that but hoped we could do something.
KevinH is offline   Reply With Quote
Old 08-25-2024, 03:34 PM   #15
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,219
Karma: 19000635
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
A combination of prettify and toggling OFF line wrap provides a space between lines. The downside being having to horizontal scroll to see the longer lines.
Turtle91 is offline   Reply With Quote
Reply

Tags
code view, qt_styles.qss


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change background color in Code View window philja Sigil 13 10-06-2022 12:27 PM
replace in book view changes view to code view cybmole Sigil 4 10-28-2012 02:20 PM
Sigil highlight Book View No Longer Shows in Code View Themus Sigil 4 10-04-2012 08:54 PM
How do I change the syntax colouring and increase the font size in the Code View? nicciglen Sigil 5 02-08-2012 10:34 AM
lock book view & code view windows into synch cybmole Sigil 5 01-19-2011 11:30 PM


All times are GMT -4. The time now is 10:24 PM.


MobileRead.com is a privately owned, operated and funded community.