pgAdmin 4 v3 Auto Indent not working - windows

Since upgrading to 4.3, Auto Indent is not working (working in a Query Tool tab). When pressing enter at the end of a line of code, the cursor appears at a random position on the next line (sometimes right at the end) and not at the correct indentation position. This is very frustrating, as I have to click at the beginning of the line and indent correctly myself for every new line.
I have tried Chrome and Edge with no difference. I have changed the Tab Size and Use Spaces Options without any luck. I am using Windows 10 Pro.
Anyone else with this problem?

UPDATE!!!
This issue is fixed in pgAdmin 4 Version 4.3!
Thank you pgAdmin Team!
Note: This is still an issue up through pgAdmin 4 version 4.2
Updated: Feb 19, 2109
:(
/*
Issue:
(Tested on Windows Server 2012 R2, Chrome and Firefox, pgAdmin 4 3.2)
Using nested functions in a variable assignment, or just in a SQL statement
causes multiple tabs to be added when hitting enter for a new line anywhere
later in your code.
If you uncomment the first line with nested functions (below), all
carriage returns lower in the code create new lines with
many unwanted tabs.
Uncomment the line below and hit enter at the end of the line,
or before another line of code.
*/
/*
x := upper(substr('uncomment to test this. Hit enter after the semicolon.', 13));
*/
/*
My workaround is to unnest the functions and use multiple statements.
Note: Be sure the offending line above is commented out.
*/
x := substr('uncomment to test this. Hit enter after after the semicolon.', 13);
x := upper(x);

Have tried your suggestion and it does work. But it does seem odd that we have to comment out the entire offending line (i.e. with the nested text) to make this work. I haven't had this issue with other editors. For example, entering the same text in SQL Developer as follows:
SELECT *
FROM employees
WHERE deptno IN (SELECT deptno FROM departments
WHERE loc = 'CHICAGO');
Pressing enter will place the cursor under the 2nd WHERE (same as Postgres). I clear the tabs with Shift+Tab to column 1, and going forward I am fine. Each new line, cursor is at the beginning. This doesn't work with Postgres.
I am still new to a lot of this. Thank you for sharing.

Related

How to move from line to line using VI

I am using PuTTY to connect to my CentOS shell server. My only problem is the keyboard I currently use is a 60%. Meaning I have no arrow keys... Darn. How could i move around the shell without arrow keys? Thanks. If you are not familiar with PuTTy, it's just a way to connect to a server like a regular command prompt.
I have found the solution! You are actually supposed to use HKJL to move around in command mode! Not the arrow keys. Reason listed below.
https://superuser.com/questions/599150/why-arrow-keys-are-not-recommended-in-vim
J move cursor down one line
K moves cursor up
H moves cursor right
I moves cursor left
Make sure to take a look at the help manual if you're starting with VI because if for example you want to go to the end of the line at line 40 you don't want to press J 40 times and then go to the end of the line or if you're looking for an specific line or word you can use /string
Reference:
http://glaciated.org/vi/

"Compile Error: Only Comments may appear after End Sub, End Function.." Access 2010 VBA

I am creating a form and I have created my first function in the VBA window. The function creates Buttons. After I type anything after the 'End function' I get an error- "Only comments appear after .." What's wrong? Am I putting the function in the wrong area?
Here is my code:
Option Compare Database
Option Explicit
Function MainMenuOptions()
Dim frm As String
frm = "Main"
Dim SCFormB As Control
Dim SCSearchB As Control
Dim SCReportB As Control
Set SCFormB = CreateControl(frm, acOptionButton, , , , 0.5, 0.6, 1.5, 0.55)
Set SCSearchB = CreateControl(frm, acOptionButton, , , , 0.5, 1.5, 1.5, 0.55)
Set SCReportB = CreateControl(frm, acOptionButton, , , , 0.5, 2.4, 1.5, 0.55)
End Function
I have recently had this problem. I'm creating a new Shares/Derivatives trade and management application, and I'm making awesome progress on creating a form, when at one point, I starting getting this error for ALL of the _Click() handlers for the controls on the form. But, it was not happening for an _Enter() handler for one of the fields on the form. There was no extraneous text after any of the 'End' statements - at all! I discovered that, somehow, the incorrect LINE ENDINGS had made their way onto the ends of the 'End' statements.
The Fix: go to the end of each of your 'End' statements, hit DELETE until the next Sub statement comes up to the cursor (i.e., you now have the start of the next procedure on the same line as the previous proc's End statement), then hit ENTER to put the next Sub statement back on it's own line. This will ensure that you have the correct CR/LF (or whatever is required of that editor/compiler) at the ends of each of your event handlers.
Apparently, you have extra code in your module which is outside of a function or sub. In the VBA editor select debug -> compile and it should highlight the offending code which you can remove or revise.
FYI: CreateControl uses twips(one 1440th of an inch) for left, top, width, and height. You may want to multiply the numbers you are using by about 1440.
If you check the Microsoft Office Dev Center for this error message you get the following explanation:
You placed executable code outside a procedure. Any nondeclarative
lines outside a procedure must begin with a comment delimiter (').
Declarative statements must appear before the first procedure
declaration. Comments are ignored when the code executes.
This means that the type of code you can write outside a Sub or Function is limited.
I had this error, and the solution was simple, however VBA's debugger threw me off the scent for a while. I had extra code after "End Sub" that needed deleting (copy and paste error), however rather than highlighting the extra code after the "End Sub" statement, the debugger highlighted the beginning of the Sub procedure, causing me to think that the error was between the opening statement of the highlighted Sub procedure and the "End Sub" ABOVE it, when in fact the error was after the "End Sub" of the highlighted sub procedure, so I needed to look well BELOW the highlighted text. So, in effect, VBA highlighted the beginning of a sub-procedure that was entirely fine, rather than the issue immediately after it.
It's like someone leaving a bag of trash immediately outside your front door so you walk into the trash as soon as you walk through the door, and then you say "Huh, I need to move the trash" while pointing at the door.
I had this issue as well, but I didn't have any code outside of my subs. I was getting the error after Access would generate a piece of code (I was trying to add code for the NoData state of my report). When I put a dummy comment below the End Sub that was having the issue it fixed the issue, at least for the last three compiles I have done.

print line before page changed in vfp reports

I'm creating a report in vfp. The report contains grouping. In the end of each group, i draw a line. Each row in the detail band doesn't contain any line, only at the end of each group. The problem is when the group expand to the next page, in the previous page i want to draw a line at the bottom. Like this :
(page 1)
group A
name, etc
x1,etc
x2,etc
???how do I add line here?
(page 2)
group A
name,etc
x3,etc
x4,etc
group B
name,etc
y1,etc
y2,etc
I've tried to place the line in the page footer band, but the last line of the report doesn't have exact position, so it doesn't look nice.
Hope I described the situation clear enough. Thank You for taking the time to help me.
Without some significant smoke-and-mirrors trickery: running the report twice, once hidden and track where the breaks are via function calls in the report, and then again for production, its not EASILY done.
The only thing I could suggest is putting a line at the TOP of a PAGE FOOTER which prints on EVERY page. How long have you been working with VFP. Depending, I MIGHT be able to guide you through it.
Ok, here are the steps I would take. This is under the assumption that you are pre-querying the results for your report and ordering them by some means into a temporary report cursor. You need to add 2 columns to your query as place-holders and be sure your do your cursor as " INTO CURSOR READWRITE " as we will be writing to this from within the report... that is the trick.
Next, modify your report. Go to the detail band and put a single line at the bottom of it. Adjust as needed if you need a few pixels under the last detail element. Double click the line and get to the tab where it allows you to put in a "Print When" condition for the line. Enter one of the new column names called "ShowLine" (but without the quotes).
Now, the "hook" for smoke and mirrors. Create another textbox field output in the report detail. It can be as small as 2 pixels wide and never actually prints anything. It can be put at the beginning or end of the report detail, no matter, just as long as its in the detail band. Double click it to bring up what it will print. In the expression, enter the following... WhatPageAmIOn( _PageNo )
This will actually call a function we'll add to your program which writes back to your report cursor... I'll hit that next.
Now, the code. The following is a sample snippet of code I've written to query the data for the report, have the extra columns, and put into a READWRITE cursor. From that, I run the report but to NOCONSOLE so it doesn't actually visually do anything, just runs in the background. It then cycles through and looks for the break between each page and goes backward 1 record from the break and stamps that record as "ShowLine" = .T... Then run the report again as normal and you have your one line appearing in the detail band regardless of a data group, but always the last data line at the end of each page.
Here's the code
*/ Query your data, order by whatever,
*/ but tack on the two extra fields and make it READWRITE
select;
YourData,;
AnotherField,;
MoreData,;
.f. as ShowLine,;
00000 as WhatPage;
FROM ;
YourData;
ORDER BY ;
WhateverForYourReport
INTO ;
CURSOR C_RptData READWRITE
*/ Pre-run the report NOCONSOLE so your windows don't get messed up / scrolled
REPORT FORM YourReport NOCONSOLE
*/ now, go back to the cursor that your report ran with
SELECT C_RptData
*/ set a variable for the first page you are looking to find a break for.
*/ in this case, the first detail that APPEARED on page 2.
lnLastPage = 2
*/ Start at top of the report cursor file and keep going until we reach
*/ the end of file where the LOCATE can no longer find "Pages".
GO TOP
DO WHILE NOT EOF()
*/ find the first record on ex: Page 2
LOCATE FOR WhatPage = lnLastPage
*/ Did we find one?
IF FOUND()
*/ Yes, go backwards 1 record
SKIP -1
*/ This is the last detail that appeared on the page before it (ie: pg 1)
*/ Mark this line as ok to "ShowLine" the next time the report is run.
replace ShowLine WITH .T.
*/ Now, advance the page counter to look for the NEXT page break...
*/ ex: between page 2&3, 3&4, 4&5, etc...
lnLastPage = lnLastPage +1
ENDIF
ENDDO
*/ Run your final version of the report
REPORT FORM YourReport Preview (or print)
RETURN
Here's the only hook below to track/update the page associated with the detail. I don't know if you have a main "SET PROCEDURE TO" file, or just a bunch of free .PRG files all in your project, or even if your reporting is done from within a PRG file itself. however, all you need is this function to be included in any of those locations. For simplest test, I would just create it as a stand-alone .prg file (if you are NOT using SET PROCEDURE, or doing your report within a PRG file and not from within a class method/event).
FUNCTION WhatPageAmIOn
LPARAMETERS lnPage
replace whatPage WITH lnPage
RETURN ""
As in the original description, the report is going to include a field in the detail band based on a function "WhatPageamIOn" and passes the parameter of _PageNo which is the internal VFP variable that keeps track of the current report page that is typically used in report header / footers. So, as each detail is getting processed, we are "STAMPING" the detail data with whatever the page is. We return an empty string "" so nothing actually gets printed, yet we've hooked what we needed. From this, the loop finding the first record at the beginning of every page (starting at page 2), and skipping backwards to the last entry for the prior page and we're done.
Good luck.

Reformatting text (or, better, LaTeX) in 80 colums in SciTE

I recently dived into LaTeX, starting with the help of a WYSIWYM editor like Lix. Now I'm staring writing tex files in Sci-TE, It already has syntax higlighting and I adapted the tex.properties file to work in Windows showing a preview on Go [F5]
One pretty thing Lyx does, and it's hard to acheive with a common text editor, is to format text in 80 columns: I can write a paragraph and hit Return each time I reach near the edge column but if, after the first draft, I want to add or cut some words here and there I end up breaking the layout and having to rearrange newlines.
It would be useful to have a tool in Sci-TE so I can select a paragraph of text I added or deleted some words in and have it rearranged in 80 columns. Probably not something working on the whole document since it could probably break some intended anticipated line break.
Probably I could easily write a Python plugin for geany, I saw vim has something similar, but I'd like to know if its' possible in Sci-TE too.
I was a bit disappointed when I found no answer as I was searching for same. No helpers by Google either, so I searched for Lua examples and syntax in a hope to craft it myself. I don't know Lua so this can perhaps be made differently or efficiently but its better then nothing I hope - here is Lua function which needs to be put in SciTE start-up Lua script:
function wrap_text()
local border = 80
local t = {}
local pos = editor.SelectionStart
local sel = editor:GetSelText()
if #sel == 0 then return end
local para = {}
local function helper(line) table.insert(para, line) return "" end
helper((sel:gsub("(.-)\r?\n", helper)))
for k, v in pairs(para) do
line = ""
for token in string.gmatch(v, "[^%s]+") do
if string.len(token .. line) >= border then
t[#t + 1] = line
line = token .. " "
else
line = line .. token .. " "
end
end
t[#t + 1] = line:gsub("%s$", "")
end
editor:ReplaceSel(table.concat(t, "\n"))
editor:GotoPos(pos)
end
Usage is like any other function from start-up script, but for completness I'll paste my tool definition from SciTE properties file:
command.name.8.*=Wrap Text
command.mode.8.*=subsystem:lua,savebefore:no,groupundo
command.8.*=wrap_text
command.replace.selection.8.*=2
It does respect paragraphs, so it can be used on broader selection, not just one paragraph.
This is one way to do it in scite: first, add this to your .SciTEUser.properties (Options/Open User Options file):
# Column guide, indicates long lines (https://wiki.archlinux.org/index.php/SciTE)
# this is what they call "margin line" in gedit (at right),
# in scite, "margin" is the area on left for line numbers
edge.mode=1
edge.column=80
... and save, so you can see a line at 80 characters.
Then scale the scite window, so the text you see is wrapped at the line.
Finally, select the long line text which is to be broken into lines, and do Edit / Paragraph / Split (for me the shortcut Ctrl-K also works for that).
Unfortunately, there seems to be no "break-lines-as-you-type" facility in scite, like the "Line Breaking" facility in geany. not anymore, now there's a plugin - see this answer
Well, I was rather disappointed that there seems to be no "break-lines-as-you-type" facility in scite; and I finally managed to code a small Lua plugin/add-on/extension for that, and released it here:
lua-users wiki: Scite Line Break
Installation and usage instructions are in the script itself. Here is how SciTE may look when the extension properly installed, and toggle activated after startup:
Note that it's pretty much the same functionality as in geany - it inserts linebreaks upon typing text - but not on pressing backspace, nor upon copy/pasting.
the same but more easy, I think...
put this in the user properties:
command.name.0.*=swrap
command.0.*=fold -s $(FileNameExt) > /tmp/scite_temp ; cat /tmp/scite_temp >$(FileNameExt)
command.is.filter.0.*=1
Ciao
Pietro

VIM Blockwise Insert

I would like to insert a hash at the beginning of a selected block of text in VIM (ruby comment). I selected the lines in Visual Mode, but how do I perform the same operation to all lines?
You have two primary options:
Select in block visual mode (ctrl-v), then use I to insert the same thing along the left side of the entire block. Similarly A appends; see blockwise operators.
Select the lines in normal visual (v) or visual line (V) mode, then run the same command on all of them, for example s/^/# / or normal I#. Typing : while you have a visual selection automatically uses the visual selection as the line range (denoted by '<,'>).
While in visual mode do the
:'<,'>s/^/#
actually, '<,'> will be inserted automatically when you hit :.
You better use this.
COMMAND MODE with set number to see lines
:10,50s/^/#/g
First number before comma is the start line and second number after comma is the end line. Both are included.
Another question might have copied this question, so came here from How to Insert in Visual Block Mode.
Highly recommend that people take a look at this cheat sheet: http://www.rayninfo.co.uk/vimtips.html
As people do more research into VIM people will see a lot of %s/^/# with the % sign in front and by replacing the % sign with what pops up in Visual Block Mode with :'<,'> the symbols that pop up you are able to do insert, etc.
:'<,'>s/^/# (applied on selected lines only)
:%s/^/# (applied globally)
(sharing my two cents after researching how to add a hrefs' to different lines).

Resources