fixed a bug where the autocompletion did not put the cursor at the end

This commit is contained in:
janis
2022-08-22 19:06:39 +02:00
parent 340c2bb402
commit 0f8b20be69
5 changed files with 17 additions and 12 deletions

View File

@@ -21,12 +21,10 @@ class AutoComplete:
def autocomplete(self, text): def autocomplete(self, text):
self.text = str(text) self.text = str(text)
print(self.text, "TEXT")
if self.text[len(self.text) - 2:] == "\t\n": if self.text[len(self.text) - 2:] == "\t\n":
self.text = self.text[:len(self.text) - 2] self.text = self.text[:len(self.text) - 2]
elif self.text[len(self.text) - 1:] == "\t": elif self.text[len(self.text) - 1:] == "\t":
self.text = self.text[:len(self.text) - 1] self.text = self.text[:len(self.text) - 1]
print(self.text, "T2")
if self.text == "": if self.text == "":
self.text = "/" self.text = "/"
self.path = "/" self.path = "/"
@@ -36,28 +34,22 @@ class AutoComplete:
self.path = self.text[:len(self.text) - 1] self.path = self.text[:len(self.text) - 1]
while self.path[len(self.path) - 1:] != "/": while self.path[len(self.path) - 1:] != "/":
self.path = self.path[:len(self.path) - 1] self.path = self.path[:len(self.path) - 1]
print(self.path, "PATH")
self.__command_list = os.listdir(self.path) self.__command_list = os.listdir(self.path)
print(self.__command_list)
self.__return_value = [] self.__return_value = []
self.__return_value_assembly = "" self.__return_value_assembly = ""
self.__possible_completion = [] self.__possible_completion = []
self.__command_count = 0 self.__command_count = 0
self.check = "" self.check = ""
self.check_in = self.text self.check_in = self.text
print("refactoring")
while self.check_in[len(self.check_in) - 1:] != "/": while self.check_in[len(self.check_in) - 1:] != "/":
self.check += str(self.check_in[len(self.check_in) - 1:]) self.check += str(self.check_in[len(self.check_in) - 1:])
self.check_in = self.check_in[:len(self.check_in) - 1] self.check_in = self.check_in[:len(self.check_in) - 1]
self.check = self.check[::-1] self.check = self.check[::-1]
print(self.check, "CHECK")
for self.item in self.__command_list: for self.item in self.__command_list:
print(self.check, self.item[:len(self.check)])
if self.check == self.item[:len(self.check)]: if self.check == self.item[:len(self.check)]:
self.__possible_completion.append(f'{self.path}{self.item}/') self.__possible_completion.append(f'{self.path}{self.item}/')
else: else:
pass pass
print(self.__possible_completion)
if len(self.__possible_completion) < 1: if len(self.__possible_completion) < 1:
self.__return_value = ["No such file or directory", self.text[:len(self.text)]] self.__return_value = ["No such file or directory", self.text[:len(self.text)]]
elif len(self.__possible_completion) == 1: elif len(self.__possible_completion) == 1:

View File

@@ -87,8 +87,10 @@ RootScreen:
hint_text: "Path to Folder containing the Music files" hint_text: "Path to Folder containing the Music files"
pos_hint: {"x":0.2, "y":0.5} pos_hint: {"x":0.2, "y":0.5}
size_hint_x: 0.6 size_hint_x: 0.6
focus: True
text: "" text: ""
on_text: root.autocomplete() on_text:
root.autocomplete()
Label: Label:
text: "" text: ""
pos_hint: {"x": 0.2, "y":1} pos_hint: {"x": 0.2, "y":1}
@@ -170,6 +172,7 @@ RootScreen:
FloatLayout: FloatLayout:
Label: Label:
text: "Currently Playing" text: "Currently Playing"
id: titleinfo
bold: True bold: True
italic: True italic: True
pos_hint: {"y": 0.35} pos_hint: {"y": 0.35}
@@ -195,6 +198,7 @@ RootScreen:
shorten: False shorten: False
halign: "center" halign: "center"
Label: Label:
id: upcoming_ind
text: "upcoming" text: "upcoming"
bold: True bold: True
italic: True italic: True

0
data/settings.ini Normal file
View File

View File

@@ -1,3 +1,3 @@
1 9
Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3 Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3
176.2394561767578 110.88689422607422
1 1 9
2 Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3 Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3
3 176.2394561767578 110.88689422607422

View File

@@ -4,6 +4,7 @@ import signal
# os.environ["KIVY_NO_CONSOLELOG"] = "1" # os.environ["KIVY_NO_CONSOLELOG"] = "1"
from kivy.core.window import Window, Config from kivy.core.window import Window, Config
from kivy.uix.screenmanager import ScreenManager from kivy.uix.screenmanager import ScreenManager
from kivymd.uix.textfield import MDTextField
from kivymd.uix.screen import MDScreen from kivymd.uix.screen import MDScreen
from kivymd.app import MDApp from kivymd.app import MDApp
from kivy.base import Builder from kivy.base import Builder
@@ -14,6 +15,7 @@ import bin.filepathanalysis
import bin.player import bin.player
import math import math
import bin.autocomplete import bin.autocomplete
import time
pl = bin.player.Player() pl = bin.player.Player()
@@ -90,10 +92,13 @@ class Home(MDScreen):
if self.input == "\t": if self.input == "\t":
self.__ac = ac.autocomplete(self.text) self.__ac = ac.autocomplete(self.text)
self.ids.cmd_output.text = self.__ac.pop(0) self.ids.cmd_output.text = self.__ac.pop(0)
self.ids.filepath.text = self.__ac.pop(0) self.output = self.__ac.pop(0)
Clock.schedule_once(self.reloadf, 0.1)
else: else:
pass pass
def reloadf(self, dt):
self.ids.filepath.text = self.output
class Main(MDScreen): class Main(MDScreen):
@@ -102,6 +107,8 @@ class Main(MDScreen):
self.instructions = multiprocessing.Value('i', 0) self.instructions = multiprocessing.Value('i', 0)
self.others = multiprocessing.Value('i', 0) self.others = multiprocessing.Value('i', 0)
self.backfeed = multiprocessing.Value('f', 0) self.backfeed = multiprocessing.Value('f', 0)
self.keyboard = Window.request_keyboard(None, self)
self.keyboard.bind(on_key_down=self.key_pressed)
self.quit_requests = 0 self.quit_requests = 0
def key_pressed(self, keyboard, keycode, text, modifiers): def key_pressed(self, keyboard, keycode, text, modifiers):
@@ -184,6 +191,8 @@ class Main(MDScreen):
self.__text_size = round(math.sqrt(((self.__windowsize_x + self.__windowsize_y) / 2)), 0) self.__text_size = round(math.sqrt(((self.__windowsize_x + self.__windowsize_y) / 2)), 0)
self.manager.get_screen("Showcase").ids.current_song.font_size = self.__text_size + 5 self.manager.get_screen("Showcase").ids.current_song.font_size = self.__text_size + 5
self.manager.get_screen("Showcase").ids.upcoming_songs.font_size = self.__text_size - 5 self.manager.get_screen("Showcase").ids.upcoming_songs.font_size = self.__text_size - 5
self.manager.get_screen("Showcase").ids.titleinfo.font_size = self.__text_size * 2.2
self.manager.get_screen("Showcase").ids.upcoming_ind.font_size = self.__text_size + 10
self.__config = cvr.importing("./data/config.csv").pop(0) self.__config = cvr.importing("./data/config.csv").pop(0)
self.__config.pop(1) self.__config.pop(1)
self.__info = cvr.importing("./data/songtemp.csv") self.__info = cvr.importing("./data/songtemp.csv")