summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES57
-rw-r--r--Readme.md22
-rw-r--r--examples/csv/countries.csv257
-rw-r--r--examples/sc/transpose.sc27
-rw-r--r--src/conf.c2
-rwxr-xr-xsrc/doc22
-rw-r--r--src/file.c220
-rw-r--r--src/function.c42
-rwxr-xr-xsrc/gram.y24
-rw-r--r--src/graph.c4
-rw-r--r--src/help.c4
-rw-r--r--src/interp.c240
-rw-r--r--src/interp.h4
-rw-r--r--src/lex.c26
-rw-r--r--src/lua.c39
-rw-r--r--src/lua.h2
-rw-r--r--src/main.c21
-rw-r--r--src/sc.h4
-rw-r--r--src/sheet.c3
-rw-r--r--src/tui.c6
20 files changed, 686 insertions, 340 deletions
diff --git a/CHANGES b/CHANGES
index 2ab40a9..7f1788a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,36 @@
CHANGES FILE
+------------
-Preparing v0.8.3
+Ideas for v0.8.5
----------------
-Here are the details of this release:
++ restore transpose
++ Add is_deleted flag on sheets that are deleted. So ents have a chance to update its references to that sheet.
+Then rebuild graph.
++ arv should have priority over scimrc.
++ rethink overlap. it shows incorrectly if text does not fit in the current LINE
++ user customizable UI header (bar)
++ modify search procedure. highlight matches
++ yank.c functions should receive yanklist pointer as parameter, rather than use yanklist global variable.
+this could allow future use of registers to copy to and paste from.
++ registers for yanking
++ use yanklist for added/removed in undo?
+
+
+
+Please open a discussion on GitHub to comment on these and other feature requests.
+
+***********
+v0.8.4
+
+06/01/2023: fix issue in csv import - 816
+06/01/2023: merged PR 789
+06/01/2023: merged PR 776
+06/01/2023: merged PR 783 that gets rid of issue 778 - changed load_rc load_file order.
+06/01/2023: Fix issue 784: get row number and column or cell that calls a LUA script with PR 814.
+
+
+***********
+v0.8.3
New stuff
---------
@@ -30,8 +58,8 @@ C command in EDIT MODE
PR 725: added 'default_open_file_under_cursor_cmd' configuration value that can be set at runtime
-Changes:
---------
+Changes
+-------
+ added more detailed error in gram.y:yyerror
+ Adapt string and number search for multisheet
+ marks now considers sheet. We could have mark A in Sheet 1, and mark B on Sheet 2..
@@ -58,7 +86,6 @@ ESC in EDIT_MODE also confirm changes.
Reeval when pasting from clipboard and autocalc is set
Adjust Makefile to have logic for clipboard commands on MacOS
-
Fixes
-----
** fixed building warnings
@@ -89,26 +116,6 @@ fix #694: csv import and export / LaTex export
fix #700: '{' '}' normal mode commands reset cmd_multiplier
-Pending to make v0.8.3 release
--------------------
-Add is_deleted flag on sheets that are deleted. So ents have a chance to update its references to that sheet.
-Then rebuild graph.
-
-
-
-Ideas for v0.8.4
-----------------
-+ arv should have priority over scimrc.
-+ rethink overlap. it shows incorrectly if text does not fit in the current LINE
-+ user customizable UI header (bar)
-+ modify search procedure. highlight matches
-+ yank.c functions should receive yanklist pointer as parameter, rather than use yanklist global variable.
-this could allow future use of registers to copy to and paste from.
-+ registers for yanking
-+ use yanklist for added/removed in undo?
-
-Please open a discussion on GitHub to comment on these and other feature requests.
-
***********
v0.8.2
diff --git a/Readme.md b/Readme.md
index 8239e08..a90d899 100644
--- a/Readme.md
+++ b/Readme.md
@@ -2,6 +2,13 @@
<img src="https://raw.githubusercontent.com/andmarti1424/sc-im/dev/logo.png" alt="sc-im" height="25%" width="25%">
</h1>
+
+# NOTE 06/01/2023:
+This project needs some help.
+This is a one person project and lost sponsoring in the last months. There are only just a few left. I want to still maintain and develop sc-im, but I am the only income in my family and its becoming difficult to work as much as I would want.
+If you can make a donation (see at the bottom), please do. Your help would be really appreciated!!
+Thanks.
+
# sc-im
Spreadsheet Calculator Improvised, aka sc-im, is an ncurses based, vim-like spreadsheet calculator.
@@ -142,10 +149,21 @@ Here is an example `~/.config/sc-im/scimrc` :
Other configuration variables are listed in the [help file](https://raw.githubusercontent.com/andmarti1424/sc-im/freeze/src/doc).
+### Issues and questions
+Please open an issue if you find a bug.
+If you are now sure if its a bug, please take a look at the discussions and/or ask there.
+If you have a question please check out current discussions and if you still are in doubt, open a discussion as well.
+If you want to ask for a feature request, the same, check out current discussions.
+Thank you!
+
### Tutorial
[sc-im tutorial](https://github.com/jonnieey/Sc-im-Tutorial)
+### Related projects
+
+- [vim-scimark](https://github.com/mipmip/vim-scimark) - Vim plugin, edit embedded markdown tables with sc-im in vim terminal.
+
### Helping us
Want to help? You can help us with one or more of the following:
@@ -157,7 +175,7 @@ Want to help? You can help us with one or more of the following:
### Donations
-If you like sc-im please support its development by making a DONATION with PayPal.
+If you like sc-im please support its development by making a DONATION with Patreon or PayPal.
It would really help a lot.
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=U537V8SNQQ45J" target="_blank">
@@ -165,6 +183,6 @@ It would really help a lot.
</a>
If you wish to make a donation, please click the above button or just send money to scim.spreadsheet@gmail.com via PayPal, choosing "Goods and Services".
-Paypal is preferred over Patreon.
+or with Patreon.
Thank you!
diff --git a/examples/csv/countries.csv b/examples/csv/countries.csv
new file mode 100644
index 0000000..4a210a1
--- /dev/null
+++ b/examples/csv/countries.csv
@@ -0,0 +1,257 @@
+"Country","Alpha-2 code","Alpha-3 code","Numeric code","Latitude (average)","Longitude (average)"
+"Afghanistan", "AF", "AFG", "4", "33", "65"
+"Albania", "AL", "ALB", "8", "41", "20"
+"Algeria", "DZ", "DZA", "12", "28", "3"
+"American Samoa", "AS", "ASM", "16", "-14.3333", "-170"
+"Andorra", "AD", "AND", "20", "42.5", "1.6"
+"Angola", "AO", "AGO", "24", "-12.5", "18.5"
+"Anguilla", "AI", "AIA", "660", "18.25", "-63.1667"
+"Antarctica", "AQ", "ATA", "10", "-90", "0"
+"Antigua and Barbuda", "AG", "ATG", "28", "17.05", "-61.8"
+"Argentina", "AR", "ARG", "32", "-34", "-64"
+"Armenia", "AM", "ARM", "51", "40", "45"
+"Aruba", "AW", "ABW", "533", "12.5", "-69.9667"
+"Australia", "AU", "AUS", "36", "-27", "133"
+"Austria", "AT", "AUT", "40", "47.3333", "13.3333"
+"Azerbaijan", "AZ", "AZE", "31", "40.5", "47.5"
+"Bahamas", "BS", "BHS", "44", "24.25", "-76"
+"Bahrain", "BH", "BHR", "48", "26", "50.55"
+"Bangladesh", "BD", "BGD", "50", "24", "90"
+"Barbados", "BB", "BRB", "52", "13.1667", "-59.5333"
+"Belarus", "BY", "BLR", "112", "53", "28"
+"Belgium", "BE", "BEL", "56", "50.8333", "4"
+"Belize", "BZ", "BLZ", "84", "17.25", "-88.75"
+"Benin", "BJ", "BEN", "204", "9.5", "2.25"
+"Bermuda", "BM", "BMU", "60", "32.3333", "-64.75"
+"Bhutan", "BT", "BTN", "64", "27.5", "90.5"
+"Bolivia, Plurinational State of", "BO", "BOL", "68", "-17", "-65"
+"Bolivia", "BO", "BOL", "68", "-17", "-65"
+"Bosnia and Herzegovina", "BA", "BIH", "70", "44", "18"
+"Botswana", "BW", "BWA", "72", "-22", "24"
+"Bouvet Island", "BV", "BVT", "74", "-54.4333", "3.4"
+"Brazil", "BR", "BRA", "76", "-10", "-55"
+"British Indian Ocean Territory", "IO", "IOT", "86", "-6", "71.5"
+"Brunei Darussalam", "BN", "BRN", "96", "4.5", "114.6667"
+"Brunei", "BN", "BRN", "96", "4.5", "114.6667"
+"Bulgaria", "BG", "BGR", "100", "43", "25"
+"Burkina Faso", "BF", "BFA", "854", "13", "-2"
+"Burundi", "BI", "BDI", "108", "-3.5", "30"
+"Cambodia", "KH", "KHM", "116", "13", "105"
+"Cameroon", "CM", "CMR", "120", "6", "12"
+"Canada", "CA", "CAN", "124", "60", "-95"
+"Cape Verde", "CV", "CPV", "132", "16", "-24"
+"Cayman Islands", "KY", "CYM", "136", "19.5", "-80.5"
+"Central African Republic", "CF", "CAF", "140", "7", "21"
+"Chad", "TD", "TCD", "148", "15", "19"
+"Chile", "CL", "CHL", "152", "-30", "-71"
+"China", "CN", "CHN", "156", "35", "105"
+"Christmas Island", "CX", "CXR", "162", "-10.5", "105.6667"
+"Cocos (Keeling) Islands", "CC", "CCK", "166", "-12.5", "96.8333"
+"Colombia", "CO", "COL", "170", "4", "-72"
+"Comoros", "KM", "COM", "174", "-12.1667", "44.25"
+"Congo", "CG", "COG", "178", "-1", "15"
+"Congo, the Democratic Republic of the", "CD", "COD", "180", "0", "25"
+"Cook Islands", "CK", "COK", "184", "-21.2333", "-159.7667"
+"Costa Rica", "CR", "CRI", "188", "10", "-84"
+"Côte d'Ivoire", "CI", "CIV", "384", "8", "-5"
+"Ivory Coast", "CI", "CIV", "384", "8", "-5"
+"Croatia", "HR", "HRV", "191", "45.1667", "15.5"
+"Cuba", "CU", "CUB", "192", "21.5", "-80"
+"Cyprus", "CY", "CYP", "196", "35", "33"
+"Czech Republic", "CZ", "CZE", "203", "49.75", "15.5"
+"Denmark", "DK", "DNK", "208", "56", "10"
+"Djibouti", "DJ", "DJI", "262", "11.5", "43"
+"Dominica", "DM", "DMA", "212", "15.4167", "-61.3333"
+"Dominican Republic", "DO", "DOM", "214", "19", "-70.6667"
+"Ecuador", "EC", "ECU", "218", "-2", "-77.5"
+"Egypt", "EG", "EGY", "818", "27", "30"
+"El Salvador", "SV", "SLV", "222", "13.8333", "-88.9167"
+"Equatorial Guinea", "GQ", "GNQ", "226", "2", "10"
+"Eritrea", "ER", "ERI", "232", "15", "39"
+"Estonia", "EE", "EST", "233", "59", "26"
+"Ethiopia", "ET", "ETH", "231", "8", "38"
+"Falkland Islands (Malvinas)", "FK", "FLK", "238", "-51.75", "-59"
+"Faroe Islands", "FO", "FRO", "234", "62", "-7"
+"Fiji", "FJ", "FJI", "242", "-18", "175"
+"Finland", "FI", "FIN", "246", "64", "26"
+"France", "FR", "FRA", "250", "46", "2"
+"French Guiana", "GF", "GUF", "254", "4", "-53"
+"French Polynesia", "PF", "PYF", "258", "-15", "-140"
+"French Southern Territories", "TF", "ATF", "260", "-43", "67"
+"Gabon", "GA", "GAB", "266", "-1", "11.75"
+"Gambia", "GM", "GMB", "270", "13.4667", "-16.5667"
+"Georgia", "GE", "GEO", "268", "42", "43.5"
+"Germany", "DE", "DEU", "276", "51", "9"
+"Ghana", "GH", "GHA", "288", "8", "-2"
+"Gibraltar", "GI", "GIB", "292", "36.1833", "-5.3667"
+"Greece", "GR", "GRC", "300", "39", "22"
+"Greenland", "GL", "GRL", "304", "72", "-40"
+"Grenada", "GD", "GRD", "308", "12.1167", "-61.6667"
+"Guadeloupe", "GP", "GLP", "312", "16.25", "-61.5833"
+"Guam", "GU", "GUM", "316", "13.4667", "144.7833"
+"Guatemala", "GT", "GTM", "320", "15.5", "-90.25"
+"Guernsey", "GG", "GGY", "831", "49.5", "-2.56"
+"Guinea", "GN", "GIN", "324", "11", "-10"
+"Guinea-Bissau", "GW", "GNB", "624", "12", "-15"
+"Guyana", "GY", "GUY", "328", "5", "-59"
+"Haiti", "HT", "HTI", "332", "19", "-72.4167"
+"Heard Island and McDonald Islands", "HM", "HMD", "334", "-53.1", "72.5167"
+"Holy See (Vatican City State)", "VA", "VAT", "336", "41.9", "12.45"
+"Honduras", "HN", "HND", "340", "15", "-86.5"
+"Hong Kong", "HK", "HKG", "344", "22.25", "114.1667"
+"Hungary", "HU", "HUN", "348", "47", "20"
+"Iceland", "IS", "ISL", "352", "65", "-18"
+"India", "IN", "IND", "356", "20", "77"
+"Indonesia", "ID", "IDN", "360", "-5", "120"
+"Iran, Islamic Republic of", "IR", "IRN", "364", "32", "53"
+"Iraq", "IQ", "IRQ", "368", "33", "44"
+"Ireland", "IE", "IRL", "372", "53", "-8"
+"Isle of Man", "IM", "IMN", "833", "54.23", "-4.55"
+"Israel", "IL", "ISR", "376", "31.5", "34.75"
+"Italy", "IT", "ITA", "380", "42.8333", "12.8333"
+"Jamaica", "JM", "JAM", "388", "18.25", "-77.5"
+"Japan", "JP", "JPN", "392", "36", "138"
+"Jersey", "JE", "JEY", "832", "49.21", "-2.13"
+"Jordan", "JO", "JOR", "400", "31", "36"
+"Kazakhstan", "KZ", "KAZ", "398", "48", "68"
+"Kenya", "KE", "KEN", "404", "1", "38"
+"Kiribati", "KI", "KIR", "296", "1.4167", "173"
+"Korea, Democratic People's Republic of", "KP", "PRK", "408", "40", "127"
+"Korea, Republic of", "KR", "KOR", "410", "37", "127.5"
+"South Korea", "KR", "KOR", "410", "37", "127.5"
+"Kuwait", "KW", "KWT", "414", "29.3375", "47.6581"
+"Kyrgyzstan", "KG", "KGZ", "417", "41", "75"
+"Lao People's Democratic Republic", "LA", "LAO", "418", "18", "105"
+"Latvia", "LV", "LVA", "428", "57", "25"
+"Lebanon", "LB", "LBN", "422", "33.8333", "35.8333"
+"Lesotho", "LS", "LSO", "426", "-29.5", "28.5"
+"Liberia", "LR", "LBR", "430", "6.5", "-9.5"
+"Libyan Arab Jamahiriya", "LY", "LBY", "434", "25", "17"
+"Libya", "LY", "LBY", "434", "25", "17"
+"Liechtenstein", "LI", "LIE", "438", "47.1667", "9.5333"
+"Lithuania", "LT", "LTU", "440", "56", "24"
+"Luxembourg", "LU", "LUX", "442", "49.75", "6.1667"
+"Macao", "MO", "MAC", "446", "22.1667", "113.55"
+"Macedonia, the former Yugoslav Republic of", "MK", "MKD", "807", "41.8333", "22"
+"Madagascar", "MG", "MDG", "450", "-20", "47"
+"Malawi", "MW", "MWI", "454", "-13.5", "34"
+"Malaysia", "MY", "MYS", "458", "2.5", "112.5"
+"Maldives", "MV", "MDV", "462", "3.25", "73"
+"Mali", "ML", "MLI", "466", "17", "-4"
+"Malta", "MT", "MLT", "470", "35.8333", "14.5833"
+"Marshall Islands", "MH", "MHL", "584", "9", "168"
+"Martinique", "MQ", "MTQ", "474", "14.6667", "-61"
+"Mauritania", "MR", "MRT", "478", "20", "-12"
+"Mauritius", "MU", "MUS", "480", "-20.2833", "57.55"
+"Mayotte", "YT", "MYT", "175", "-12.8333", "45.1667"
+"Mexico", "MX", "MEX", "484", "23", "-102"
+"Micronesia, Federated States of", "FM", "FSM", "583", "6.9167", "158.25"
+"Moldova, Republic of", "MD", "MDA", "498", "47", "29"
+"Monaco", "MC", "MCO", "492", "43.7333", "7.4"
+"Mongolia", "MN", "MNG", "496", "46", "105"
+"Montenegro", "ME", "MNE", "499", "42", "19"
+"Montserrat", "MS", "MSR", "500", "16.75", "-62.2"
+"Morocco", "MA", "MAR", "504", "32", "-5"
+"Mozambique", "MZ", "MOZ", "508", "-18.25", "35"
+"Myanmar", "MM", "MMR", "104", "22", "98"
+"Burma", "MM", "MMR", "104", "22", "98"
+"Namibia", "NA", "NAM", "516", "-22", "17"
+"Nauru", "NR", "NRU", "520", "-0.5333", "166.9167"
+"Nepal", "NP", "NPL", "524", "28", "84"
+"Netherlands", "NL", "NLD", "528", "52.5", "5.75"
+"Netherlands Antilles", "AN", "ANT", "530", "12.25", "-68.75"
+"New Caledonia", "NC", "NCL", "540", "-21.5", "165.5"
+"New Zealand", "NZ", "NZL", "554", "-41", "174"
+"Nicaragua", "NI", "NIC", "558", "13", "-85"
+"Niger", "NE", "NER", "562", "16", "8"
+"Nigeria", "NG", "NGA", "566", "10", "8"
+"Niue", "NU", "NIU", "570", "-19.0333", "-169.8667"
+"Norfolk Island", "NF", "NFK", "574", "-29.0333", "167.95"
+"Northern Mariana Islands", "MP", "MNP", "580", "15.2", "145.75"
+"Norway", "NO", "NOR", "578", "62", "10"
+"Oman", "OM", "OMN", "512", "21", "57"
+"Pakistan", "PK", "PAK", "586", "30", "70"
+"Palau", "PW", "PLW", "585", "7.5", "134.5"
+"Palestinian Territory, Occupied", "PS", "PSE", "275", "32", "35.25"
+"Panama", "PA", "PAN", "591", "9", "-80"
+"Papua New Guinea", "PG", "PNG", "598", "-6", "147"
+"Paraguay", "PY", "PRY", "600", "-23", "-58"
+"Peru", "PE", "PER", "604", "-10", "-76"
+"Philippines", "PH", "PHL", "608", "13", "122"
+"Pitcairn", "PN", "PCN", "612", "-24.7", "-127.4"
+"Poland", "PL", "POL", "616", "52", "20"
+"Portugal", "PT", "PRT", "620", "39.5", "-8"
+"Puerto Rico", "PR", "PRI", "630", "18.25", "-66.5"
+"Qatar", "QA", "QAT", "634", "25.5", "51.25"
+"Réunion", "RE", "REU", "638", "-21.1", "55.6"
+"Romania", "RO", "ROU", "642", "46", "25"
+"Russian Federation", "RU", "RUS", "643", "60", "100"
+"Russia", "RU", "RUS", "643", "60", "100"
+"Rwanda", "RW", "RWA", "646", "-2", "30"
+"Saint Helena, Ascension and Tristan da Cunha", "SH", "SHN", "654", "-15.9333", "-5.7"
+"Saint Kitts and Nevis", "KN", "KNA", "659", "17.3333", "-62.75"
+"Saint Lucia", "LC", "LCA", "662", "13.8833", "-61.1333"
+"Saint Pierre and Miquelon", "PM", "SPM", "666", "46.8333", "-56.3333"
+"Saint Vincent and the Grenadines", "VC", "VCT", "670", "13.25", "-61.2"
+"Saint Vincent & the Grenadines", "VC", "VCT", "670", "13.25", "-61.2"
+"St. Vincent and the Grenadines", "VC", "VCT", "670", "13.25", "-61.2"
+"Samoa", "WS", "WSM", "882", "-13.5833", "-172.3333"
+"San Marino", "SM", "SMR", "674", "43.7667", "12.4167"
+"Sao Tome and Principe", "ST", "STP", "678", "1", "7"
+"Saudi Arabia", "SA", "SAU", "682", "25", "45"
+"Senegal", "SN", "SEN", "686", "14", "-14"
+"Serbia", "RS", "SRB", "688", "44", "21"
+"Seychelles", "SC", "SYC", "690", "-4.5833", "55.6667"
+"Sierra Leone", "SL", "SLE", "694", "8.5", "-11.5"
+"Singapore", "SG", "SGP", "702", "1.3667", "103.8"
+"Slovakia", "SK", "SVK", "703", "48.6667", "19.5"
+"Slovenia", "SI", "SVN", "705", "46", "15"
+"Solomon Islands", "SB", "SLB", "90", "-8", "159"
+"Somalia", "SO", "SOM", "706", "10", "49"
+"South Africa", "ZA", "ZAF", "710", "-29", "24"
+"South Georgia and the South Sandwich Islands", "GS", "SGS", "239", "-54.5", "-37"
+"South Sudan", "SS", "SSD", "728", "8", "30"
+"Spain", "ES", "ESP", "724", "40", "-4"
+"Sri Lanka", "LK", "LKA", "144", "7", "81"
+"Sudan", "SD", "SDN", "736", "15", "30"
+"Suriname", "SR", "SUR", "740", "4", "-56"
+"Svalbard and Jan Mayen", "SJ", "SJM", "744", "78", "20"
+"Swaziland", "SZ", "SWZ", "748", "-26.5", "31.5"
+"Sweden", "SE", "SWE", "752", "62", "15"
+"Switzerland", "CH", "CHE", "756", "47", "8"
+"Syrian Arab Republic", "SY", "SYR", "760", "35", "38"
+"Taiwan, Province of China", "TW", "TWN", "158", "23.5", "121"
+"Taiwan", "TW", "TWN", "158", "23.5", "121"
+"Tajikistan", "TJ", "TJK", "762", "39", "71"
+"Tanzania, United Republic of", "TZ", "TZA", "834", "-6", "35"
+"Thailand", "TH", "THA", "764", "15", "100"
+"Timor-Leste", "TL", "TLS", "626", "-8.55", "125.5167"
+"Togo", "TG", "TGO", "768", "8", "1.1667"
+"Tokelau", "TK", "TKL", "772", "-9", "-172"
+"Tonga", "TO", "TON", "776", "-20", "-175"
+"Trinidad and Tobago", "TT", "TTO", "780", "11", "-61"
+"Tunisia", "TN", "TUN", "788", "34", "9"
+"Turkey", "TR", "TUR", "792", "39", "35"
+"Turkmenistan", "TM", "TKM", "795", "40", "60"
+"Turks and Caicos Islands", "TC", "TCA", "796", "21.75", "-71.5833"
+"Tuvalu", "TV", "TUV", "798", "-8", "178"
+"Uganda", "UG", "UGA", "800", "1", "32"
+"Ukraine", "UA", "UKR", "804", "49", "32"
+"United Arab Emirates", "AE", "ARE", "784", "24", "54"
+"United Kingdom", "GB", "GBR", "826", "54", "-2"
+"United States", "US", "USA", "840", "38", "-97"
+"United States Minor Outlying Islands", "UM", "UMI", "581", "19.2833", "166.6"
+"Uruguay", "UY", "URY", "858", "-33", "-56"
+"Uzbekistan", "UZ", "UZB", "860", "41", "64"
+"Vanuatu", "VU", "VUT", "548", "-16", "167"
+"Venezuela, Bolivarian Republic of", "VE", "VEN", "862", "8", "-66"
+"Venezuela", "VE", "VEN", "862", "8", "-66"
+"Viet Nam", "VN", "VNM", "704", "16", "106"
+"Vietnam", "VN", "VNM", "704", "16", "106"
+"Virgin Islands, British", "VG", "VGB", "92", "18.5", "-64.5"
+"Virgin Islands, U.S.", "VI", "VIR", "850", "18.3333", "-64.8333"
+"Wallis and Futuna", "WF", "WLF", "876", "-13.3", "-176.2"
+"Western Sahara", "EH", "ESH", "732", "24.5", "-13"
+"Yemen", "YE", "YEM", "887", "15", "48"
+"Zambia", "ZM", "ZMB", "894", "-15", "30"
+"Zimbabwe", "ZW", "ZWE", "716", "-20", "30" \ No newline at end of file
diff --git a/examples/sc/transpose.sc b/examples/sc/transpose.sc
new file mode 100644
index 0000000..219050d
--- /dev/null
+++ b/examples/sc/transpose.sc
@@ -0,0 +1,27 @@
+# This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
+# You almost certainly shouldn't edit it.
+
+newsheet "Sheet1"
+movetosheet "Sheet1"
+offscr_sc_cols 0
+offscr_sc_rows 0
+nb_frozen_rows 0
+nb_frozen_cols 0
+nb_frozen_screenrows 0
+nb_frozen_screencols 0
+let A0 = 9-H0
+let B0 = 4
+let D0 = 9
+let E0 = 8
+let F0 = 7
+let H0 = 8
+let A1 = 2
+let B1 = 5
+let D1 = 6
+let E1 = 5
+let F1 = 4
+let A2 = 3
+let B2 = 6
+label B4 = "algo"
+goto B4
+movetosheet "Sheet1"
diff --git a/src/conf.c b/src/conf.c
index 2497fd4..6a0ea39 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -63,7 +63,7 @@ const char default_config[] =
"external_functions=0\n"
"exec_lua=1\n"
"xlsx_readformulas=0\n"
- "import_delimited_as_text=0\n"
+ "import_delimited_to_text=0\n"
"ignore_hidden=0\n"
"quit_afterload=0\n"
"quiet=0\n"
diff --git a/src/doc b/src/doc
index fc885ed..d10f501 100755
--- a/src/doc
+++ b/src/doc
@@ -414,7 +414,7 @@ Commands for handling cell content:
file (.md, mkd, .markdown), an xlsx or xls file.
If loading a csv, tab or tsv file and
- 'import_delimited_as_text' configuration variable is set
+ 'import_delimited_to_text' configuration variable is set
Sc-im will import numbers as text.
If loading an xlsx file and 'xlsx_readformulas' is set, Sc-im
@@ -1682,14 +1682,20 @@ Commands for handling cell content:
Executes a "luascript". Using Lua script, sc-im can be extend with lot
new functionality, such as complex programming, accessing databases
etc.
+
+ Two global variables {r} and {c} are injected in the "luascript". The
+ variables denote the row and column of the calling cell respectively.
+
The second parameter {i} is 0 or 1 indicating if the reference to this
- cell should be added to the formula evaluation graph.
- Setting it to 0 may be a good idea if you call sc.lquery to often in
- your scripts.
+ cell should be added to the formula evaluation graph. Setting it to 0
+ may be a good idea if you call sc.lquery to often in your scripts.
However, in the cases were its not added to the dependency graph, it
will nevertheless be executed when the cell that calls the script
executions is referenced by another cell.
+ The return of value of the "luascript" is inserted in the calling
+ cell if it is a string.
+
The search patch for LUA scripts files is $PWD/lua/
$HOME/.sc-im/lua/ or /usr/local/share/sc-im/lua (in that order)
@@ -1786,6 +1792,12 @@ Commands for handling cell content:
==============================================================================
&Other functions&
+ @myrow
+ references current row
+
+ @mycol
+ references current column
+
@if({expr}, {expr}, {expr})
Conditional: If the first expression is true then the value of
the second is returned, otherwise the value of the third.
@@ -1936,7 +1948,7 @@ Commands for handling cell content:
'LET A0=1' is the same as 'let A0=1'
Almost every interactive sc-im command is available for non-interactive
- scripting. Search the equivelent interactive commands for usage
+ scripting. Search the equivalent interactive commands for usage
information.
sc-im has these commands for available for external scripts.
diff --git a/src/file.c b/src/file.c
index ae07ada..85054b6 100644
--- a/src/file.c
+++ b/src/file.c
@@ -515,7 +515,7 @@ void write_fd(FILE * f, struct roman * doc) {
sprintf(strcolor, " fg=%.*s", BUFFERSIZE-5, &line[0]);
free(e);
} else if ((cc = get_custom_color_by_number((*pp)->ucolor->fg - 7)) != NULL) {
- sprintf(strcolor, " fg=%.*s", BUFFERSIZE-5, cc->name);
+ sprintf(strcolor, " fg=%.*s", BUFFERSIZE, cc->name);
}
}
@@ -526,10 +526,10 @@ void write_fd(FILE * f, struct roman * doc) {
decompile(e, 0);
uppercase(line);
del_char(line, 0);
- snprintf(strcolor + strlen(strcolor), strlen(line)+5, " bg=%s", &line[0]);
+ sprintf(strcolor + strlen(strcolor), " bg=%s", &line[0]);
free(e);
} else if ((cc = get_custom_color_by_number((*pp)->ucolor->bg - 7)) != NULL) {
- sprintf(strcolor + strlen(strcolor), " bg=%.*s", BUFFERSIZE-5, cc->name);
+ sprintf(strcolor + strlen(strcolor), " bg=%.*s", BUFFERSIZE, cc->name);
}
}
@@ -625,9 +625,6 @@ void write_fd(FILE * f, struct roman * doc) {
sh = sh->next;
}
- // save movetosheet in sc file
- if (doc->cur_sh != NULL) fprintf (f, "movetosheet \"%s\"\n", doc->cur_sh->name);
-
// write marks of document
write_marks(f);
@@ -1100,8 +1097,10 @@ int import_csv(char * fname, char d) {
int r = 0, c = 0, cf = 0;
wchar_t line_interp[FBUFLEN] = L"";
char * token;
- char * next;
- int eol = 0;
+
+ int quote = 0; // if value has '"'. ex: 12,"1234,450.00",56
+ char delim[2] = ""; //strtok receives a char *, not a char
+ add_char(delim, d, 0);
if ((f = fopen(fname , "r")) == NULL) {
sc_error("Can't read file \"%s\"", fname);
@@ -1123,10 +1122,14 @@ int import_csv(char * fname, char d) {
int i=0;
+ // handle ","
+ char lookf[4], repls[2], replb[2];
+ sprintf(lookf, "\"%c\"", d);
+ sprintf(repls, "%c", 6);
+ sprintf(replb, "%c", d);
+
// CSV file traversing
while ( ! feof(f) && (fgets(line_in, sizeof(line_in), f) != NULL) ) {
- eol = 0;
-
// show file loading progress
if (++i % 10 == 0 ) sc_info("loading line %d of %d", i, max_lines);
@@ -1138,46 +1141,59 @@ int import_csv(char * fname, char d) {
break;
}
- next = line_in;
+ //char * str_rep = str_replace(line_in, lookf, repls); // handle "," case
+ //strcpy(line_in, str_rep);
+ //free(str_rep);
+ // Split string using the delimiter
+ token = xstrtok(line_in, delim);
c = 0;
- while( !eol ) {
+ while( token != NULL ) {
if (r > MAXROWS - GROWAMT - 1 || c > ABSMAXCOLS - 1) break;
+ clean_carrier(token);
+ if ( token[0] == '\"' && token[strlen(token)-1] == '\"') {
+ quote = 1;
- // Split string using the delimiter
- token = next;
- next += next_unquot_delim(token, d);
- if (*next == '\0')
- eol = 1;
- else {
- *next = '\0';
- next++;
- }
+ // to handle # 816
+ } else if (( token[0] == '\"' || (token[0] == ' ' && token[1] == '\"')) && token[strlen(token)-1] == '\"') {
+ quote = 1;
- clean_carrier(token);
+ } else if ( (token[0] == '\"' || quote) && strlen(token) && (token[strlen(token)-1] != '\"' || strlen(token) == 1) ) {
+ quote = 1;
+ char * next = xstrtok(NULL, delim);
- // remove quotes
- if ( token[0] == '\"' && token[strlen(token)-1] == '\"') {
- token[strlen(token)-1] = '\0';
- token++;
+ if (next != NULL) {
+ sprintf(token + strlen(token), "%c%s", d, next);
+ continue;
+ }
}
+ if (quote) { // Remove quotes
+ del_char(token, 0);
+ del_char(token, strlen(token)-1);
+ if (token[0]=='\"') del_char(token, 0); // to handle # 816
+ }
+
+ char * st = str_replace (token, repls, replb); // handle "," case
// number import
- if (strlen(token) && isnumeric(token) && ! get_conf_int("import_delimited_as_text")
+ if (strlen(st) && isnumeric(st) && ! get_conf_int("import_delimited_as_text")
) {
//wide char
- swprintf(line_interp, BUFFERSIZE, L"let %s%d=%s", coltoa(c), r, token);
+ swprintf(line_interp, BUFFERSIZE, L"let %s%d=%s", coltoa(c), r, st);
// text import
- } else if (strlen(token)){
+ } else if (strlen(st)){
//wide char
- swprintf(line_interp, BUFFERSIZE, L"label %s%d=\"%s\"", coltoa(c), r, token);
+ swprintf(line_interp, BUFFERSIZE, L"label %s%d=\"%s\"", coltoa(c), r, st);
}
//wide char
- if (strlen(token)) send_to_interp(line_interp);
+ if (strlen(st)) send_to_interp(line_interp);
if (++c > cf) cf = c;
+ quote = 0;
+ token = xstrtok(NULL, delim);
+ free(st);
}
r++;
@@ -1196,34 +1212,6 @@ int import_csv(char * fname, char d) {
/**
- * \brief find next unquoted delimiter
- * \details Helper function to import_csv(). Returns the
- * relative position of the next delimiter character that
- * is not quoted with double-quotes (").
- * \param[in] start where we are in the line
- * \param[in] d the delimiter character
- * \return number of characters to move from start to next
- * delimiter or EOL
- */
-int next_unquot_delim(char *start, char d) {
- int quote = 0;
- char *p = start;
- int count = 0;
-
- while(1) {
- if (*p == '\0')
- return count;
- if (*p == d && !quote)
- return count;
- if (*p == '\"')
- quote = !quote;
- count++;
- p++;
- }
-}
-
-
-/**
* \brief Import Markdown to sc
* \param[in] fname file name
* \param[in] d
@@ -1514,13 +1502,11 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
int dash_num;
int rowfmt;
- int ignore_hidden = get_conf_int("ignore_hidden");
-
for (row = r0; row <= rn; row++) {
for (rowfmt=0; rowfmt < roman->cur_sh->row_format[row]; rowfmt++) {
// ignore hidden rows
- if (ignore_hidden && roman->cur_sh->row_hidden[row]) continue;
+ //if (row_hidden[row]) continue;
for (pp = ATBL(roman->cur_sh, roman->cur_sh->tbl, row, col = c0); col <= cn; col++, pp++) {
// ignore hidden cols
@@ -1532,24 +1518,6 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
(void) fprintf (f, " | ");
}
- //make header border of dashes with alignment characters
- if (row == 0) {
- if (col == c0) strcat (dashline, "|");
- if (align == 0) {
- strcat (dashline, ":");
- } else {
- strcat (dashline, "-");
- }
- for (dash_num = 0; dash_num < roman->cur_sh->fwidth[col]; dash_num++) {
- strcat (dashline, "-");
- }
- if(align >= 0) {
- strcat (dashline, ":");
- } else {
- strcat (dashline, "-");
- }
- strcat (dashline, "|");
- }
if (*pp) {
num [0] = '\0';
@@ -1584,7 +1552,6 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
}
}
-
pad_and_align (text, num, roman->cur_sh->fwidth[col], align, 0, out, roman->cur_sh->row_format[row]);
wchar_t new[wcslen(out)+1];
@@ -1610,6 +1577,27 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
} else {
fprintf (f, "%*s", roman->cur_sh->fwidth[col], " ");
}
+
+ // Make header border of dashes with alignment characters
+ // Column alignment is bases on cell alignments of first row
+ if (row == 0) {
+ if (col == c0) strcat (dashline, "|");
+ if (align == 0) {
+ strcat (dashline, ":");
+ } else {
+ strcat (dashline, "-");
+ }
+ for (dash_num = 0; dash_num < roman->cur_sh->fwidth[col]; dash_num++) {
+ strcat (dashline, "-");
+ }
+ if(align >= 0) {
+ strcat (dashline, ":");
+ } else {
+ strcat (dashline, "-");
+ }
+ strcat (dashline, "|");
+ }
+
}
fprintf(f," |\n");
}
@@ -1666,13 +1654,11 @@ void export_plain(char * fname, int r0, int c0, int rn, int cn) {
int align = 1;
int rowfmt;
- int ignore_hidden = get_conf_int("ignore_hidden");
-
for (row = r0; row <= rn; row++) {
for (rowfmt = 0; rowfmt < roman->cur_sh->row_format[row]; rowfmt++) {
// ignore hidden rows
- if (ignore_hidden && roman->cur_sh->row_hidden[row]) continue;
+ //if (row_hidden[row]) continue;
for (pp = ATBL(roman->cur_sh, roman->cur_sh->tbl, row, col = c0); col <= cn; col++, pp++) {
// ignore hidden cols
@@ -1827,40 +1813,32 @@ void export_latex(char * fname, int r0, int c0, int rn, int cn, int verbose) {
/**
- * \brief escape special characters and output cell to file
+ * \brief unspecial()
*
- * \details For the export formats delimiter-separated value
- * and LaTex. Escapes the special characters in one cell value
- * and appends the cell to the file.
+ * \details Unspecial (backquotes - > ") things that are special
+ * chars in a table
*
* \param[in] f file pointer
- * \param[in] str string pointer
+ * \param[in] srt string pointer
* \param[in] delim
*
* \return none
*/
void unspecial(FILE * f, char * str, int delim) {
int backquote = 0;
- if (strchr(str, delim) != NULL) backquote = 1;
+ if (str_in_str(str, ",") != -1) backquote = 1;
+ if (backquote) putc('\"', f);
if (*str == '\\') str++; // delete wheeling string operator, OK?
-
- if (delim == '&') { // the export format is LaTex
- while (*str) {
- if ( (*str == '&') || (*str == '$') || (*str == '#') ||
-