https://bugs.kde.org/show_bug.cgi?id=442739

--- Comment #17 from Igor Perković <igorp.mail...@gmail.com> ---
> git clone https://invent.kde.org/utilities/kate
 >mkdir build && cd build
> cmake .. && make -j8
changed to cmake ../kate && make -j8

> QT_PLUGIN_PATH=.bin/ ./bin/kate -n .

Other than that, it was compiled fine, except one and one only warning:

[ 52%] Building CXX object
addons/symbolviewer/CMakeFiles/katesymbolviewerplugin.dir/fortran_parser.cpp.o
/home/petra/kate/addons/snippets/snippetview.cpp: In member function ‘void
SnippetView::slotSnippetToGHNS()’:
/home/petra/kate/addons/snippets/snippetview.cpp:370:105: warning:
‘KNS3::UploadDialog::UploadDialog(const QString&, QWidget*)’ is deprecated:
Since 5.85. See API documentation [-Wdeprecated-declarations]
  370 |     KNS3::UploadDialog
dialog(QStringLiteral(":/katesnippets/ktexteditor_codesnippets_core.knsrc"),
this);
      |
                                    ^
In file included from /home/petra/kate/addons/snippets/snippetview.cpp:30:
/usr/include/KF5/KNewStuff3/kns3/uploaddialog.h:75:14: note: declared here
   75 |     explicit UploadDialog(const QString &configFile, QWidget
*parent = nullptr);
      |              ^~~~~~~~~~~~

but, successfully started new Kate!
I like some new features (new for me) like  breadcrumbs below tags, View
controls aligned straight left (below FileBrowser...)

Tried on other laptop (just in case) with AMD A4, which is slower, but
still, on regular Kate I ran Case A in 52 sec, and on my new build it was
34 sec.. Almost double... Good work!

Yeah, about AlignTab... what I use the most is prettify complex SQL code
(for better visibility and understanding), thus I use Python script for SQL
format beautifier

#!/home/igorp/python_venv/data/bin/python
# -*- coding: utf8 -*-

# 📦 PACKAGE:
# pip install sqlparse

import sys
if len(sys.argv):
    # Join all arguments into one string
    sql = ' '.join(sys.argv[1:])

    import sqlparse
    parsed = sqlparse.format(sql, indent_width=4, reindent_aligned=True,
use_space_around_operators=True, comma_first=True, keyword_case='upper')
    print(parsed)

This one works well as External tool in Kate.

But, what I can do with AlignTab is to select my query and type (i.e.):
ON|=

and my code is aligned over ON keywords and further (in pipe) where is
equal sign...

I came to this point, and never actually try to do something like that in
JavaScript... I find Lua interesting (resembling on Python) and being
really fast, but never dig deep into...


# -*- coding: utf8 -*-

"""
🏷️ ALIGN TEXT SIMPLE
👔 Igor Perković

🚀 Created: 2021-10-05 23:05:21
📅 Changed: 2022-01-23 19:20:14

💡 Idea is to extend KDE Kate with simple align function.

USAGE:

1. Type delimiter character(s)/word(s)
   in a blank line, before text you want to select and align.
2. Select delimiters along with text
3. Run this script

"""

import sys
sys.path.append(r"/home/igorp/Documents/CODE")
from df_utils import du

import numpy as np
import pandas as pd

def align_delimited_text(txt, mode=0):
    if len(txt):
        res = txt.split('\n')
        delimiter = res[0]

        acc = []
        # NOTE 💡 The Idea here is to mark these rows who contains
delimiter in a new column at first position [0]
        # and then calculate max columns length on these rows where
delimiter exists.
        #
----------------------------------------------------------------------------------------------------------
        for e,d in enumerate(res[1:]):
            if delimiter in d:
                dn = '1' + delimiter + d
            else:
                dn = '0' + delimiter + d
            tmp = dn.split(delimiter)
            acc.append(tmp)

        df = pd.DataFrame(acc)

        # Filter splitted - to see in which row exists delimiter
        dff = df[df[0]=='1']

        # After we choose the rows and subset of data for column width
measurements,
        # we may drop this column with indicator

#----------------------------------------------------------------------------
        dff = dff.drop(dff.columns[[0]], axis=1)
        df  = df.drop(df.columns[[0]], axis=1)

        dfl = df.columns.tolist()

        col_widths = np.vectorize(len)
        cw = col_widths(dff.values.astype(str)).max(axis=0)

        cwl = []
        for i in cw:
            cwl.append(i)

        for x,y in zip(dfl, cwl):
            df[x]=df[x].str.ljust(y)

        df = df.replace(np.nan, '')
        rowres = []
        for v in df.values.tolist():
            rowstr = ''
            for e,i in enumerate(v):
                if e:
                    if len(i.strip()):
                        if mode:
                            rowstr = rowstr + f'{delimiter}' + i
                        else:
                            rowstr = rowstr + ' ' + i
                else:
                    if len(i.strip()):
                        rowstr = rowstr + i
            rowres.append(rowstr)

        for t in rowres:
            print(t)

# Start. Check if we do have any selected text to process ?
if len(sys.argv):
    # Join all arguments into one string
    tmp = ' '.join(sys.argv[1:])
    try:
        align_delimited_text(tmp)
    except:
        print(tmp)
        print('Please check 1st line delimiter...')

Thank you for the assistance :)


*Igor Perković*


On Sat, 26 Mar 2022 at 02:48, Waqar Ahmed <bugzilla_nore...@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=442739
>
> --- Comment #16 from Waqar Ahmed <waqar....@gmail.com> ---
> Here are the steps.
>
> You will need git, cmake, make, gcc or clang compiler, extra-cmake-modules
> package
>
> sudo pacman -S git gcc g++ cmake make extra-cmake-modules
>
> git clone https://invent.kde.org/utilities/kate
> mkdir build && cd build
> cmake .. && make -j8
> QT_PLUGIN_PATH=.bin/ ./bin/kate -n .
>
> That should be it I think. This will be a local build i.e., won't interfere
> with the system one but will reuse the same settings. the last command
> should
> start up kate. The "QT_PLUGIN_PATH=./bin" env var is important as it will
> load
> the newly built plugins in the "bin" subdir and not your system Kate's
> plugins
> which can be confusing.
>
> Thanks for the article. I saw you were looking for something like AlignTab.
> That should actually be not that hard to implement via scripts. In fact,
> all
> our indenters are written in scripts. If you want to try, the built-in
> scripts
> can be used as reference:
> https://invent.kde.org/frameworks/ktexteditor/-/tree/master/src/script/data
>
> ^ That's where you can find the python indenter, sort, uniq and other
> stuff.
>
> --
> You are receiving this mail because:
> You reported the bug.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to