FastHub Version: 4.1.0
Android Version: 6.0 (SDK: 23)
Device Information:
Could you add a option to change tab-size in code preview?
tab size? could you elaborate?
@k0shk0sh he means the amount of space for each tab
if (brown == true){
return plus
}
if (brown == true){
--> return plus
}
@yakov116 I thought that at beginning but said maybe I'm wrong.
Then this isn't possible and I don't see why would it make any sense anyway.
You could zoom in/out with your fingers or wrap content or download the file, other than that, I'm not looking at any customization to do for your code.
@k0shk0sh its used when looking through a lot of code. But the again you would normally use a computer to look through it.
Actually, as far as I can tell you _can_ change this, and it should be trivial too.
Since fasthub code themes are CSS based, I assume it uses Android WebView. In that case the number of spaces in the indentation can be changed via tab-width in the CSS for the code viewer. See https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size
@JobLeonard PR?
Not an android dev, sorry :)
I don't I mind helping out, it's just that getting everything up and running would take so much time, and all of that to add one line of CSS!
But I _can_ help look at where you might want to change this, is that good enough? I just skimmed the code base, and I think the change should be as follows (but again, I can't test this on my machine!)
In the PrettyfyHelper.java file, the header is defined between between line 14 and 23:
"<head>\n" +
" <meta charset=\"utf-8\">\n" +
" <link rel=\"stylesheet\" href=\"./styles/" + css + "\">\n" +
"" + (!wrap ? "<meta name=\"viewport\" content=\"width=device-width, height=device-height, " +
"initial-scale=.5,user-scalable=yes\"/>\n" : "") + "" +
LINE_NO_CSS + "\n" +
" " + (wrap ? WRAPPED_STYLE : "") + "\n" +
"<script src=\"./js/prettify.js\"></script>\n" +
"<script src=\"./js/prettify_line_number.js\"></script>\n" +
"</head>\n" +
All you have to do is insert a <style> tag with the extra css rule in there (I think between the linked style sheet and the prettify.js code makes most sense)
"<style type=\"text/css\">pre {tab-size: 2;}</style>\n" +
If my hunch about Android WebView is correct, that should make the tabs two spaces wide.
You could also set it up to allow the user to change (I personally would love that; I prefer three spaces but I don't want to inflict that as a default on others :P). That's up to k0shk0sh of course, but could be achieved by something like:
"<style type=\"text/css\">pre {tab-size:" + tabSize + ";}</style>\n" +
... where tabSize is a java integer variable holding the tab size setting. k0shk0sh would need to figure out where to store and insert those settings, and how to add it to the settings the interface; I don't know whether or not that's a lot of work so I'll refrain from commenting on that ;).
PS: while looking through the code I noticed that the version of highlight.js used is 9.10. Just so you know: the official one is at 9.12
PPS: Also, I believe you can reduce memory overhead in PrettyfyHelper.getHtmlContent by using StringBuilder to concatenate strings. Depending on how you load that input source (it is downloaded from the internet after all), you might also be able to replace the source string in the generateContent methods with a BufferedReader as well, which should reduce memory usage even more - see also this SO question for example. In that case you also should make getFormattedSource take/return a StringBuilder - see this SO question. This should reduce intermediate allocations, which I expect would make the app run better with large source files on low-end devices.
Most helpful comment
Not an android dev, sorry :)
I don't I mind helping out, it's just that getting everything up and running would take so much time, and all of that to add one line of CSS!
But I _can_ help look at where you might want to change this, is that good enough? I just skimmed the code base, and I think the change should be as follows (but again, I can't test this on my machine!)
In the
PrettyfyHelper.java file, the header is defined between between line 14 and 23:All you have to do is insert a
<style>tag with the extra css rule in there (I think between the linked style sheet and the prettify.js code makes most sense)If my hunch about Android WebView is correct, that should make the tabs two spaces wide.
You could also set it up to allow the user to change (I personally would love that; I prefer three spaces but I don't want to inflict that as a default on others :P). That's up to k0shk0sh of course, but could be achieved by something like:
... where
tabSizeis a java integer variable holding the tab size setting. k0shk0sh would need to figure out where to store and insert those settings, and how to add it to the settings the interface; I don't know whether or not that's a lot of work so I'll refrain from commenting on that ;).PS: while looking through the code I noticed that the version of
highlight.jsused is 9.10. Just so you know: the official one is at 9.12PPS: Also, I believe you can reduce memory overhead in
PrettyfyHelper.getHtmlContentby using StringBuilder to concatenate strings. Depending on how you load that input source (it is downloaded from the internet after all), you might also be able to replace thesourcestring in thegenerateContentmethods with a BufferedReader as well, which should reduce memory usage even more - see also this SO question for example. In that case you also should makegetFormattedSourcetake/return a StringBuilder - see this SO question. This should reduce intermediate allocations, which I expect would make the app run better with large source files on low-end devices.