size-calculator.lua   [B---] 37 L:[ 46+17  63/124] *(1762/3363b) 0097 0x061                   [↕][✕]
     46                                                                                             
     47 -- Shows the dialog.                                                                        
     48 --                                                                                          
     49 -- Possible 'opts': use_coma, add_other_panel.                                              
     50 --                                                                                          
     51 local function show_dialog(total, opts)                                                     
     52                                                                                             
     53   local fmt = function(n) return opts.use_comma and locale.format_number(n) or n end        
     54   local r = utils.text.round                                                                
     55                                                                                             
*    56   local dlg = ui.Dialog(T"Size calculator")                                                 
     57                                                                                             
     58   dlg:add(ui.HBox{expandx=true}:add(                                                        
     59     ui.Space{expandx=true},  -- The purpose of the two expanded Space widgets at            
     60                              -- both sides is to horizontally center the groupboxes.        
     61     ui.Groupbox(T"1024 based"):add(                                                         
     62       ui.Label(T"%s bytes":format(fmt(total))),                                             
     63       ui.Label(T"%s KiB":format(fmt(math.ceil(total / 1024)))),                             
     64       ui.Label(T"%s MiB":format(fmt(r╔══════════╗4 / 1024, 2)))),                           
     65       ui.Label(T"%s GiB":format(fmt(rmarked  4 / 1024 / 1024, 2))))                     
     66     ),                               ║ midnight ║                                           
     67     ui.Groupbox(T"1000 based (SI)"):a║ mark     ║                                           
     68       ui.Label(T"%s bytes":format(fmt║ media    ║                                           
     69       ui.Label(T"%s kB":format(fmt(ma╚══════════╝l / 1000)))),  -- "kB" is no spelling mista
     70       ui.Label(T"%s MB":format(fmt(r(total / 1000 / 1000, 2)))),                            
     71       ui.Label(T"%s GB":format(fmt(r(total / 1000 / 1000 / 1000, 2))))                      
     72     ),                                                                                      
     73     ui.Space{expandx=true}                                                                  
 1Help     2Save     3Mark     4Replac   5Copy     6Move     7Search   8Delete   9PullDn  10Quit