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

[Feature] Customize format number #11

Closed
danilort opened this issue Dec 24, 2021 · 4 comments
Closed

[Feature] Customize format number #11

danilort opened this issue Dec 24, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@danilort
Copy link

Qalc 0.1.8.

I suggest some changes to the settings.

Remove this:

// Turn this on to display commas in results ($1,000,000), or off to hide commas ($1000000)
qalc.output.displayCommas": true,

and add these two:

qalc.output.decimalSymbol": "."
qalc.output.digitGroupingSymbol": ","

Like Windows 10:

immagine

Now

Now I am much more free to choose the I prefer format.

English format (like qalc.output.displayCommas": true)

qalc.output.decimalSymbol": "."
qalc.output.digitGroupingSymbol": ","

immagine

English format (like qalc.output.displayCommas": false)

qalc.output.decimalSymbol": "."
qalc.output.digitGroupingSymbol": ""    //void string

immagine

Italian format

qalc.output.decimalSymbol": ","
qalc.output.digitGroupingSymbol": "."

immagine

Other format

qalc.output.decimalSymbol": "."
qalc.output.digitGroupingSymbol": " "   //space

immagine

Thank's for your job!

@danilort
Copy link
Author

danilort commented Dec 30, 2021

How to do

package.json

"qalc.output.digitGroupingSymbol": {
    "title": "Character that groups the digits",
    "type": "string",
    "default": ".",
    "description": "Character that groups the digits"
},
"qalc.output.decimalSymbol": {
    "title": "Character separating the decimals",
    "type": "string",
    "default": ",",
    "description": "Character separating the decimals"
}

settings.js

exports.temperatureShortcut = exports.localCurrencyCode = exports.localCurrencySymbol = exports.convertLocalCurrency = exports.upperExponentBound = exports.lowerExponentBound = exports.notation = exports.precision = exports.trimTrailingZeros = exports.displayCommas = exports.enabledLanguages = exports.maxAlignmentColumn = exports.alignResults = exports.resultsColor = exports.getComputedResultsDelimiter = exports.resultsDelimiter = exports.showResultsDelimiter = exports.digitGroupingSymbol = exports.decimalSymbol = void 0; 

const SEPARA_GRUPPI_CIFRE = "qalc.output.digitGroupingSymbol";     //DG
const SEPARA_DECIMALI = "qalc.output.decimalSymbol";     //DG

……………………..

function digitGroupingSymbol() {
    return getConfiguration(SEPARA_GRUPPI_CIFRE);
}
exports.digitGroupingSymbol = digitGroupingSymbol;

function decimalSymbol() {
    return getConfiguration(SEPARA_DECIMALI);
}
exports.decimalSymbol = decimalSymbol;

document.js

digitGroupingSymbol: settings_1.digitGroupingSymbol(),   
decimalSymbol: settings_1.decimalSymbol() 

decorator.js

digitGroupingSymbol: settings_1.digitGroupingSymbol(),  
decimalSymbol: settings_1.decimalSymbol() 

formatter.js

if (formatterSettings.trimTrailingZeros) 
{
   .................
}

//replace the decimal separator with temporary characters
output = output.replace(/\./, '#');

//add the digit group separator
output = output.replace(/\B(?<!\#\d*)(?=(\d{3})+(?!\d))/g, formatterSettings.digitGroupingSymbol);

//replace the decimal separator
output = output.replace(/\#/, formatterSettings.decimalSymbol);

return output;

@nortakales nortakales added the enhancement New feature or request label Feb 17, 2022
@ml-1
Copy link

ml-1 commented Feb 11, 2024

@nortakales I'm really missing this feature.
Would this be merged if it was made into a pull request or are there any parts that needs to be rewritten?

@nortakales
Copy link
Owner

I'll look into it this week. I think it should be fairly straightforward, I just want to make sure I honor existing settings or somehow migrate them to the new settings so I don't change things unexpectedly for existing users.

@nortakales
Copy link
Owner

nortakales commented Feb 13, 2024

Added these settings in version 0.3.0. Let me know if there are any issues.

Commit: 92ad4e6

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

No branches or pull requests

3 participants