Author Topic: Auto indent ?  (Read 4985 times)

gordonisnz

  • Guest
Auto indent ?
« on: December 28, 2008, 02:05:44 PM »
Hi,

I've d/loaded HippoEdit tonight - & would LOVE the "auto-indent" feature....


Its listed as a feature,  & from Google searches, it is one of the "edit" commands...

however - I have no idea how to activate it / turn it on 

Is this a big secret ?

I'm looking at the "edit" functions / option on an open PHP file - & nowhere can I see an auto-complete option. (Ive been to the other options aswell)


Please help - Thanks...




Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2214
  • Karma: +37/-3
    • HippoEDIT
Re: Auto indent ?
« Reply #1 on: December 28, 2008, 03:11:11 PM »
Hello

depends what you want :)

Generally it is active by default. If you (take for example PHP) would type { and then Enter, next line should be indented on default indent. Or if you have if (something) -> Enter next line would be also auto-indented.

But if you want to correct indent for whole document, you can use Format All command (Main Menu->Format->Format All).

Best regards,
Alex

gordonisnz

  • Guest
Re: Auto indent ?
« Reply #2 on: December 29, 2008, 01:05:54 AM »
Found the format all command - But nothing happens (existing document)....

(even tred highlighting the whole document & format all) - It doesn't ask me what I want to change....

Does the auto-indent feature only work as you type ? & not on an existing document ?



Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2214
  • Karma: +37/-3
    • HippoEDIT
Re: Auto indent ?
« Reply #3 on: December 29, 2008, 01:52:31 AM »
 - Auto-Indent works only when you type.
 - "Format All" should correct indentation for complete open document. Also, if selected in options, case of keywords would be corrected. No user input required (nothing asked).

But everything depends which syntax schema is used.

Can you provide more info:
- what you expect to happen?
- which code you have tried to format with Format All?
- which syntax was used (can be found in status bar)?
- which Hippoedit version you have tried?

gordonisnz

  • Guest
Re: Auto indent ?
« Reply #4 on: December 29, 2008, 02:08:30 AM »
Can you provide more info:

- what you expect to happen?

Basically, to look through the entire document & correct the indenting

(if no indenting - create an indent - Move text / lines to the right .... )

if its indented too far - Move it to the left....

- which code you have tried to format with Format All?

PHP code

- which syntax was used (can be found in status bar)?

Plain text / ASCII / 1252 / DOS (status bar)

- which Hippoedit version you have tried? - 1.33


SAMPLE CODE :-

$temp=$_COOKIE['FAQ'];
$logreport.="COOKIE FAQ = '$temp'<BR>\n";

$temp=$login['logged_in'];
$logreport.="LOGIN = '$temp' '$login'<BR>\n";

foreach($login as $ab => $ac){
$logreport.="LOGINARRAY '$ab' '$ac'<BR>\n";
}
foreach($_COOKIE as $ab => $ac){
$logreport.="COOKIE  '$ab' '$ac'<BR>\n";
}

-------------------------

It should look something like :-


$temp=$login['logged_in'];
$logreport.="LOGIN = '$temp' '$login'<BR>\n";

foreach($login as $ab => $ac){
   $logreport.="LOGINARRAY '$ab' '$ac'<BR>\n";
}
foreach($_COOKIE as $ab => $ac){
   $logreport.="COOKIE  '$ab' '$ac'<BR>\n";
}



Thats only a few lines - I've got scripts with hundreds of lines.... - & lots of scripts...

Shall i try & locate something else - to auto-indent scripts ?



Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2214
  • Karma: +37/-3
    • HippoEDIT
Re: Auto indent ?
« Reply #5 on: December 29, 2008, 02:14:36 AM »
Ok. Thanks. Now clear ;)

If you are trying to edit PHP code, then you need to use PHP syntax ;)
What is the extension of the document you have tried to edit? Strange that it was not recognized as PHP (or html).
But you can also change syntax manually. Or with Context menu (Right click on document, Synatx->PHP) or thought Main Menu -> View-> Syntax -> PHP. Then try Format All once more.

gordonisnz

  • Guest
Re: Auto indent ?
« Reply #6 on: December 29, 2008, 02:30:20 AM »
ah - Ok...

the file i'm trying to edit is  secure.class.php (not secure.php)

Ive tried syntax command - & PHP is not listed as one of them...

- I'll try renaming the file - See what happens.....



gordonisnz

  • Guest
Re: Auto indent ?
« Reply #7 on: December 29, 2008, 02:32:00 AM »
No, - changed to secureclass.php - no php in the syntax options (looking....)


Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2214
  • Karma: +37/-3
    • HippoEDIT
Re: Auto indent ?
« Reply #8 on: December 29, 2008, 11:55:47 AM »
Have you installed schemas for PHP during installation?

Choose components:
    - Language Files
        - WEB Development
             - PHP

Check that you have files php_spec.xml and html_spec.xml in you Hippoedit\data\syntax folder.

gordonisnz

  • Guest
Re: Auto indent ?
« Reply #9 on: December 29, 2008, 12:45:15 PM »
FIXED   :)

I re-installed everything - & now have all language files etc.....


Cool programme now :)



Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
Re: Auto indent ?
« Reply #10 on: December 29, 2008, 12:47:35 PM »
I have tried this with 1.3x

1) open new txt document
2) past your example into this document
Code: [Select]
$temp=$_COOKIE['FAQ'];
$logreport.="COOKIE FAQ = '$temp'<BR>\n";

$temp=$login['logged_in'];
$logreport.="LOGIN = '$temp' '$login'<BR>\n";

foreach($login as $ab => $ac){
$logreport.="LOGINARRAY '$ab' '$ac'<BR>\n";
}
foreach($_COOKIE as $ab => $ac){
$logreport.="COOKIE  '$ab' '$ac'<BR>\n";
}

3) switch syntax to PHP:       "View > Syntax > PHP"
4) select whole code:            "Edit > Selection > Select all"
5) format this selected code: "Format > Format All"

My result:
Code: [Select]
$temp=$_COOKIE['FAQ'];
$logreport.="COOKIE FAQ = '$temp'<BR>\n";

$temp=$login['logged_in'];
$logreport.="LOGIN = '$temp' '$login'<BR>\n";

foreach($login as $ab => $ac){
    $logreport.="LOGINARRAY '$ab' '$ac'<BR>\n";
}
foreach($_COOKIE as $ab => $ac){
    $logreport.="COOKIE  '$ab' '$ac'<BR>\n";
}

---

If i paste your example code into an *.php file
and open this file, then HippoEDIT enable HTML as syntax.
And with HTML-syntax the formating doesn't works.

If i do
- switch syntax to PHP:       "View > Syntax > PHP"
- select whole code:            "Edit > Selection > Select all"
- format this selected code: "Format > Format All"
then formating works too.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
Re: Auto indent ?
« Reply #11 on: December 29, 2008, 12:49:09 PM »
;D fine you worked it out, welcome to the community.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2214
  • Karma: +37/-3
    • HippoEDIT
Re: Auto indent ?
« Reply #12 on: December 29, 2008, 01:02:43 PM »
Hi Stefan,

The "base language" for PHP files is HTML. To switch to PHP block you need to have <?php ... ?> arround the code ;) As far as I know. Then formatting would work.

Best regards,
Alex.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
Re: Auto indent ?
« Reply #13 on: December 29, 2008, 06:22:59 PM »
To switch to PHP block you need to have <?php ... ?> arround the code

Aha, that's the way it works.

I just take the PHP template file from HippoEDIT 1.4 beta
and test it with the sample code.
You are right, HippoEDIT switch the syntax to PHP if i go into an PHP-block.
And the formating works too.
Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>

<?php
$temp
=$_COOKIE['FAQ'];
$logreport.="COOKIE FAQ = '$temp'<BR>\n";

$temp=$login['logged_in'];
$logreport.="LOGIN = '$temp' '$login'<BR>\n";

foreach(
$login as $ab => $ac){
$logreport.="LOGINARRAY '$ab' '$ac'<BR>\n";
}
foreach(
$_COOKIE as $ab => $ac){
$logreport.="COOKIE  '$ab' '$ac'<BR>\n";
}
print 
"Hello World!"

?>


</body>
</html>

Thanks for clarifying.