🔍 An RStudio addin slash regex utility belt
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

125 lines
4.5KB

  1. # ---- Regex Gadget UI ----
  2. #' @inheritParams regex_gadget
  3. regexplain_gadget_ui <- function(text = NULL, pattern = NULL, start_page = "Text") {
  4. miniPage(
  5. shiny::includeCSS(system.file("styles", "groups.css", package = "regexplain")),
  6. shiny::includeCSS(system.file("styles", "gadget.css", package = "regexplain")),
  7. gadgetTitleBar(
  8. "RegExplain",
  9. right = miniTitleBarButton("done", "Send RegEx To Console", TRUE)
  10. ),
  11. miniTabstripPanel(
  12. selected = match.arg(start_page, c("Text", "RegEx", "Output", "Help")),
  13. # --- UI - Tab - Text ----
  14. miniTabPanel(
  15. "Text", icon = icon('file-text-o'),
  16. miniContentPanel(
  17. fillCol(
  18. textAreaInputAlt('text',
  19. label = "Text to search or parse",
  20. value = paste(text, collapse = "\n"),
  21. resize = "both",
  22. width = "100%",
  23. height="90%",
  24. placeholder = "Paste, enter, or edit your sample text here.")
  25. )
  26. )
  27. ),
  28. # ---- UI - Tab - Regex ----
  29. miniTabPanel(
  30. "RegEx", icon = icon('terminal'),
  31. miniContentPanel(
  32. tags$div(
  33. id = "regexPage",
  34. class = "container-fluid",
  35. style = "height: 90%",
  36. fluidRow(
  37. id = "regexInput",
  38. tags$div(
  39. class = "col-12",
  40. textInputCode(
  41. 'pattern', 'RegEx', width = "100%",
  42. value = pattern,
  43. placeholder = "Standard RegEx, e.g. \\w+_\\d{2,4}\\s+",
  44. tags$span(class = "input-group-btn",
  45. actionButton("library_show", "Library", class = "btn-primary")
  46. )
  47. )
  48. )
  49. ),
  50. fluidRow(
  51. id = "regexOptions",
  52. checkboxGroupInput(
  53. 'regex_options',
  54. label = HTML(
  55. '<div style="font-size: 1.25rem;">',
  56. 'Option Groups: ',
  57. '<span style="color: #337ab7;">RegExplain</span>,',
  58. '<span style="color: #5cb85c;">All</span>, ',
  59. '<span style="color: #f0ad4e;">Base only</span>',
  60. '</div>'
  61. ),
  62. inline = TRUE,
  63. width = "90%",
  64. choiceValues = list(
  65. "global",
  66. "text_break_lines",
  67. "ignore.case",
  68. "fixed",
  69. "perl",
  70. "useBytes"),
  71. choiceNames = list(
  72. HTML('<span style="color: #337ab7;">Global</span>'),
  73. HTML('<span style="color: #337ab7;">Break Lines</span>'),
  74. HTML('<span style="color: #5cb85c;">Ignore Case</span>'),
  75. HTML('<span style="color: #5cb85c;">Fixed/Literal</span>'),
  76. HTML('<span style="color: #f0ad4e;">Perl Style</span>'),
  77. HTML('<span style="color: #f0ad4e;">Use Bytes</span>')),
  78. selected = c('text_break_lines', 'perl')
  79. )
  80. ),
  81. tags$div(
  82. id = "regexResult",
  83. class = "gadget-result",
  84. style = "overflow-y: scroll; height: 100%; max-height: calc(100% - 90px);",
  85. htmlOutput('result')
  86. )
  87. )
  88. )
  89. ),
  90. # ---- UI - Tab - Output ----
  91. miniTabPanel(
  92. "Output", icon = icon("table"),
  93. miniContentPanel(
  94. fillCol(
  95. flex = c(1, 3),
  96. inputPanel(
  97. tags$div(
  98. width = "100%;",
  99. selectInput('regexFn', label = 'Apply Function',
  100. choices = regexFn_choices),
  101. tags$span(class = "help-block",
  102. style = "font-size:1.25rem; margin-top:-10px; margin-bottom:0px; margin-left:4px;",
  103. "Adjust options in RegEx tab")
  104. ),
  105. uiOutput("output_sub")
  106. ),
  107. # verbatimTextOutput('output_result', placeholder = TRUE)
  108. tags$pre(
  109. id = "output_result",
  110. class = "shiny-text-output",
  111. style = "overflow-y: scroll; height: 100%;"
  112. )
  113. )
  114. )
  115. ),
  116. # ---- UI - Tab - Help ----
  117. miniTabPanel(
  118. "Help", icon = icon("support"),
  119. generate_help_ui(cheatsheet_only = FALSE)
  120. )
  121. )
  122. )
  123. }