Forum > Editor

record structure display while editing question

(1/3) > >>

440bx:
Hello,

consider code where the following declaration exists:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  FlagLabelValues : array[TFLAG_LABEL_IDS] of pchar =  { index: flvi          }  (   { fli_actions                        } 'ACTIONS:',   { fli_read                           } 'READ:',   { fli_written                        } 'WRITTEN:',    { fli_carry_flag                     }   'CF: ',   { fli_parity_flag                    }   'PF: ',   { fli_auxiliary_carry_flag           }   'AF: ',   { fli_zero_flag                      }   'ZF: ',   { fli_sign_flag                      }   'SF: ',   { fli_trap_flag                      }   'TF: ',   { fli_interrupt_enable_flag          }   'IF: ',   { fli_direction_flag                 }   'DF: ',   { fli_overflow_flag                  }   'OF: ',   { fli_io_privilege_level             } 'IOPL: ',   { fli_nested_task_flag               }   'NT: ',   { fli_resume_flag                    }   'RF: ',   { fli_virtual_8086_mode_flag         }   'VM: ',   { fli_alignment_check_flag           }   'AC: ',   { fli_virtual_interrupt_flag         }  'VIF: ',   { fli_virtual_interrupt_pending_flag }  'VIP: ',   { fli_cpuid_instruction_flag         }   'ID: '  ); 
when debugging, hovering on the presence of that identifier will cause a popup window to show the values in the array (see attachments.)

when editing, hovering on the the identifier displays a very abbreviated version of the array (see attachments.)

Is there a way to tell the editor to show the entire array (or at least more than just its definition) ?

Thank you for your help.


Khrys:
I'm afraid this isn't possible - here's why:

const  symbols in Free Pascal actually come in two flavors: typed and untyped constants:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  ALPHA = 1;          // Untyped constant  BETA: Integer = 2;  // Typed constant (Integer)
Untyped constants are truly constant; their value can never be changed under any circumstances. They are similiar to  #define  macro constants in C in that they are basically textually substituted in the source code (with some exceptions), and as a consequence it isn't possible to i.e. take the address of an untyped constant.

Typed constants on the other hand aren't really constant at all: with the  {$WRITABLECONST}  modeswitch disabled ({$J-}, which is the default behaviour!) typed constants can be reassigned as you wish - they behave pretty much exactly like (static) variables (ability to take address, generates linker symbol etc.). For example, this is perfectly legal code:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure DoSomething();const  CallCounter: Integer = 0;begin  // Do some work...  CallCounter += 1;  WriteLn(Format('DoSomething() was called %d time(s) so far', [CallCounter]));end;
In C you'd use a static variable for this purpose:


--- Code: C  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---void do_something(){    static int call_counter = 0;    // Do some work...    call_counter++;    printf("do_something() was called %d time(s) so far\n", call_counter);}
So, the point I'm trying to make is this: Typed constants under the hood are indistinguishable from regular variables to the compiler, so in essence what you're asking the IDE to display when hovering is the value of a variable, which of course is only possible at runtime. Note that in the popup while debugging, memory addresses are shown.

The solution to this would be to use untyped constants, but unfortunately those can only be ordinals, floats, sets, chars, strings and the  nil  pointer - no arrays.

440bx:
Hi Khrys,

Thank you for the reply.  Maybe I wasn't clear.  I just want the editor to show me what was typed, nothing else.  IOW, I don't want any operation done on the array, just a little popup that shows the text that defines the array.

Yet, IOW, instead of having to jump to its definition (by right clicking and jumping to it) and then coming back to the original spot, I just want the editor to show the definition in a little popup window (saves having to jump there and back.)


Khrys:
Oh, you mean a preview of the source... my bad  :-[

Yes, that would be really convenient actually. You mentioned right-click jump, that's a hassle for sure... I usually do  CTRL + left click  and then jump back with  CTRL + H  or one of those extra buttons my mouse has (two buttons near the thumb that allow jumping back and forth - not only in browsers, but also in Lazarus)

440bx:

--- Quote from: Khrys on May 09, 2024, 09:11:51 am ---Oh, you mean a preview of the source... my bad  :-[

--- End quote ---
Don't worry about it.  I re-read what I wrote in my OP and, on second thought, I don't think I made it really clear what I was looking for.

Navigation

[0] Message Index

[#] Next page

Go to full version