https://tinyfiledialogs.sourceforge.net Hi, I am the author of tinyfiledialogs a cross-platform C C++ library (windows, Mac, Unix) which offers many modal dialogs and popup notifications (both for graphic and console modes). It aims to be extremely easy to use. There is no init, no main loop, and no external dependencies. It is used by hundreds projects on GitHub. The following github call returns almost 15000 files (you need to be logged on github) https://github.com/search?q=tinyfd+OR+tinyfiledialogs&type=code With the latest version v3.14, I've just released the bindings for R. I've been pointed to the documentation link on how to write a package, but it would really help if someone who knows what to do could direct me. Thanks in advance Guillaume Vareille ??? # first load the included library (it could easily be compiled on the target machine) ??? dyn.load("tinyfiledialogsLinux64.so") ??? # then load the included R interface ??? tinyfd_openFileDialog <- function(aTitle, aDefaultPathAndFile , aNumOfFilterPatterns, ??? ??? ??? ??? aFilterPatterns, aSingleFilterDescription , aAllowMultipleSelects) ??? { ?? ?? result <- .C("tfd_openFileDialog", ?? ???????? charToRaw(aTitle), ??? ?? ? ?? lOpenFile = aDefaultPathAndFile , ??????? ??? as.integer(aNumOfFilterPatterns) , ??????? ??? aFilterPatterns , ??????? ??? charToRaw(aSingleFilterDescription) , ??????? ??? as.integer(aAllowMultipleSelects) ) ?? ?? if ( result$lOpenFile == "NULL" ) return() ?? ?? else return(result$lOpenFile) ??? } ??? # now, you can call the dialog ??? lFilename <- tinyfd_openFileDialog( "a title" , "/Users/bardos/Documents/" , 1 , c ("*.txt","*.jpg") , "some files" , 0 )
[R-pkg-devel] tinyfiledialogs - The bindings are ready, but I need help to make of package of it
4 messages · ti@yiiiedi@iogs m@iii@g oii yse@gri@@com, Ivan Krylov, Brad Eck
Dear Guillaume Vareille, ? Wed, 20 Sep 2023 12:30:53 +0200 tinyfiledialogs at ysengrin.com ?????:
I've been pointed to the documentation link on how to write a package, but it would really help if someone who knows what to do could direct me.
There's potentially a lot to tell. Converting the entire Writing R Extensions [*] into e-mails is a poor use of one's time. Do you have more specific questions? If you don't know where to start, try utils::package.skeleton or the pkgKitten package (which aims to pass R CMD check right from the start). There's also books like R Packages by Hadley Wickham and Jennifer Bryan, but they mention a lot of techniques and third-party dependencies that you don't have to use.
??? # first load the included library (it could easily be compiled
on the target machine)
??? dyn.load("tinyfiledialogsLinux64.so")
You will need to put your source files into the src/ subdirectory of the package and arrange for them to get compiled (see WRE 1.1.5 and 1.2.1). It's best to write a special entry point in order to let R know about the functions you intend to call (see WRE 5.4). Does your code have third-party dependencies? If you'd like to put the package on CRAN, you will need to bundle your own code with the package (since it's probably not available yet in major GNU/Linux distributions, macOS recipes and MXE) but set up a ./configure script to locate the third-party dependencies while the package is being installed: https://cran.r-project.org/web/packages/external_libs.html
?? ?? result <- .C("tfd_openFileDialog",
?? ???????? charToRaw(aTitle),
In R, strings have encodings. A string can be stored in UTF-8, Latin-1,
the native locale encoding (which may include anything from
Windows-936 to KOI8-R) or even as arbitrary bytes, which admittedly
makes it less of a string (see ?Encoding).
x1 <- `Encoding<-`('fran\xe7ais', 'latin1')
x2 <- `Encoding<-`('fran\xc3\xa7ais', 'UTF-8')
x1 == x2 # TRUE, they encode the same characters
identical(charToRaw(x1), charToRaw(x2)) # not even the same length
Which encoding does tfd_openFileDialog() use for the file names and
paths? Does it work with UCRT on Windows in UTF-8 locale mode? (Can you
return a filename that is not representable in the ANSI codepage?) You
will probably need to convert the strings into a certain encoding before
passing them to tfd_openFileDialog(...) (e.g. enc2utf8(.)).
?? ?? if ( result$lOpenFile == "NULL" ) return()
What happens if I create a file named NULL on my system and try to open it? Good luck, and I hope that your effort results in a good R package!
Best regards, Ivan [*] https://cran.r-project.org/doc/manuals/R-exts.html
Hi, There are no dependencies and everything is considered/treated as UTF-8. On windows, I internally do all the conversions between UTF-8 and UTF-16. I also offer functions to convert between UTF-8 , UTF-16 and MBCS. I don't know what UCRT is, but tinyfiledialogs is compatible with all versions of windows from XP to 11, all the versions of mac since osx 10.2 and all the unix versions I have ever came accross. I was hoping to find a tldr version of the "how to write an extension". The source code is just one C file (+ header) and one R file for the interface. What files are supposed to be in my package ? the C file or the compiled shared libraries ? What else ? a documentation file ? is there a model to follow ? thanks for your help guillaume
On 9/21/23 11:33, Ivan Krylov wrote:
Dear Guillaume Vareille, ? Wed, 20 Sep 2023 12:30:53 +0200 tinyfiledialogs at ysengrin.com ?????:
I've been pointed to the documentation link on how to write a package, but it would really help if someone who knows what to do could direct me.
There's potentially a lot to tell. Converting the entire Writing R Extensions [*] into e-mails is a poor use of one's time. Do you have more specific questions? If you don't know where to start, try utils::package.skeleton or the pkgKitten package (which aims to pass R CMD check right from the start). There's also books like R Packages by Hadley Wickham and Jennifer Bryan, but they mention a lot of techniques and third-party dependencies that you don't have to use.
??? # first load the included library (it could easily be compiled
on the target machine)
??? dyn.load("tinyfiledialogsLinux64.so")
You will need to put your source files into the src/ subdirectory of the package and arrange for them to get compiled (see WRE 1.1.5 and 1.2.1). It's best to write a special entry point in order to let R know about the functions you intend to call (see WRE 5.4). Does your code have third-party dependencies? If you'd like to put the package on CRAN, you will need to bundle your own code with the package (since it's probably not available yet in major GNU/Linux distributions, macOS recipes and MXE) but set up a ./configure script to locate the third-party dependencies while the package is being installed:https://cran.r-project.org/web/packages/external_libs.html
?? ?? result <- .C("tfd_openFileDialog",
?? ???????? charToRaw(aTitle),
In R, strings have encodings. A string can be stored in UTF-8, Latin-1,
the native locale encoding (which may include anything from
Windows-936 to KOI8-R) or even as arbitrary bytes, which admittedly
makes it less of a string (see ?Encoding).
x1 <- `Encoding<-`('fran\xe7ais', 'latin1')
x2 <- `Encoding<-`('fran\xc3\xa7ais', 'UTF-8')
x1 == x2 # TRUE, they encode the same characters
identical(charToRaw(x1), charToRaw(x2)) # not even the same length
Which encoding does tfd_openFileDialog() use for the file names and
paths? Does it work with UCRT on Windows in UTF-8 locale mode? (Can you
return a filename that is not representable in the ANSI codepage?) You
will probably need to convert the strings into a certain encoding before
passing them to tfd_openFileDialog(...) (e.g. enc2utf8(.)).
?? ?? if ( result$lOpenFile == "NULL" ) return()
What happens if I create a file named NULL on my system and try to open it? Good luck, and I hope that your effort results in a good R package!
Dear Guillaume - Here is a minimal example of an R package that uses C source: https://github.com/bradleyjeck/fancyRpkg As the timestamps show, I made this a few years ago, so some things might not conform to the current version of Writing R Extensions. But it should get you started. The motivation I had was to provide an R package that binds to a simulation engine written in C. That package is on CRAN and could be used as a more in depth example: https://cran.r-project.org/package=epanet2toolkit Hope this helps, Brad
On Fri, Sep 22, 2023 at 6:33?AM <tinyfiledialogs at ysengrin.com> wrote:
Hi, There are no dependencies and everything is considered/treated as UTF-8. On windows, I internally do all the conversions between UTF-8 and UTF-16. I also offer functions to convert between UTF-8 , UTF-16 and MBCS. I don't know what UCRT is, but tinyfiledialogs is compatible with all versions of windows from XP to 11, all the versions of mac since osx 10.2 and all the unix versions I have ever came accross. I was hoping to find a tldr version of the "how to write an extension". The source code is just one C file (+ header) and one R file for the interface. What files are supposed to be in my package ? the C file or the compiled shared libraries ? What else ? a documentation file ? is there a model to follow ? thanks for your help guillaume On 9/21/23 11:33, Ivan Krylov wrote:
Dear Guillaume Vareille, ? Wed, 20 Sep 2023 12:30:53 +0200 tinyfiledialogs at ysengrin.com ?????:
I've been pointed to the documentation link on how to write a package, but it would really help if someone who knows what to do could direct me.
There's potentially a lot to tell. Converting the entire Writing R Extensions [*] into e-mails is a poor use of one's time. Do you have more specific questions? If you don't know where to start, try utils::package.skeleton or the pkgKitten package (which aims to pass R CMD check right from the start). There's also books like R Packages by Hadley Wickham and Jennifer Bryan, but they mention a lot of techniques and third-party dependencies that you don't have to use.
# first load the included library (it could easily be compiled
on the target machine)
dyn.load("tinyfiledialogsLinux64.so")
You will need to put your source files into the src/ subdirectory of the package and arrange for them to get compiled (see WRE 1.1.5 and 1.2.1). It's best to write a special entry point in order to let R know about the functions you intend to call (see WRE 5.4). Does your code have third-party dependencies? If you'd like to put the package on CRAN, you will need to bundle your own code with the package (since it's probably not available yet in major GNU/Linux distributions, macOS recipes and MXE) but set up a ./configure script to locate the third-party dependencies while the package is being installed:https://cran.r-project.org/web/packages/external_libs.html
result <- .C("tfd_openFileDialog",
charToRaw(aTitle),
In R, strings have encodings. A string can be stored in UTF-8, Latin-1,
the native locale encoding (which may include anything from
Windows-936 to KOI8-R) or even as arbitrary bytes, which admittedly
makes it less of a string (see ?Encoding).
x1 <- `Encoding<-`('fran\xe7ais', 'latin1')
x2 <- `Encoding<-`('fran\xc3\xa7ais', 'UTF-8')
x1 == x2 # TRUE, they encode the same characters
identical(charToRaw(x1), charToRaw(x2)) # not even the same length
Which encoding does tfd_openFileDialog() use for the file names and
paths? Does it work with UCRT on Windows in UTF-8 locale mode? (Can you
return a filename that is not representable in the ANSI codepage?) You
will probably need to convert the strings into a certain encoding before
passing them to tfd_openFileDialog(...) (e.g. enc2utf8(.)).
if ( result$lOpenFile == "NULL" ) return()
What happens if I create a file named NULL on my system and try to open it? Good luck, and I hope that your effort results in a good R package!
[[alternative HTML version deleted]]
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel